Spaces:
Sleeping
Sleeping
add number of images
Browse files
app.py
CHANGED
@@ -2,19 +2,24 @@ import gradio as gr
|
|
2 |
from diffusers import DDPMPipeline
|
3 |
|
4 |
model = 'alexktrs/CumulusCloudsGenerator'
|
5 |
-
device='
|
6 |
|
7 |
generator = DDPMPipeline.from_pretrained(model)
|
8 |
generator.to(device)
|
9 |
|
10 |
-
def generate(num_inference_steps):
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
return
|
16 |
|
17 |
-
with gr.Blocks() as demo:
|
18 |
gr.Markdown("""
|
19 |
|
20 |
# Generate Cumulus Clouds
|
@@ -22,9 +27,12 @@ with gr.Blocks() as demo:
|
|
22 |
""")
|
23 |
|
24 |
gallery=gr.Gallery(type="pil")
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
27 |
btn = gr.Button("Generate Clouds")
|
28 |
-
btn.click(fn=generate, inputs=slider, outputs=gallery)
|
29 |
|
30 |
demo.launch()
|
|
|
2 |
from diffusers import DDPMPipeline
|
3 |
|
4 |
model = 'alexktrs/CumulusCloudsGenerator'
|
5 |
+
device='cuda'
|
6 |
|
7 |
generator = DDPMPipeline.from_pretrained(model)
|
8 |
generator.to(device)
|
9 |
|
10 |
+
def generate(num_images, num_inference_steps):
|
11 |
+
images=[]
|
12 |
+
print(num_images)
|
13 |
+
if num_images==None:
|
14 |
+
num_images=1
|
15 |
+
num_images=int(num_images)
|
16 |
|
17 |
+
for i in range(num_images):
|
18 |
+
image = generator(num_inference_steps=num_inference_steps).images[0]
|
19 |
+
images.append(image)
|
20 |
+
return images
|
21 |
|
22 |
+
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
23 |
gr.Markdown("""
|
24 |
|
25 |
# Generate Cumulus Clouds
|
|
|
27 |
""")
|
28 |
|
29 |
gallery=gr.Gallery(type="pil")
|
30 |
+
|
31 |
+
with gr.Row():
|
32 |
+
slider=gr.Slider(label='Inference Steps', minimum=1, maximum=100, step=1, value=20)
|
33 |
+
n=gr.Number(label='Number of Generated Images', minimum=1, maximum=4, value=2)
|
34 |
+
|
35 |
btn = gr.Button("Generate Clouds")
|
36 |
+
btn.click(fn=generate, inputs=[n, slider], outputs=gallery)
|
37 |
|
38 |
demo.launch()
|