Spaces:
Runtime error
Runtime error
Commit ·
b78ccbf
1
Parent(s): 4131d04
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,7 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
| 2 |
import random
|
| 3 |
|
| 4 |
def generate_image(prompt):
|
|
@@ -172,71 +175,52 @@ def generate_image(prompt):
|
|
| 172 |
]
|
| 173 |
|
| 174 |
if "face" in prompt:
|
| 175 |
-
|
| 176 |
-
return output
|
| 177 |
elif "landscape" in prompt:
|
| 178 |
-
|
| 179 |
-
return output
|
| 180 |
elif "animal" in prompt:
|
| 181 |
-
|
| 182 |
-
return output
|
| 183 |
elif "car" in prompt:
|
| 184 |
-
|
| 185 |
-
return output
|
| 186 |
elif "food" in prompt:
|
| 187 |
-
|
| 188 |
-
return output
|
| 189 |
elif "boat" in prompt:
|
| 190 |
-
|
| 191 |
-
return output
|
| 192 |
elif "logo" in prompt:
|
| 193 |
-
|
| 194 |
-
return output
|
| 195 |
elif "eye" in prompt:
|
| 196 |
-
|
| 197 |
-
return output
|
| 198 |
-
elif "food" in prompt:
|
| 199 |
-
output = random.choice(food)
|
| 200 |
-
return output
|
| 201 |
elif "beard" in prompt:
|
| 202 |
-
|
| 203 |
-
return output
|
| 204 |
elif "avatar" in prompt:
|
| 205 |
-
|
| 206 |
-
return output
|
| 207 |
elif "dreadlocks" in prompt:
|
| 208 |
-
|
| 209 |
-
return output
|
| 210 |
elif "soap" in prompt:
|
| 211 |
-
|
| 212 |
-
return output
|
| 213 |
elif "sumsung" in prompt:
|
| 214 |
-
|
| 215 |
-
return output
|
| 216 |
elif "iphone" in prompt:
|
| 217 |
-
|
| 218 |
-
return output
|
| 219 |
elif "phone" in prompt:
|
| 220 |
-
|
| 221 |
-
return output
|
| 222 |
elif "code" in prompt:
|
| 223 |
-
|
| 224 |
-
return output
|
| 225 |
elif "youtube" in prompt:
|
| 226 |
-
|
| 227 |
-
return output
|
| 228 |
elif "dog" in prompt:
|
| 229 |
-
|
| 230 |
-
return output
|
| 231 |
elif "doll" in prompt:
|
| 232 |
-
|
| 233 |
-
return output
|
| 234 |
elif "background" in prompt:
|
| 235 |
-
|
| 236 |
-
return output
|
| 237 |
else:
|
| 238 |
return "No image generated."
|
| 239 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 240 |
iface = gr.Interface(
|
| 241 |
fn=generate_image,
|
| 242 |
inputs=gr.inputs.Textbox(label="Enter prompt"),
|
|
@@ -247,7 +231,6 @@ iface = gr.Interface(
|
|
| 247 |
["I want a face"],
|
| 248 |
["I want a landscape"],
|
| 249 |
["I want an animal"]
|
| 250 |
-
# Add more example prompts if desired
|
| 251 |
]
|
| 252 |
)
|
| 253 |
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from PIL import Image
|
| 3 |
+
import requests
|
| 4 |
+
from io import BytesIO
|
| 5 |
import random
|
| 6 |
|
| 7 |
def generate_image(prompt):
|
|
|
|
| 175 |
]
|
| 176 |
|
| 177 |
if "face" in prompt:
|
| 178 |
+
output_url = random.choice(faces)
|
|
|
|
| 179 |
elif "landscape" in prompt:
|
| 180 |
+
output_url = random.choice(landscapes)
|
|
|
|
| 181 |
elif "animal" in prompt:
|
| 182 |
+
output_url = random.choice(animal)
|
|
|
|
| 183 |
elif "car" in prompt:
|
| 184 |
+
output_url = random.choice(car)
|
|
|
|
| 185 |
elif "food" in prompt:
|
| 186 |
+
output_url = random.choice(food)
|
|
|
|
| 187 |
elif "boat" in prompt:
|
| 188 |
+
output_url = random.choice(boat)
|
|
|
|
| 189 |
elif "logo" in prompt:
|
| 190 |
+
output_url = random.choice(logo)
|
|
|
|
| 191 |
elif "eye" in prompt:
|
| 192 |
+
output_url = random.choice(eye)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 193 |
elif "beard" in prompt:
|
| 194 |
+
output_url = random.choice(beard)
|
|
|
|
| 195 |
elif "avatar" in prompt:
|
| 196 |
+
output_url = random.choice(avatar)
|
|
|
|
| 197 |
elif "dreadlocks" in prompt:
|
| 198 |
+
output_url = random.choice(dreadlocks)
|
|
|
|
| 199 |
elif "soap" in prompt:
|
| 200 |
+
output_url = random.choice(soap)
|
|
|
|
| 201 |
elif "sumsung" in prompt:
|
| 202 |
+
output_url = random.choice(sumsung)
|
|
|
|
| 203 |
elif "iphone" in prompt:
|
| 204 |
+
output_url = random.choice(iphone)
|
|
|
|
| 205 |
elif "phone" in prompt:
|
| 206 |
+
output_url = random.choice(phone)
|
|
|
|
| 207 |
elif "code" in prompt:
|
| 208 |
+
output_url = random.choice(code)
|
|
|
|
| 209 |
elif "youtube" in prompt:
|
| 210 |
+
output_url = random.choice(ytlogo)
|
|
|
|
| 211 |
elif "dog" in prompt:
|
| 212 |
+
output_url = random.choice(dog)
|
|
|
|
| 213 |
elif "doll" in prompt:
|
| 214 |
+
output_url = random.choice(doll)
|
|
|
|
| 215 |
elif "background" in prompt:
|
| 216 |
+
output_url = random.choice(background)
|
|
|
|
| 217 |
else:
|
| 218 |
return "No image generated."
|
| 219 |
|
| 220 |
+
image = load_image(output_url)
|
| 221 |
+
return image
|
| 222 |
+
|
| 223 |
+
|
| 224 |
iface = gr.Interface(
|
| 225 |
fn=generate_image,
|
| 226 |
inputs=gr.inputs.Textbox(label="Enter prompt"),
|
|
|
|
| 231 |
["I want a face"],
|
| 232 |
["I want a landscape"],
|
| 233 |
["I want an animal"]
|
|
|
|
| 234 |
]
|
| 235 |
)
|
| 236 |
|