Spaces:
Runtime error
Runtime error
Commit
·
c37ede3
1
Parent(s):
24ad498
created new ui using blocks
Browse files
app.py
CHANGED
@@ -11,15 +11,42 @@ def generate_image():
|
|
11 |
image.save("trial.png")
|
12 |
img = plt.imread("trial.png")
|
13 |
# Display the image (optional)
|
14 |
-
plt.imshow(img)
|
15 |
-
plt.axis("off")
|
16 |
-
plt.show()
|
17 |
return img
|
18 |
|
19 |
# gradio interface
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
import gradio as gr
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
image.save("trial.png")
|
12 |
img = plt.imread("trial.png")
|
13 |
# Display the image (optional)
|
14 |
+
# plt.imshow(img)
|
15 |
+
# plt.axis("off")
|
16 |
+
# plt.show()
|
17 |
return img
|
18 |
|
19 |
# gradio interface
|
20 |
+
# import gradio as gr
|
21 |
+
# iface = gr.Interface(fn=generate_image, inputs=None, outputs=[gr.Image(label="Generated Image", type="numpy", tool='editor')],
|
22 |
+
# title="Image Data Generator",
|
23 |
+
# description="This tool generates synthetic images using the DiffusionPipeline model.",
|
24 |
+
# article="### Using the Image Data Generator\n\nSimply click 'Generate Image' to create a synthetic image. The generated image will be displayed below.")
|
25 |
+
# iface.launch(debug=True)
|
26 |
+
|
27 |
+
# blocks ui
|
28 |
import gradio as gr
|
29 |
+
|
30 |
+
def generate_multiple(num):
|
31 |
+
images = []
|
32 |
+
for i in range(num):
|
33 |
+
images.append(generate_image())
|
34 |
+
|
35 |
+
with gr.Blocks() as app:
|
36 |
+
title = "Synthetic Image Generator"
|
37 |
+
with gr.Tab("Generate Single Image"):
|
38 |
+
gr.Markdown("## Using the Synthetic Generator\n\nSimply click 'Generate Image' to create a synthetic image. The generated image will be displayed below.")
|
39 |
+
gen_img = gr.Image(shape=(256,256), tool="select", type="numpy", label="Generated Image", container=True)
|
40 |
+
gen_button = gr.Button("Generate")
|
41 |
+
with gr.Tab("Generate Multiple Images"):
|
42 |
+
gr.Markdown(
|
43 |
+
"""
|
44 |
+
## Using the Synthetic Image Generator to generate multiple images
|
45 |
+
"""
|
46 |
+
)
|
47 |
+
gen_number = gr.Slider(2, 5, label="Number of Images", info="Generate multiple images")
|
48 |
+
gen_images = gr.Gallery(label="Generated Images", object_fit="contain")
|
49 |
+
gen_m_button = gr.Button("Generate Images")
|
50 |
+
gen_button.click(generate_image, inputs=None, outputs=gen_img)
|
51 |
+
gen_m_button.click(generate_multiple, inputs=gen_number, outputs=gen_images)
|
52 |
+
app.launch(debug=True)
|