Update app.py
Browse files
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.
|
| 374 |
model=openai_model,
|
| 375 |
-
|
| 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 |
-
|
| 404 |
-
top_p=1
|
| 405 |
-
store=True
|
| 406 |
)
|
| 407 |
|
| 408 |
# ์๋ต ์ถ์ถ
|
| 409 |
-
output = response.
|
| 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 |
-
|
| 438 |
-
|
| 439 |
-
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
<
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 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.
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
|
|
|
| 460 |
|
| 461 |
-
#
|
|
|
|
| 462 |
global_option = gr.Radio(
|
| 463 |
["Disabled", "Random", "No Figure Rand"],
|
| 464 |
-
label="
|
| 465 |
-
value="Disabled"
|
|
|
|
| 466 |
)
|
| 467 |
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
|
|
|
|
|
|
| 471 |
|
| 472 |
-
with gr.Accordion("
|
| 473 |
-
|
| 474 |
-
|
| 475 |
-
|
| 476 |
-
|
| 477 |
-
|
|
|
|
| 478 |
|
| 479 |
-
with gr.Accordion("
|
| 480 |
-
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
|
| 484 |
-
|
|
|
|
| 485 |
|
| 486 |
-
with gr.Accordion("
|
| 487 |
-
|
| 488 |
-
|
| 489 |
-
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
|
|
|
|
| 493 |
|
| 494 |
-
generate_button = gr.Button("
|
| 495 |
|
|
|
|
| 496 |
with gr.Column(scale=2):
|
| 497 |
-
with gr.Accordion("
|
| 498 |
-
|
| 499 |
-
|
| 500 |
-
|
| 501 |
-
|
| 502 |
-
|
| 503 |
-
|
| 504 |
-
|
| 505 |
-
|
| 506 |
-
|
| 507 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 508 |
|
|
|
|
| 509 |
with gr.Column(scale=2):
|
| 510 |
-
with gr.
|
| 511 |
-
|
| 512 |
-
gr.HTML("<
|
| 513 |
-
|
| 514 |
-
|
| 515 |
-
|
| 516 |
-
|
| 517 |
-
|
| 518 |
-
|
| 519 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
|
|
|
|
| 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,
|