Spaces:
ginigen
/
Running on Zero

ginipick commited on
Commit
2bfd5d9
ยท
verified ยท
1 Parent(s): 88fe7fe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +110 -114
app.py CHANGED
@@ -222,7 +222,10 @@ def load_gallery():
222
  print(f"Error loading gallery: {str(e)}")
223
  return []
224
 
225
- # Create Gradio interface
 
 
 
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.Row():
237
- with gr.Column(scale=3):
238
- prompt = gr.Textbox(
239
- label="Image Description",
240
- placeholder="Describe the image you want to create...",
241
- lines=3
 
 
 
 
 
 
 
 
 
242
  )
243
-
244
- with gr.Accordion("Advanced Settings", open=False):
245
- with gr.Row():
246
- height = gr.Slider(
247
- label="Height",
248
- minimum=256,
249
- maximum=1152,
250
- step=64,
251
- value=1024
252
- )
253
- width = gr.Slider(
254
- label="Width",
255
- minimum=256,
256
- maximum=1152,
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
- randomize_seed = gr.Button("๐ŸŽฒ Randomize Seed", elem_classes=["generate-btn"])
288
-
289
- generate_btn = gr.Button(
290
- "โœจ Generate Image",
291
- elem_classes=["generate-btn"]
 
 
 
 
 
292
  )
293
-
294
- gr.HTML("""
295
- <div style="margin-top: 1em; padding: 1em; border-radius: 8px; background: rgba(255, 255, 255, 0.05);">
296
- <h4 style="margin: 0 0 0.5em 0;">Example Prompts:</h4>
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;">๐ŸŒ… Cinematic Landscape</p>
299
- <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>
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;">๐Ÿ–ผ๏ธ Fantasy Portrait</p>
303
- <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>
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;">๐ŸŒƒ Cyberpunk Scene</p>
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
- with gr.Column(scale=4, elem_classes=["fixed-width"]):
334
- output = gr.Image(
335
- label="Generated Image",
336
- elem_id="output-image",
337
- elem_classes=["output-image", "fixed-width"]
338
- )
339
-
340
- gallery = gr.Gallery(
341
- label="Generated Images Gallery",
342
- show_label=True,
343
- elem_id="gallery",
344
- columns=[4],
345
- rows=[2],
346
- height="auto",
347
- object_fit="cover",
348
- elem_classes=["gallery-container", "fixed-width"]
349
- )
350
-
351
- gallery.value = load_gallery()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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):