Spaces:
Runtime error
Runtime error
Doubleupai
commited on
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import random
|
3 |
+
from PIL import Image
|
4 |
+
import io
|
5 |
+
|
6 |
+
# Dummy functions to simulate image generation models
|
7 |
+
def ideogram_2_0_turbo(prompt):
|
8 |
+
# Simulate image generation by creating a random image
|
9 |
+
img = Image.new('RGB', (256, 256), color=(random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)))
|
10 |
+
return img
|
11 |
+
|
12 |
+
def midjourney_6_1(prompt):
|
13 |
+
# Simulate image generation by creating a random image
|
14 |
+
img = Image.new('RGB', (256, 256), color=(random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)))
|
15 |
+
return img
|
16 |
+
|
17 |
+
def flux_1_1_dev(prompt):
|
18 |
+
# Simulate image generation by creating a random image
|
19 |
+
img = Image.new('RGB', (256, 256), color=(random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)))
|
20 |
+
return img
|
21 |
+
|
22 |
+
def flux_1_1_pro(prompt):
|
23 |
+
# Simulate image generation by creating a random image
|
24 |
+
img = Image.new('RGB', (256, 256), color=(random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)))
|
25 |
+
return img
|
26 |
+
|
27 |
+
def flux_1_1_pro_ultra(prompt):
|
28 |
+
# Simulate image generation by creating a random image
|
29 |
+
img = Image.new('RGB', (256, 256), color=(random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)))
|
30 |
+
return img
|
31 |
+
|
32 |
+
def dall_e_3_0(prompt):
|
33 |
+
# Simulate image generation by creating a random image
|
34 |
+
img = Image.new('RGB', (256, 256), color=(random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)))
|
35 |
+
return img
|
36 |
+
|
37 |
+
def stable_diffusion_3_5_large(prompt):
|
38 |
+
# Simulate image generation by creating a random image
|
39 |
+
img = Image.new('RGB', (256, 256), color=(random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)))
|
40 |
+
return img
|
41 |
+
|
42 |
+
def imggen_3_0(prompt):
|
43 |
+
# Simulate image generation by creating a random image
|
44 |
+
img = Image.new('RGB', (256, 256), color=(random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)))
|
45 |
+
return img
|
46 |
+
|
47 |
+
# Function to generate images using all models
|
48 |
+
def generate_images(prompt):
|
49 |
+
images = []
|
50 |
+
images.append(ideogram_2_0_turbo(prompt))
|
51 |
+
images.append(midjourney_6_1(prompt))
|
52 |
+
images.append(flux_1_1_dev(prompt))
|
53 |
+
images.append(flux_1_1_pro(prompt))
|
54 |
+
images.append(flux_1_1_pro_ultra(prompt))
|
55 |
+
images.append(dall_e_3_0(prompt))
|
56 |
+
images.append(stable_diffusion_3_5_large(prompt))
|
57 |
+
images.append(imggen_3_0(prompt))
|
58 |
+
return images
|
59 |
+
|
60 |
+
# Create the Gradio interface
|
61 |
+
with gr.Blocks() as iface:
|
62 |
+
gr.Markdown("# Image Generation by All Models")
|
63 |
+
gr.Markdown("Enter a prompt to generate images using different models.")
|
64 |
+
|
65 |
+
with gr.Row():
|
66 |
+
prompt_input = gr.Textbox(label="Prompt")
|
67 |
+
btn_generate = gr.Button("Generate Images")
|
68 |
+
|
69 |
+
with gr.Row():
|
70 |
+
image_outputs = [gr.Image(label=f"Model {i+1}") for i in range(8)]
|
71 |
+
|
72 |
+
btn_generate.click(generate_images, inputs=prompt_input, outputs=image_outputs)
|
73 |
+
|
74 |
+
# Launch the interface
|
75 |
+
iface.launch()
|