Update app.py
Browse files
app.py
CHANGED
@@ -12,7 +12,7 @@ import torchvision.transforms.functional as TVF
|
|
12 |
|
13 |
|
14 |
CLIP_PATH = "google/siglip-so400m-patch14-384"
|
15 |
-
MODEL_PATH = "
|
16 |
CHECKPOINT_PATH = Path("9em124t2-499968")
|
17 |
TITLE = "<h1><center>JoyCaption Alpha One (2024-09-20a)</center></h1>"
|
18 |
CAPTION_TYPE_MAP = {
|
@@ -442,48 +442,6 @@ with gr.Blocks(theme="Hev832/Applio", css=css) as demo:
|
|
442 |
value="any",
|
443 |
)
|
444 |
|
445 |
-
lens_type = gr.Dropdown(
|
446 |
-
choices=get_dropdown_choices(lens_types_info),
|
447 |
-
label="Lens Type",
|
448 |
-
visible=False,
|
449 |
-
info="Select a lens type to define the perspective and field of view of the image."
|
450 |
-
)
|
451 |
-
|
452 |
-
film_stock = gr.Dropdown(
|
453 |
-
choices=get_dropdown_choices(film_stocks_info),
|
454 |
-
label="Film Stock",
|
455 |
-
visible=False,
|
456 |
-
info="Choose a film stock to determine the color, grain, and overall look of the image."
|
457 |
-
)
|
458 |
-
|
459 |
-
composition_style = gr.Dropdown(
|
460 |
-
choices=get_dropdown_choices(composition_styles_info),
|
461 |
-
label="Composition Style",
|
462 |
-
visible=False,
|
463 |
-
info="Select a composition style to guide the arrangement of elements in the image."
|
464 |
-
)
|
465 |
-
|
466 |
-
lighting_aspect = gr.Dropdown(
|
467 |
-
choices=get_dropdown_choices(lighting_aspects_info),
|
468 |
-
label="Lighting Aspect",
|
469 |
-
visible=False,
|
470 |
-
info="Choose a lighting style to define the mood and atmosphere of the image."
|
471 |
-
)
|
472 |
-
|
473 |
-
special_technique = gr.Dropdown(
|
474 |
-
choices=get_dropdown_choices(special_techniques_info),
|
475 |
-
label="Special Technique",
|
476 |
-
visible=False,
|
477 |
-
info="Select a special photographic technique to add unique effects to the image."
|
478 |
-
)
|
479 |
-
|
480 |
-
color_effect = gr.Dropdown(
|
481 |
-
choices=get_dropdown_choices(color_effects_info),
|
482 |
-
label="Color Effect",
|
483 |
-
visible=False,
|
484 |
-
info="Choose a color effect to alter the overall color palette of the image."
|
485 |
-
)
|
486 |
-
|
487 |
gr.Markdown("**Note:** Caption tone doesn't affect `rng-tags`, `training_prompt`, and `style_prompt`.")
|
488 |
|
489 |
run_button = gr.Button("Make My Caption!")
|
@@ -492,28 +450,43 @@ with gr.Blocks(theme="Hev832/Applio", css=css) as demo:
|
|
492 |
output_caption = gr.Textbox(label="Generated Caption")
|
493 |
|
494 |
# Container for advanced options
|
495 |
-
|
496 |
-
with advanced_options:
|
497 |
gr.Markdown("### Advanced Options for Style Prompt")
|
498 |
-
lens_type.
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
504 |
|
505 |
def update_style_options(caption_type):
|
506 |
-
return
|
507 |
-
|
508 |
-
|
509 |
-
composition_style: gr.update(visible=caption_type == "style_prompt"),
|
510 |
-
lighting_aspect: gr.update(visible=caption_type == "style_prompt"),
|
511 |
-
special_technique: gr.update(visible=caption_type == "style_prompt"),
|
512 |
-
color_effect: gr.update(visible=caption_type == "style_prompt"),
|
513 |
-
advanced_options: gr.update(visible=caption_type == "style_prompt"),
|
514 |
-
}
|
515 |
-
|
516 |
-
caption_type.change(update_style_options, inputs=[caption_type], outputs=[lens_type, film_stock, composition_style, lighting_aspect, special_technique, color_effect, advanced_options])
|
517 |
|
518 |
run_button.click(fn=stream_chat, inputs=[input_image, caption_type, caption_tone, caption_length, lens_type, film_stock, composition_style, lighting_aspect, special_technique, color_effect], outputs=[output_caption])
|
519 |
|
|
|
12 |
|
13 |
|
14 |
CLIP_PATH = "google/siglip-so400m-patch14-384"
|
15 |
+
MODEL_PATH = "meta-llama/Meta-Llama-3.1-8B"
|
16 |
CHECKPOINT_PATH = Path("9em124t2-499968")
|
17 |
TITLE = "<h1><center>JoyCaption Alpha One (2024-09-20a)</center></h1>"
|
18 |
CAPTION_TYPE_MAP = {
|
|
|
442 |
value="any",
|
443 |
)
|
444 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
445 |
gr.Markdown("**Note:** Caption tone doesn't affect `rng-tags`, `training_prompt`, and `style_prompt`.")
|
446 |
|
447 |
run_button = gr.Button("Make My Caption!")
|
|
|
450 |
output_caption = gr.Textbox(label="Generated Caption")
|
451 |
|
452 |
# Container for advanced options
|
453 |
+
with gr.Column(visible=False) as advanced_options:
|
|
|
454 |
gr.Markdown("### Advanced Options for Style Prompt")
|
455 |
+
lens_type = gr.Dropdown(
|
456 |
+
choices=get_dropdown_choices(lens_types_info),
|
457 |
+
label="Lens Type",
|
458 |
+
info="Select a lens type to define the perspective and field of view of the image."
|
459 |
+
)
|
460 |
+
film_stock = gr.Dropdown(
|
461 |
+
choices=get_dropdown_choices(film_stocks_info),
|
462 |
+
label="Film Stock",
|
463 |
+
info="Choose a film stock to determine the color, grain, and overall look of the image."
|
464 |
+
)
|
465 |
+
composition_style = gr.Dropdown(
|
466 |
+
choices=get_dropdown_choices(composition_styles_info),
|
467 |
+
label="Composition Style",
|
468 |
+
info="Select a composition style to guide the arrangement of elements in the image."
|
469 |
+
)
|
470 |
+
lighting_aspect = gr.Dropdown(
|
471 |
+
choices=get_dropdown_choices(lighting_aspects_info),
|
472 |
+
label="Lighting Aspect",
|
473 |
+
info="Choose a lighting style to define the mood and atmosphere of the image."
|
474 |
+
)
|
475 |
+
special_technique = gr.Dropdown(
|
476 |
+
choices=get_dropdown_choices(special_techniques_info),
|
477 |
+
label="Special Technique",
|
478 |
+
info="Select a special photographic technique to add unique effects to the image."
|
479 |
+
)
|
480 |
+
color_effect = gr.Dropdown(
|
481 |
+
choices=get_dropdown_choices(color_effects_info),
|
482 |
+
label="Color Effect",
|
483 |
+
info="Choose a color effect to alter the overall color palette of the image."
|
484 |
+
)
|
485 |
|
486 |
def update_style_options(caption_type):
|
487 |
+
return gr.update(visible=caption_type == "style_prompt")
|
488 |
+
|
489 |
+
caption_type.change(update_style_options, inputs=[caption_type], outputs=[advanced_options])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
490 |
|
491 |
run_button.click(fn=stream_chat, inputs=[input_image, caption_type, caption_tone, caption_length, lens_type, film_stock, composition_style, lighting_aspect, special_technique, color_effect], outputs=[output_caption])
|
492 |
|