vsrinivas commited on
Commit
e5e34c0
·
1 Parent(s): 1a73643

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio
2
+ from transformers import pipeline
3
+ import torch
4
+
5
+ def get_completion(prompt):
6
+ return pipeline(prompt)['sample'][0]
7
+
8
+ def generate(prompt):
9
+ output = get_completion(prompt)
10
+ return output
11
+
12
+ with gr.Blocks() as demo:
13
+ gr.Markdown("# Image Generation with Stable Diffusion")
14
+ with gr.Row():
15
+ with gr.Column(scale=4):
16
+ prompt = gr.Textbox(label="Your prompt") #Give prompt some real estate
17
+ with gr.Column(scale=1, min_width=50):
18
+ btn = gr.Button("Submit") #Submit button side by side!
19
+ with gr.Accordion("Advanced options", open=False): #Let's hide the advanced options!
20
+ negative_prompt = gr.Textbox(label="Negative prompt")
21
+ with gr.Row():
22
+ with gr.Column():
23
+ steps = gr.Slider(label="Inference Steps", minimum=1, maximum=100, value=25,
24
+ info="In many steps will the denoiser denoise the image?")
25
+ guidance = gr.Slider(label="Guidance Scale", minimum=1, maximum=20, value=7,
26
+ info="Controls how much the text prompt influences the result")
27
+ with gr.Column():
28
+ width = gr.Slider(label="Width", minimum=64, maximum=512, step=64, value=512)
29
+ height = gr.Slider(label="Height", minimum=64, maximum=512, step=64, value=512)
30
+ output = gr.Image(label="Result") #Move the output up too
31
+
32
+ btn.click(fn=generate, inputs=[prompt,negative_prompt,steps,guidance,width,height], outputs=[output])
33
+
34
+ demo.launch()