Spaces:
Runtime error
Runtime error
Commit
·
b80257e
1
Parent(s):
2e792f7
Update app.py
Browse files
app.py
CHANGED
@@ -41,4 +41,34 @@ with autocast("cuda"), torch.inference_mode():
|
|
41 |
).images
|
42 |
|
43 |
for img in images:
|
44 |
-
display(img)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
).images
|
42 |
|
43 |
for img in images:
|
44 |
+
display(img)
|
45 |
+
|
46 |
+
def inference(prompt, negative_prompt, num_samples, height=512, width=512, num_inference_steps=50, guidance_scale=7.5):
|
47 |
+
with torch.autocast("cuda"), torch.inference_mode():
|
48 |
+
return pipe(
|
49 |
+
prompt, height=int(height), width=int(width),
|
50 |
+
negative_prompt=negative_prompt,
|
51 |
+
num_images_per_prompt=int(num_samples),
|
52 |
+
num_inference_steps=int(num_inference_steps), guidance_scale=guidance_scale,
|
53 |
+
generator=g_cuda
|
54 |
+
).images
|
55 |
+
|
56 |
+
with gr.Blocks() as demo:
|
57 |
+
with gr.Row():
|
58 |
+
with gr.Column():
|
59 |
+
prompt = gr.Textbox(label="Prompt", value="photo of zwx dog in a bucket")
|
60 |
+
negative_prompt = gr.Textbox(label="Negative Prompt", value="")
|
61 |
+
run = gr.Button(value="Generate")
|
62 |
+
with gr.Row():
|
63 |
+
num_samples = gr.Number(label="Number of Samples", value=4)
|
64 |
+
guidance_scale = gr.Number(label="Guidance Scale", value=7.5)
|
65 |
+
with gr.Row():
|
66 |
+
height = gr.Number(label="Height", value=512)
|
67 |
+
width = gr.Number(label="Width", value=512)
|
68 |
+
num_inference_steps = gr.Slider(label="Steps", value=24)
|
69 |
+
with gr.Column():
|
70 |
+
gallery = gr.Gallery()
|
71 |
+
|
72 |
+
run.click(inference, inputs=[prompt, negative_prompt, num_samples, height, width, num_inference_steps, guidance_scale], outputs=gallery)
|
73 |
+
|
74 |
+
demo.launch(debug=True)
|