fantaxy commited on
Commit
d6137ae
1 Parent(s): 73a6dbd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -10
app.py CHANGED
@@ -312,14 +312,27 @@ with gr.Blocks(theme="Yntec/HaleyCH_Theme_Orange", css=css) as dalle:
312
  strength = gr.Slider(label="Strength", value=0.7, minimum=0, maximum=1, step=0.1)
313
  seed = gr.Slider(label="Seed (-1 for random)", value=-1, minimum=-1, maximum=1000000000, step=1)
314
 
315
- with gr.Group():
316
- gr.Markdown("### Model Selection")
317
  model_search = gr.Textbox(
318
  label="Search Models",
319
  placeholder="Type to filter models...",
320
  lines=1
321
  )
322
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
323
  models_list = [
324
  "Stable Diffusion 3.5 Large",
325
  "Stable Diffusion 3.5 Large Turbo",
@@ -363,17 +376,34 @@ with gr.Blocks(theme="Yntec/HaleyCH_Theme_Orange", css=css) as dalle:
363
  )
364
 
365
  with gr.Row():
366
- generate_btn = gr.Button("Generate Image", variant="primary", size="lg")
367
 
368
  with gr.Row():
369
- image_output = gr.Image(
370
- type="pil",
371
- label="Generated Image",
372
- show_label=True
 
 
 
373
  )
374
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
375
  generate_btn.click(
376
- fn=query,
377
  inputs=[
378
  text_prompt,
379
  model,
@@ -386,7 +416,7 @@ with gr.Blocks(theme="Yntec/HaleyCH_Theme_Orange", css=css) as dalle:
386
  width,
387
  height
388
  ],
389
- outputs=image_output
390
  )
391
 
392
  def filter_models(search_term):
@@ -396,4 +426,4 @@ with gr.Blocks(theme="Yntec/HaleyCH_Theme_Orange", css=css) as dalle:
396
  model_search.change(filter_models, inputs=model_search, outputs=model)
397
 
398
  if __name__ == "__main__":
399
- dalle.launch(show_api=False, share=False)
 
312
  strength = gr.Slider(label="Strength", value=0.7, minimum=0, maximum=1, step=0.1)
313
  seed = gr.Slider(label="Seed (-1 for random)", value=-1, minimum=-1, maximum=1000000000, step=1)
314
 
315
+ with gr.Accordion("Model Selection", open=False):
 
316
  model_search = gr.Textbox(
317
  label="Search Models",
318
  placeholder="Type to filter models...",
319
  lines=1
320
  )
321
 
322
+ # 상위 9개 모델을 기본으로 설정
323
+ default_models = [
324
+ "Stable Diffusion 3.5 Large",
325
+ "Stable Diffusion 3.5 Large Turbo",
326
+ "Stable Diffusion XL",
327
+ "FLUX.1 [Schnell]",
328
+ "FLUX.1 [Dev]",
329
+ "Midjourney",
330
+ "DreamPhotoGASM",
331
+ "Disney",
332
+ "Leonardo AI Style Illustration"
333
+ ]
334
+
335
+ # 전체 모델 리스트
336
  models_list = [
337
  "Stable Diffusion 3.5 Large",
338
  "Stable Diffusion 3.5 Large Turbo",
 
376
  )
377
 
378
  with gr.Row():
379
+ generate_btn = gr.Button("Generate 2x2 Grid", variant="primary", size="lg")
380
 
381
  with gr.Row():
382
+ gallery = gr.Gallery(
383
+ label="Generated Images",
384
+ show_label=True,
385
+ elem_id="gallery",
386
+ columns=2,
387
+ rows=2,
388
+ height="auto"
389
  )
390
 
391
+ # 2x2 그리드 생성 함수
392
+ def generate_grid(prompt, model, custom_lora, negative_prompt, steps, cfg_scale, seed, strength, width, height):
393
+ images = []
394
+ for i in range(4):
395
+ current_seed = random.randint(1, 1000000000) if seed == -1 else seed + i
396
+ try:
397
+ img = query(prompt, model, custom_lora, negative_prompt, steps, cfg_scale, current_seed, strength, width, height)
398
+ images.append(img)
399
+ except Exception as e:
400
+ print(f"Error generating image {i+1}: {str(e)}")
401
+ continue
402
+ return images
403
+
404
+ # 이벤트 핸들러
405
  generate_btn.click(
406
+ fn=generate_grid,
407
  inputs=[
408
  text_prompt,
409
  model,
 
416
  width,
417
  height
418
  ],
419
+ outputs=gallery
420
  )
421
 
422
  def filter_models(search_term):
 
426
  model_search.change(filter_models, inputs=model_search, outputs=model)
427
 
428
  if __name__ == "__main__":
429
+ dalle.launch(show_api=False, share=False)