ginipick commited on
Commit
82dcf73
ยท
verified ยท
1 Parent(s): 62bf7b3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +186 -106
app.py CHANGED
@@ -369,44 +369,26 @@ You are allowed to make up film and branding names, and do them like 80's, 90's
369
  char_limit = compression_chars[compression_level]
370
  base_prompt += f" Compress the output to be concise while retaining key visual details. MAX OUTPUT SIZE no more than {char_limit} characters."
371
 
372
- # OpenAI API ์š”์ฒญ ํฌ๋งท ์‚ฌ์šฉ
373
- response = self.client.responses.create(
374
  model=openai_model,
375
- input=[
376
  {
377
  "role": "system",
378
- "content": [
379
- {
380
- "type": "input_text",
381
- "text": "You are a helpful assistant. Try your best to give best response possible to user."
382
- }
383
- ]
384
  },
385
  {
386
  "role": "user",
387
- "content": [
388
- {
389
- "type": "input_text",
390
- "text": f"{base_prompt}\nDescription: {input_text}"
391
- }
392
- ]
393
  }
394
  ],
395
- text={
396
- "format": {
397
- "type": "text"
398
- }
399
- },
400
- reasoning={},
401
- tools=[],
402
  temperature=1,
403
- max_output_tokens=2048,
404
- top_p=1,
405
- store=True
406
  )
407
 
408
  # ์‘๋‹ต ์ถ”์ถœ
409
- output = response.content[0].text
410
 
411
  # ์ถœ๋ ฅ ์ •๋ฆฌ
412
  if ": " in output:
@@ -416,108 +398,198 @@ You are allowed to make up film and branding names, and do them like 80's, 90's
416
  if len(sentences) > 1:
417
  output = ". ".join(sentences[1:]).strip()
418
 
 
 
 
419
  return output
420
 
421
  except Exception as e:
422
  print(f"An error occurred: {e}")
423
  return f"Error occurred while processing the request: {str(e)}"
424
 
 
425
  css = """
426
  footer {
427
  visibility: hidden;
428
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
429
  """
430
 
431
  def create_interface():
432
  prompt_generator = PromptGenerator()
433
  openai_node = OpenAIGenerationNode()
 
434
  with gr.Blocks(theme="soft", css=css) as demo:
435
-
 
 
 
 
 
 
 
436
 
437
- gr.HTML("<h1>Flux Prompt Generator(ํ”„๋กฌํ”„ํŠธ์— ํ•œ๊ธ€ ์ž…๋ ฅ ๊ฐ€๋Šฅ)</h1>")
438
-
439
- gr.HTML(
440
- """
441
- <div class='container' style='display:flex; justify-content:center; gap:12px;'>
442
- <a href="https://huggingface.co/spaces/openfree/Best-AI" target="_blank">
443
- <img src="https://img.shields.io/static/v1?label=OpenFree&message=BEST%20AI%20Services&color=%230000ff&labelColor=%23000080&logo=huggingface&logoColor=%23ffa500&style=for-the-badge" alt="OpenFree badge">
444
- </a>
445
-
446
- <a href="https://discord.gg/openfreeai" target="_blank">
447
- <img src="https://img.shields.io/static/v1?label=Discord&message=Openfree%20AI&color=%230000ff&labelColor=%23800080&logo=discord&logoColor=white&style=for-the-badge" alt="Discord badge">
448
- </a>
449
- </div>
450
- """
451
- )
452
-
453
 
 
454
  with gr.Row():
 
455
  with gr.Column(scale=2):
456
- with gr.Accordion("Basic Settings"):
457
- seed = gr.Slider(0, 30000, label='Seed', step=1, value=random.randint(0,30000))
458
- custom = gr.Textbox(label="Custom Input Prompt (optional)")
459
- subject = gr.Textbox(label="Subject (optional)")
 
460
 
461
- # Add the radio button for global option selection
 
462
  global_option = gr.Radio(
463
  ["Disabled", "Random", "No Figure Rand"],
464
- label="Set all options to:",
465
- value="Disabled"
 
466
  )
467
 
468
- with gr.Accordion("Artform and Photo Type", open=False):
469
- artform = gr.Dropdown(["disabled", "random"] + ARTFORM, label="Artform", value="disabled")
470
- photo_type = gr.Dropdown(["disabled", "random"] + PHOTO_TYPE, label="Photo Type", value="disabled")
 
 
471
 
472
- with gr.Accordion("Character Details", open=False):
473
- body_types = gr.Dropdown(["disabled", "random"] + BODY_TYPES, label="Body Types", value="disabled")
474
- default_tags = gr.Dropdown(["disabled", "random"] + DEFAULT_TAGS, label="Default Tags", value="disabled")
475
- roles = gr.Dropdown(["disabled", "random"] + ROLES, label="Roles", value="disabled")
476
- hairstyles = gr.Dropdown(["disabled", "random"] + HAIRSTYLES, label="Hairstyles", value="disabled")
477
- clothing = gr.Dropdown(["disabled", "random"] + CLOTHING, label="Clothing", value="disabled")
 
478
 
479
- with gr.Accordion("Scene Details", open=False):
480
- place = gr.Dropdown(["disabled", "random"] + PLACE, label="Place", value="disabled")
481
- lighting = gr.Dropdown(["disabled", "random"] + LIGHTING, label="Lighting", value="disabled")
482
- composition = gr.Dropdown(["disabled", "random"] + COMPOSITION, label="Composition", value="disabled")
483
- pose = gr.Dropdown(["disabled", "random"] + POSE, label="Pose", value="disabled")
484
- background = gr.Dropdown(["disabled", "random"] + BACKGROUND, label="Background", value="disabled")
 
485
 
486
- with gr.Accordion("Style and Artist", open=False):
487
- additional_details = gr.Dropdown(["disabled", "random"] + ADDITIONAL_DETAILS, label="Additional Details", value="disabled")
488
- photography_styles = gr.Dropdown(["disabled", "random"] + PHOTOGRAPHY_STYLES, label="Photography Styles", value="disabled")
489
- device = gr.Dropdown(["disabled", "random"] + DEVICE, label="Device", value="disabled")
490
- photographer = gr.Dropdown(["disabled", "random"] + PHOTOGRAPHER, label="Photographer", value="disabled")
491
- artist = gr.Dropdown(["disabled", "random"] + ARTIST, label="Artist", value="disabled")
492
- digital_artform = gr.Dropdown(["disabled", "random"] + DIGITAL_ARTFORM, label="Digital Artform", value="disabled")
 
493
 
494
- generate_button = gr.Button("Generate Prompt")
495
 
 
496
  with gr.Column(scale=2):
497
- with gr.Accordion("Image and Caption", open=False):
498
- input_image = gr.Image(label="Input Image (optional)")
499
- caption_output = gr.Textbox(label="Generated Caption", lines=3)
500
- create_caption_button = gr.Button("Create Caption")
501
- add_caption_button = gr.Button("Add Caption to Prompt")
502
-
503
- with gr.Accordion("Prompt Generation", open=True):
504
- output = gr.Textbox(label="Generated Prompt / Input Text", lines=4)
505
- t5xxl_output = gr.Textbox(label="T5XXL Output", visible=True)
506
- clip_l_output = gr.Textbox(label="CLIP L Output", visible=True)
507
- clip_g_output = gr.Textbox(label="CLIP G Output", visible=True)
 
 
 
 
508
 
 
509
  with gr.Column(scale=2):
510
- with gr.Accordion("Prompt Generation with OpenAI", open=True):
511
- # ๋ชจ๋ธ ์„ ํƒ ์ œ๊ฑฐ ๋ฐ ์•ˆ๋‚ด ํ…์ŠคํŠธ ๋ณ€๊ฒฝ
512
- gr.HTML("<small>๊ธฐ๋ณธ ๋ชจ๋ธ: gpt-4.1-mini</small>")
513
- happy_talk = gr.Checkbox(label="Happy Talk", value=True)
514
- compress = gr.Checkbox(label="Compress", value=True)
515
- compression_level = gr.Radio(["soft", "medium", "hard"], label="Compression Level", value="hard")
516
- poster = gr.Checkbox(label="Poster", value=False)
517
- custom_base_prompt = gr.Textbox(label="Custom Base Prompt", lines=5)
518
- generate_text_button = gr.Button("Generate Prompt with OpenAI")
519
- text_output = gr.Textbox(label="Generated Text", lines=10)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
520
 
 
521
  def create_caption(image):
522
  if image is not None:
523
  return florence_caption(image)
@@ -543,7 +615,6 @@ def create_interface():
543
  outputs=[output]
544
  )
545
 
546
- # ํ•จ์ˆ˜ ํ˜ธ์ถœ ์‹œ ํŒŒ๋ผ๋ฏธํ„ฐ ์ˆ˜์ •
547
  generate_text_button.click(
548
  lambda input_text, happy_talk, compress, compression_level, poster, custom_base_prompt:
549
  openai_node.generate(input_text, happy_talk, compress, compression_level, poster, custom_base_prompt),
@@ -551,28 +622,37 @@ def create_interface():
551
  outputs=text_output
552
  )
553
 
 
 
 
 
 
 
 
 
554
  def update_all_options(choice):
555
  updates = {}
 
 
 
 
 
 
556
  if choice == "Disabled":
557
- for dropdown in [
558
- artform, photo_type, body_types, default_tags, roles, hairstyles, clothing,
559
- place, lighting, composition, pose, background, additional_details,
560
- photography_styles, device, photographer, artist, digital_artform
561
- ]:
562
  updates[dropdown] = gr.update(value="disabled")
563
  elif choice == "Random":
564
- for dropdown in [
565
- artform, photo_type, body_types, default_tags, roles, hairstyles, clothing,
566
- place, lighting, composition, pose, background, additional_details,
567
- photography_styles, device, photographer, artist, digital_artform
568
- ]:
569
  updates[dropdown] = gr.update(value="random")
570
  else: # No Figure Random
 
571
  for dropdown in [photo_type, body_types, default_tags, roles, hairstyles, clothing, pose, additional_details]:
572
  updates[dropdown] = gr.update(value="disabled")
 
573
  for dropdown in [artform, place, lighting, composition, background, photography_styles, device, photographer, artist, digital_artform]:
574
  updates[dropdown] = gr.update(value="random")
575
- return updates
 
576
 
577
  global_option.change(
578
  update_all_options,
 
369
  char_limit = compression_chars[compression_level]
370
  base_prompt += f" Compress the output to be concise while retaining key visual details. MAX OUTPUT SIZE no more than {char_limit} characters."
371
 
372
+ # ์˜ฌ๋ฐ”๋ฅธ OpenAI API ํ˜ธ์ถœ ํ˜•์‹
373
+ response = self.client.chat.completions.create(
374
  model=openai_model,
375
+ messages=[
376
  {
377
  "role": "system",
378
+ "content": "You are a helpful assistant. Try your best to give best response possible to user."
 
 
 
 
 
379
  },
380
  {
381
  "role": "user",
382
+ "content": f"{base_prompt}\nDescription: {input_text}"
 
 
 
 
 
383
  }
384
  ],
 
 
 
 
 
 
 
385
  temperature=1,
386
+ max_tokens=2048,
387
+ top_p=1
 
388
  )
389
 
390
  # ์‘๋‹ต ์ถ”์ถœ
391
+ output = response.choices[0].message.content
392
 
393
  # ์ถœ๋ ฅ ์ •๋ฆฌ
394
  if ": " in output:
 
398
  if len(sentences) > 1:
399
  output = ". ".join(sentences[1:]).strip()
400
 
401
+ # ํ”„๋กฌํ”„ํŠธ ์ €์žฅ
402
+ self.save_prompt(output)
403
+
404
  return output
405
 
406
  except Exception as e:
407
  print(f"An error occurred: {e}")
408
  return f"Error occurred while processing the request: {str(e)}"
409
 
410
+ # ๊ฐœ์„ ๋œ CSS
411
  css = """
412
  footer {
413
  visibility: hidden;
414
  }
415
+ .main-title {
416
+ text-align: center;
417
+ margin: 20px 0;
418
+ }
419
+ .main-title h1 {
420
+ color: #2c3e50;
421
+ font-size: 2.5em;
422
+ }
423
+ .badge-container {
424
+ display: flex;
425
+ justify-content: center;
426
+ gap: 15px;
427
+ margin: 20px 0;
428
+ }
429
+ .prompt-generator-container {
430
+ background: #f8f9fa;
431
+ border-radius: 10px;
432
+ padding: 20px;
433
+ margin: 10px 0;
434
+ }
435
+ .settings-container {
436
+ background: #ffffff;
437
+ border-radius: 8px;
438
+ padding: 15px;
439
+ margin: 10px 0;
440
+ box-shadow: 0 2px 4px rgba(0,0,0,0.1);
441
+ }
442
+ .output-container {
443
+ background: #e8f4f8;
444
+ border-radius: 8px;
445
+ padding: 15px;
446
+ margin: 10px 0;
447
+ }
448
+ .generate-button {
449
+ background: #3498db !important;
450
+ color: white !important;
451
+ font-size: 1.1em !important;
452
+ padding: 12px 24px !important;
453
+ margin: 10px 0 !important;
454
+ }
455
+ .openai-button {
456
+ background: #27ae60 !important;
457
+ color: white !important;
458
+ font-size: 1.1em !important;
459
+ padding: 12px 24px !important;
460
+ }
461
  """
462
 
463
  def create_interface():
464
  prompt_generator = PromptGenerator()
465
  openai_node = OpenAIGenerationNode()
466
+
467
  with gr.Blocks(theme="soft", css=css) as demo:
468
+ # ํ—ค๋”
469
+ with gr.Row(elem_classes="main-title"):
470
+ gr.HTML("""
471
+ <h1>๐ŸŽจ Flux Prompt Generator</h1>
472
+ <p style="text-align: center; color: #7f8c8d; font-size: 1.1em;">
473
+ ํ•œ๊ธ€ ์ž…๋ ฅ ์ง€์› | AI ๊ธฐ๋ฐ˜ ํ”„๋กฌํ”„ํŠธ ์ƒ์„ฑ๊ธฐ
474
+ </p>
475
+ """)
476
 
477
+ # ๋ฐฐ์ง€
478
+ with gr.Row(elem_classes="badge-container"):
479
+ gr.HTML("""
480
+ <a href="https://huggingface.co/spaces/openfree/Best-AI" target="_blank">
481
+ <img src="https://img.shields.io/static/v1?label=OpenFree&message=BEST%20AI%20Services&color=%230000ff&labelColor=%23000080&logo=huggingface&logoColor=%23ffa500&style=for-the-badge" alt="OpenFree badge">
482
+ </a>
483
+ <a href="https://discord.gg/openfreeai" target="_blank">
484
+ <img src="https://img.shields.io/static/v1?label=Discord&message=Openfree%20AI&color=%230000ff&labelColor=%23800080&logo=discord&logoColor=white&style=for-the-badge" alt="Discord badge">
485
+ </a>
486
+ """)
 
 
 
 
 
 
487
 
488
+ # ๋ฉ”์ธ ์ปจํ…Œ์ด๋„ˆ
489
  with gr.Row():
490
+ # ์™ผ์ชฝ ํŒจ๋„ - ์„ค์ •
491
  with gr.Column(scale=2):
492
+ with gr.Box(elem_classes="settings-container"):
493
+ gr.Markdown("### ๐ŸŽฏ ๊ธฐ๋ณธ ์„ค์ •")
494
+ seed = gr.Slider(0, 30000, label='์‹œ๋“œ๊ฐ’', step=1, value=random.randint(0,30000))
495
+ custom = gr.Textbox(label="โœ๏ธ ์ปค์Šคํ…€ ํ”„๋กฌํ”„ํŠธ (ํ•œ๊ธ€ ๊ฐ€๋Šฅ)", placeholder="์›ํ•˜๋Š” ์„ค๋ช…์„ ์ž…๋ ฅํ•˜์„ธ์š”...")
496
+ subject = gr.Textbox(label="๐ŸŽญ ์ฃผ์ œ (์„ ํƒ์‚ฌํ•ญ)", placeholder="์˜ˆ: ์•„๋ฆ„๋‹ค์šด ์—ฌ์„ฑ, ๊ท€์—ฌ์šด ๊ณ ์–‘์ด ๋“ฑ...")
497
 
498
+ # ์ „์—ญ ์˜ต์…˜ ์„ค์ •
499
+ gr.Markdown("### โšก ๋น ๋ฅธ ์„ค์ •")
500
  global_option = gr.Radio(
501
  ["Disabled", "Random", "No Figure Rand"],
502
+ label="๋ชจ๋“  ์˜ต์…˜ ์ผ๊ด„ ์„ค์ •:",
503
+ value="Disabled",
504
+ info="ํ•œ ๋ฒˆ์— ๋ชจ๋“  ์„ค์ •์„ ๋ณ€๊ฒฝํ•ฉ๋‹ˆ๋‹ค"
505
  )
506
 
507
+ # ์ƒ์„ธ ์„ค์ •๋“ค
508
+ with gr.Accordion("๐ŸŽจ ์•„ํŠธํผ & ์‚ฌ์ง„ ํƒ€์ž…", open=False):
509
+ with gr.Box(elem_classes="settings-container"):
510
+ artform = gr.Dropdown(["disabled", "random"] + ARTFORM, label="์•„ํŠธํผ", value="disabled")
511
+ photo_type = gr.Dropdown(["disabled", "random"] + PHOTO_TYPE, label="์‚ฌ์ง„ ํƒ€์ž…", value="disabled")
512
 
513
+ with gr.Accordion("๐Ÿ‘ค ์บ๋ฆญํ„ฐ ์„ค์ •", open=False):
514
+ with gr.Box(elem_classes="settings-container"):
515
+ body_types = gr.Dropdown(["disabled", "random"] + BODY_TYPES, label="์ฒดํ˜•", value="disabled")
516
+ default_tags = gr.Dropdown(["disabled", "random"] + DEFAULT_TAGS, label="๊ธฐ๋ณธ ํƒœ๊ทธ", value="disabled")
517
+ roles = gr.Dropdown(["disabled", "random"] + ROLES, label="์—ญํ• ", value="disabled")
518
+ hairstyles = gr.Dropdown(["disabled", "random"] + HAIRSTYLES, label="ํ—ค์–ด์Šคํƒ€์ผ", value="disabled")
519
+ clothing = gr.Dropdown(["disabled", "random"] + CLOTHING, label="์˜์ƒ", value="disabled")
520
 
521
+ with gr.Accordion("๐Ÿž๏ธ ์žฅ๋ฉด ์„ค์ •", open=False):
522
+ with gr.Box(elem_classes="settings-container"):
523
+ place = gr.Dropdown(["disabled", "random"] + PLACE, label="์žฅ์†Œ", value="disabled")
524
+ lighting = gr.Dropdown(["disabled", "random"] + LIGHTING, label="์กฐ๋ช…", value="disabled")
525
+ composition = gr.Dropdown(["disabled", "random"] + COMPOSITION, label="๊ตฌ๋„", value="disabled")
526
+ pose = gr.Dropdown(["disabled", "random"] + POSE, label="ํฌ์ฆˆ", value="disabled")
527
+ background = gr.Dropdown(["disabled", "random"] + BACKGROUND, label="๋ฐฐ๊ฒฝ", value="disabled")
528
 
529
+ with gr.Accordion("๐ŸŽญ ์Šคํƒ€์ผ & ์•„ํ‹ฐ์ŠคํŠธ", open=False):
530
+ with gr.Box(elem_classes="settings-container"):
531
+ additional_details = gr.Dropdown(["disabled", "random"] + ADDITIONAL_DETAILS, label="์ถ”๊ฐ€ ๋””ํ…Œ์ผ", value="disabled")
532
+ photography_styles = gr.Dropdown(["disabled", "random"] + PHOTOGRAPHY_STYLES, label="์‚ฌ์ง„ ์Šคํƒ€์ผ", value="disabled")
533
+ device = gr.Dropdown(["disabled", "random"] + DEVICE, label="์ดฌ์˜ ์žฅ๋น„", value="disabled")
534
+ photographer = gr.Dropdown(["disabled", "random"] + PHOTOGRAPHER, label="์‚ฌ์ง„์ž‘๊ฐ€", value="disabled")
535
+ artist = gr.Dropdown(["disabled", "random"] + ARTIST, label="์•„ํ‹ฐ์ŠคํŠธ", value="disabled")
536
+ digital_artform = gr.Dropdown(["disabled", "random"] + DIGITAL_ARTFORM, label="๋””์ง€ํ„ธ ์•„ํŠธํผ", value="disabled")
537
 
538
+ generate_button = gr.Button("๐Ÿš€ ํ”„๋กฌํ”„ํŠธ ์ƒ์„ฑ", variant="primary", elem_classes="generate-button")
539
 
540
+ # ์ค‘๊ฐ„ ํŒจ๋„ - ์ด๋ฏธ์ง€์™€ ์ถœ๋ ฅ
541
  with gr.Column(scale=2):
542
+ with gr.Accordion("๐Ÿ–ผ๏ธ ์ด๋ฏธ์ง€ ์บก์…˜ ์ƒ์„ฑ", open=False):
543
+ with gr.Box(elem_classes="settings-container"):
544
+ input_image = gr.Image(label="์ด๋ฏธ์ง€ ์—…๋กœ๋“œ (์„ ํƒ์‚ฌํ•ญ)", type="pil")
545
+ caption_output = gr.Textbox(label="์ƒ์„ฑ๋œ ์บก์…˜", lines=3)
546
+ with gr.Row():
547
+ create_caption_button = gr.Button("๐Ÿ“ ์บก์…˜ ์ƒ์„ฑ", variant="secondary")
548
+ add_caption_button = gr.Button("โž• ํ”„๋กฌํ”„ํŠธ์— ์ถ”๊ฐ€", variant="secondary")
549
+
550
+ with gr.Box(elem_classes="output-container"):
551
+ gr.Markdown("### ๐Ÿ“‹ ์ƒ์„ฑ๋œ ํ”„๋กฌํ”„ํŠธ")
552
+ output = gr.Textbox(label="๋ฉ”์ธ ํ”„๋กฌํ”„ํŠธ", lines=4)
553
+ with gr.Accordion("๊ณ ๊ธ‰ ์ถœ๋ ฅ ์˜ต์…˜", open=False):
554
+ t5xxl_output = gr.Textbox(label="T5XXL", lines=2)
555
+ clip_l_output = gr.Textbox(label="CLIP L", lines=2)
556
+ clip_g_output = gr.Textbox(label="CLIP G", lines=2)
557
 
558
+ # ์˜ค๋ฅธ์ชฝ ํŒจ๋„ - OpenAI
559
  with gr.Column(scale=2):
560
+ with gr.Box(elem_classes="prompt-generator-container"):
561
+ gr.Markdown("### ๐Ÿค– OpenAI ํ”„๋กฌํ”„ํŠธ ํ–ฅ์ƒ")
562
+ gr.HTML("<p style='text-align: center; color: #95a5a6;'>์‚ฌ์šฉ ๋ชจ๋ธ: gpt-4.1-mini</p>")
563
+
564
+ with gr.Box(elem_classes="settings-container"):
565
+ with gr.Row():
566
+ happy_talk = gr.Checkbox(label="๐Ÿ˜Š Happy Talk", value=True, info="๋” ์ƒ์„ธํ•œ ์„ค๋ช…")
567
+ compress = gr.Checkbox(label="๐Ÿ—œ๏ธ ์••์ถ•", value=True, info="์ถœ๋ ฅ ๊ธธ์ด ์ œํ•œ")
568
+
569
+ compression_level = gr.Radio(
570
+ ["soft", "medium", "hard"],
571
+ label="์••์ถ• ๊ฐ•๋„",
572
+ value="hard",
573
+ visible=True
574
+ )
575
+
576
+ poster = gr.Checkbox(label="๐ŸŽฌ ์˜ํ™” ํฌ์Šคํ„ฐ ์Šคํƒ€์ผ", value=False)
577
+
578
+ custom_base_prompt = gr.Textbox(
579
+ label="๐Ÿ› ๏ธ ์ปค์Šคํ…€ ๋ฒ ์ด์Šค ํ”„๋กฌํ”„ํŠธ",
580
+ lines=5,
581
+ placeholder="OpenAI์—๊ฒŒ ํŠน๋ณ„ํ•œ ์ง€์‹œ์‚ฌํ•ญ์„ ์ž…๋ ฅํ•˜์„ธ์š”..."
582
+ )
583
+
584
+ generate_text_button = gr.Button("โœจ AI๋กœ ํ”„๋กฌํ”„ํŠธ ํ–ฅ์ƒ", variant="primary", elem_classes="openai-button")
585
+
586
+ text_output = gr.Textbox(
587
+ label="๐ŸŽฏ AI ํ–ฅ์ƒ ๊ฒฐ๊ณผ",
588
+ lines=10,
589
+ elem_classes="output-container"
590
+ )
591
 
592
+ # ์ด๋ฒคํŠธ ํ•ธ๋“ค๋Ÿฌ๋“ค
593
  def create_caption(image):
594
  if image is not None:
595
  return florence_caption(image)
 
615
  outputs=[output]
616
  )
617
 
 
618
  generate_text_button.click(
619
  lambda input_text, happy_talk, compress, compression_level, poster, custom_base_prompt:
620
  openai_node.generate(input_text, happy_talk, compress, compression_level, poster, custom_base_prompt),
 
622
  outputs=text_output
623
  )
624
 
625
+ # ์••์ถ• ์ฒดํฌ๋ฐ•์Šค์— ๋”ฐ๋ฅธ ์••์ถ• ๊ฐ•๋„ ํ‘œ์‹œ/์ˆจ๊ธฐ๊ธฐ
626
+ compress.change(
627
+ lambda x: gr.update(visible=x),
628
+ inputs=[compress],
629
+ outputs=[compression_level]
630
+ )
631
+
632
+ # ์ „์—ญ ์˜ต์…˜ ๋ณ€๊ฒฝ ํ•จ์ˆ˜
633
  def update_all_options(choice):
634
  updates = {}
635
+ dropdown_list = [
636
+ artform, photo_type, body_types, default_tags, roles, hairstyles, clothing,
637
+ place, lighting, composition, pose, background, additional_details,
638
+ photography_styles, device, photographer, artist, digital_artform
639
+ ]
640
+
641
  if choice == "Disabled":
642
+ for dropdown in dropdown_list:
 
 
 
 
643
  updates[dropdown] = gr.update(value="disabled")
644
  elif choice == "Random":
645
+ for dropdown in dropdown_list:
 
 
 
 
646
  updates[dropdown] = gr.update(value="random")
647
  else: # No Figure Random
648
+ # ์บ๋ฆญํ„ฐ ๊ด€๋ จ ์„ค์ •์€ disabled
649
  for dropdown in [photo_type, body_types, default_tags, roles, hairstyles, clothing, pose, additional_details]:
650
  updates[dropdown] = gr.update(value="disabled")
651
+ # ๋‚˜๋จธ์ง€๋Š” random
652
  for dropdown in [artform, place, lighting, composition, background, photography_styles, device, photographer, artist, digital_artform]:
653
  updates[dropdown] = gr.update(value="random")
654
+
655
+ return list(updates.values())
656
 
657
  global_option.change(
658
  update_all_options,