Wootang01 commited on
Commit
022e492
1 Parent(s): 105d47f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import diffusers
3
+ import streamlit as st
4
+ device = "cpu"
5
+ from diffusers import StableDiffusionPipeline
6
+ pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", revision = "fp16", use_auth_token = st.secrets["USER_TOKEN"])
7
+ pipe = pipe.to("cpu")
8
+ from PIL import Image
9
+ import torch
10
+ def StableDiffusionPipeline (prompt, Guide, iSteps, seed):
11
+ generator = torch.Generator("cpu").manual_seed(seed)
12
+ image = pipe(prompt, num_inference_steps = iSteps, guidence_scale = Guide).images[0]
13
+ return image
14
+ iface = gr.Interface(fn = StableDiffusionPipeline, inputs = [
15
+ gr.Textbox(label = 'Prompt Input Text'),
16
+ gr.Slider(2, 15, value = 7, label = 'Guidence Scale'),
17
+ gr.Slider(10, 100, value = 25, step = 1, label = 'Number of Iterations'),
18
+ gr.Slider(
19
+ label = "Seed",
20
+ minimum = 0,
21
+ maximum = 2147483647,
22
+ step = 1,
23
+ randomize = True)
24
+ ],
25
+ outputs = 'image')
26
+ iface.launch()