Spaces:
Runtime error
Runtime error
Commit
·
1b2a439
1
Parent(s):
c0df34e
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
def inference(prompt, negative_prompt, num_samples, height=512, width=512, num_inference_steps=50, guidance_scale=7.5):
|
| 4 |
+
with torch.autocast("cuda"), torch.inference_mode():
|
| 5 |
+
return pipe(
|
| 6 |
+
prompt, height=int(height), width=int(width),
|
| 7 |
+
negative_prompt=negative_prompt,
|
| 8 |
+
num_images_per_prompt=int(num_samples),
|
| 9 |
+
num_inference_steps=int(num_inference_steps), guidance_scale=guidance_scale,
|
| 10 |
+
generator=g_cuda
|
| 11 |
+
).images
|
| 12 |
+
|
| 13 |
+
with gr.Blocks() as demo:
|
| 14 |
+
with gr.Row():
|
| 15 |
+
with gr.Column():
|
| 16 |
+
prompt = gr.Textbox(label="Prompt", value="photo of aaabbbccc man")
|
| 17 |
+
negative_prompt = gr.Textbox(label="Negative Prompt", value="")
|
| 18 |
+
run = gr.Button(value="Generate")
|
| 19 |
+
with gr.Row():
|
| 20 |
+
num_samples = gr.Number(label="Number of Samples", value=4)
|
| 21 |
+
guidance_scale = gr.Number(label="Guidance Scale", value=7.5)
|
| 22 |
+
with gr.Row():
|
| 23 |
+
height = gr.Number(label="Height", value=512)
|
| 24 |
+
width = gr.Number(label="Width", value=512)
|
| 25 |
+
num_inference_steps = gr.Slider(label="Steps", value=24)
|
| 26 |
+
with gr.Column():
|
| 27 |
+
gallery = gr.Gallery()
|
| 28 |
+
|
| 29 |
+
run.click(inference, inputs=[prompt, negative_prompt, num_samples, height, width, num_inference_steps, guidance_scale], outputs=gallery)
|
| 30 |
+
|
| 31 |
+
demo.launch(share=True)
|