Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -222,7 +222,10 @@ def load_gallery():
|
|
222 |
print(f"Error loading gallery: {str(e)}")
|
223 |
return []
|
224 |
|
225 |
-
|
|
|
|
|
|
|
226 |
with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
|
227 |
gr.HTML('<div class="title">AI Image Generator</div>')
|
228 |
gr.HTML('<div style="text-align: center; margin-bottom: 2em; color: #666;">Create stunning images from your descriptions</div>')
|
@@ -232,123 +235,116 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
|
|
232 |
โ ๏ธ Explicit or inappropriate content cannot be generated.
|
233 |
</div>
|
234 |
""")
|
235 |
-
|
236 |
-
with gr.
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
242 |
)
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
step=64,
|
258 |
-
value=1024
|
259 |
-
)
|
260 |
-
|
261 |
-
with gr.Row():
|
262 |
-
steps = gr.Slider(
|
263 |
-
label="Inference Steps",
|
264 |
-
minimum=6,
|
265 |
-
maximum=25,
|
266 |
-
step=1,
|
267 |
-
value=8
|
268 |
-
)
|
269 |
-
scales = gr.Slider(
|
270 |
-
label="Guidance Scale",
|
271 |
-
minimum=0.0,
|
272 |
-
maximum=5.0,
|
273 |
-
step=0.1,
|
274 |
-
value=3.5
|
275 |
-
)
|
276 |
-
|
277 |
-
# get_random_seed ํจ์๋ฅผ Advanced Settings ๋ด๋ถ์์ ์ ์
|
278 |
-
def get_random_seed():
|
279 |
-
return torch.randint(0, 1000000, (1,)).item()
|
280 |
-
|
281 |
-
seed = gr.Number(
|
282 |
-
label="Seed (random by default, set for reproducibility)",
|
283 |
-
value=get_random_seed(),
|
284 |
-
precision=0
|
285 |
)
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
|
|
|
|
|
|
|
|
|
|
292 |
)
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
<
|
306 |
-
|
307 |
-
<p style="margin: 0; font-style: italic;">"Neon-lit cyberpunk street market in rain, holographic advertisements reflecting in puddles, street vendors with glowing cyber-augmentations, dense urban environment, atmospheric fog, cinematic lighting, inspired by Blade Runner 2049"</p>
|
308 |
-
</div>
|
309 |
-
<div style="background: rgba(75, 121, 161, 0.1); padding: 1em; border-radius: 8px; margin-bottom: 1em;">
|
310 |
-
<p style="font-weight: bold; margin: 0 0 0.5em 0;">๐จ Abstract Art</p>
|
311 |
-
<p style="margin: 0; font-style: italic;">"Vibrant abstract composition of flowing liquid colors, dynamic swirls of iridescent purples and teals, golden geometric patterns emerging from chaos, luxury art style, ultra-detailed, painted in oil on canvas, inspired by James Jean and Gustav Klimt"</p>
|
312 |
-
</div>
|
313 |
-
<div style="background: rgba(75, 121, 161, 0.1); padding: 1em; border-radius: 8px; margin-bottom: 1em;">
|
314 |
-
<p style="font-weight: bold; margin: 0 0 0.5em 0;">๐ฟ Macro Nature</p>
|
315 |
-
<p style="margin: 0; font-style: italic;">"Extreme macro photography of a dewdrop on a butterfly wing, rainbow light refraction, crystalline clarity, intricate wing scales visible, natural bokeh background, professional studio lighting, shot with Canon MP-E 65mm lens"</p>
|
316 |
-
</div>
|
317 |
-
<!-- ์ถ๊ฐ ์์ ํ๋กฌํํธ -->
|
318 |
-
<div style="background: rgba(75, 121, 161, 0.1); padding: 1em; border-radius: 8px; margin-bottom: 1em;">
|
319 |
-
<p style="font-weight: bold; margin: 0 0 0.5em 0;">๐ค Futuristic Cityscape</p>
|
320 |
-
<p style="margin: 0; font-style: italic;">"A vibrant futuristic cityscape at night with neon lights, holograms, flying cars, and towering skyscrapers, ultra-detailed, cinematic atmosphere"</p>
|
321 |
-
</div>
|
322 |
-
<div style="background: rgba(75, 121, 161, 0.1); padding: 1em; border-radius: 8px; margin-bottom: 1em;">
|
323 |
-
<p style="font-weight: bold; margin: 0 0 0.5em 0;">๐ง Enchanted Forest</p>
|
324 |
-
<p style="margin: 0; font-style: italic;">"A mystical enchanted forest filled with luminescent flora, magical creatures, soft ethereal light, ultra-detailed, dreamlike atmosphere"</p>
|
325 |
-
</div>
|
326 |
-
<div style="background: rgba(75, 121, 161, 0.1); padding: 1em; border-radius: 8px;">
|
327 |
-
<p style="font-weight: bold; margin: 0 0 0.5em 0;">๐ Cosmic Explosion</p>
|
328 |
-
<p style="margin: 0; font-style: italic;">"A stunning cosmic explosion in deep space, vibrant nebulae, swirling galaxies, high-resolution digital art, ethereal and awe-inspiring"</p>
|
329 |
-
</div>
|
330 |
</div>
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
352 |
|
353 |
@spaces.GPU
|
354 |
def process_and_save_image(height, width, steps, scales, prompt, seed):
|
|
|
222 |
print(f"Error loading gallery: {str(e)}")
|
223 |
return []
|
224 |
|
225 |
+
def get_random_seed():
|
226 |
+
return torch.randint(0, 1000000, (1,)).item()
|
227 |
+
|
228 |
+
# Create Gradio interface with a left sidebar for inputs
|
229 |
with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
|
230 |
gr.HTML('<div class="title">AI Image Generator</div>')
|
231 |
gr.HTML('<div style="text-align: center; margin-bottom: 2em; color: #666;">Create stunning images from your descriptions</div>')
|
|
|
235 |
โ ๏ธ Explicit or inappropriate content cannot be generated.
|
236 |
</div>
|
237 |
""")
|
238 |
+
|
239 |
+
with gr.Sidebar():
|
240 |
+
# ์ข์ธก ์ฌ์ด๋๋ฐ ๋ฉ๋ด: ํ๋กฌํํธ ์
๋ ฅ ๋ฐ ๊ณ ๊ธ ์ค์
|
241 |
+
prompt = gr.Textbox(
|
242 |
+
label="Image Description",
|
243 |
+
placeholder="Describe the image you want to create...",
|
244 |
+
lines=3
|
245 |
+
)
|
246 |
+
|
247 |
+
with gr.Accordion("Advanced Settings", open=False):
|
248 |
+
height = gr.Slider(
|
249 |
+
label="Height",
|
250 |
+
minimum=256,
|
251 |
+
maximum=1152,
|
252 |
+
step=64,
|
253 |
+
value=1024
|
254 |
)
|
255 |
+
width = gr.Slider(
|
256 |
+
label="Width",
|
257 |
+
minimum=256,
|
258 |
+
maximum=1152,
|
259 |
+
step=64,
|
260 |
+
value=1024
|
261 |
+
)
|
262 |
+
with gr.Row():
|
263 |
+
steps = gr.Slider(
|
264 |
+
label="Inference Steps",
|
265 |
+
minimum=6,
|
266 |
+
maximum=25,
|
267 |
+
step=1,
|
268 |
+
value=8
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
269 |
)
|
270 |
+
scales = gr.Slider(
|
271 |
+
label="Guidance Scale",
|
272 |
+
minimum=0.0,
|
273 |
+
maximum=5.0,
|
274 |
+
step=0.1,
|
275 |
+
value=3.5
|
276 |
+
)
|
277 |
+
seed = gr.Number(
|
278 |
+
label="Seed (random by default, set for reproducibility)",
|
279 |
+
value=get_random_seed(),
|
280 |
+
precision=0
|
281 |
)
|
282 |
+
randomize_seed = gr.Button("๐ฒ Randomize Seed", elem_classes=["generate-btn"])
|
283 |
+
|
284 |
+
generate_btn = gr.Button(
|
285 |
+
"โจ Generate Image",
|
286 |
+
elem_classes=["generate-btn"]
|
287 |
+
)
|
288 |
+
|
289 |
+
# ์์ ํ๋กฌํํธ ์์ญ
|
290 |
+
gr.HTML("""
|
291 |
+
<div style="margin-top: 1em; padding: 1em; border-radius: 8px; background: rgba(255, 255, 255, 0.05);">
|
292 |
+
<h4 style="margin: 0 0 0.5em 0;">Example Prompts:</h4>
|
293 |
+
<div style="background: rgba(75, 121, 161, 0.1); padding: 1em; border-radius: 8px; margin-bottom: 1em;">
|
294 |
+
<p style="font-weight: bold; margin: 0 0 0.5em 0;">๐
Cinematic Landscape</p>
|
295 |
+
<p style="margin: 0; font-style: italic;">"A breathtaking mountain vista at golden hour, dramatic sunbeams piercing through clouds, snow-capped peaks reflecting warm light, ultra-high detail photography, artistically composed, award-winning landscape photo, shot on Hasselblad"</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
296 |
</div>
|
297 |
+
<div style="background: rgba(75, 121, 161, 0.1); padding: 1em; border-radius: 8px; margin-bottom: 1em;">
|
298 |
+
<p style="font-weight: bold; margin: 0 0 0.5em 0;">๐ผ๏ธ Fantasy Portrait</p>
|
299 |
+
<p style="margin: 0; font-style: italic;">"Ethereal portrait of an elven queen with flowing silver hair, adorned with luminescent crystals, intricate crown of twisted gold and moonstone, soft ethereal lighting, detailed facial features, fantasy art style, highly detailed, painted by Artgerm and Charlie Bowater"</p>
|
300 |
+
</div>
|
301 |
+
<div style="background: rgba(75, 121, 161, 0.1); padding: 1em; border-radius: 8px; margin-bottom: 1em;">
|
302 |
+
<p style="font-weight: bold; margin: 0 0 0.5em 0;">๐ Cyberpunk Scene</p>
|
303 |
+
<p style="margin: 0; font-style: italic;">"Neon-lit cyberpunk street market in rain, holographic advertisements reflecting in puddles, street vendors with glowing cyber-augmentations, dense urban environment, atmospheric fog, cinematic lighting, inspired by Blade Runner 2049"</p>
|
304 |
+
</div>
|
305 |
+
<div style="background: rgba(75, 121, 161, 0.1); padding: 1em; border-radius: 8px; margin-bottom: 1em;">
|
306 |
+
<p style="font-weight: bold; margin: 0 0 0.5em 0;">๐จ Abstract Art</p>
|
307 |
+
<p style="margin: 0; font-style: italic;">"Vibrant abstract composition of flowing liquid colors, dynamic swirls of iridescent purples and teals, golden geometric patterns emerging from chaos, luxury art style, ultra-detailed, painted in oil on canvas, inspired by James Jean and Gustav Klimt"</p>
|
308 |
+
</div>
|
309 |
+
<div style="background: rgba(75, 121, 161, 0.1); padding: 1em; border-radius: 8px; margin-bottom: 1em;">
|
310 |
+
<p style="font-weight: bold; margin: 0 0 0.5em 0;">๐ฟ Macro Nature</p>
|
311 |
+
<p style="margin: 0; font-style: italic;">"Extreme macro photography of a dewdrop on a butterfly wing, rainbow light refraction, crystalline clarity, intricate wing scales visible, natural bokeh background, professional studio lighting, shot with Canon MP-E 65mm lens"</p>
|
312 |
+
</div>
|
313 |
+
<!-- ์ถ๊ฐ ์์ ํ๋กฌํํธ -->
|
314 |
+
<div style="background: rgba(75, 121, 161, 0.1); padding: 1em; border-radius: 8px; margin-bottom: 1em;">
|
315 |
+
<p style="font-weight: bold; margin: 0 0 0.5em 0;">๐ค Futuristic Cityscape</p>
|
316 |
+
<p style="margin: 0; font-style: italic;">"A vibrant futuristic cityscape at night with neon lights, holograms, flying cars, and towering skyscrapers, ultra-detailed, cinematic atmosphere"</p>
|
317 |
+
</div>
|
318 |
+
<div style="background: rgba(75, 121, 161, 0.1); padding: 1em; border-radius: 8px; margin-bottom: 1em;">
|
319 |
+
<p style="font-weight: bold; margin: 0 0 0.5em 0;">๐ง Enchanted Forest</p>
|
320 |
+
<p style="margin: 0; font-style: italic;">"A mystical enchanted forest filled with luminescent flora, magical creatures, soft ethereal light, ultra-detailed, dreamlike atmosphere"</p>
|
321 |
+
</div>
|
322 |
+
<div style="background: rgba(75, 121, 161, 0.1); padding: 1em; border-radius: 8px;">
|
323 |
+
<p style="font-weight: bold; margin: 0 0 0.5em 0;">๐ Cosmic Explosion</p>
|
324 |
+
<p style="margin: 0; font-style: italic;">"A stunning cosmic explosion in deep space, vibrant nebulae, swirling galaxies, high-resolution digital art, ethereal and awe-inspiring"</p>
|
325 |
+
</div>
|
326 |
+
</div>
|
327 |
+
""")
|
328 |
+
|
329 |
+
with gr.Column():
|
330 |
+
# ๋ฉ์ธ ์์ญ: ์์ฑ๋ ์ด๋ฏธ์ง์ ๊ฐค๋ฌ๋ฆฌ ํ์
|
331 |
+
output = gr.Image(
|
332 |
+
label="Generated Image",
|
333 |
+
elem_id="output-image",
|
334 |
+
elem_classes=["output-image", "fixed-width"]
|
335 |
+
)
|
336 |
+
|
337 |
+
gallery = gr.Gallery(
|
338 |
+
label="Generated Images Gallery",
|
339 |
+
show_label=True,
|
340 |
+
elem_id="gallery",
|
341 |
+
columns=[4],
|
342 |
+
rows=[2],
|
343 |
+
height="auto",
|
344 |
+
object_fit="cover",
|
345 |
+
elem_classes=["gallery-container", "fixed-width"]
|
346 |
+
)
|
347 |
+
gallery.value = load_gallery()
|
348 |
|
349 |
@spaces.GPU
|
350 |
def process_and_save_image(height, width, steps, scales, prompt, seed):
|