Upload app.py
Browse files
app.py
CHANGED
@@ -596,79 +596,81 @@ with gr.Blocks(theme='Nymbo/Nymbo_Theme', fill_width=True, css=css) as app:
|
|
596 |
pg_generate_text_button = gr.Button("Generate Prompt with LLM (Llama 3.1 70B)")
|
597 |
pg_text_output = gr.Textbox(label="Generated Text", lines=10)
|
598 |
|
599 |
-
|
600 |
-
if image is not None:
|
601 |
-
return florence_caption(image)
|
602 |
-
return ""
|
603 |
-
|
604 |
-
pg_create_caption_button.click(
|
605 |
-
create_caption,
|
606 |
-
inputs=[pg_input_image],
|
607 |
-
outputs=[pg_caption_output]
|
608 |
-
)
|
609 |
-
|
610 |
-
def generate_prompt_with_dynamic_seed(*args):
|
611 |
-
# Generate a new random seed
|
612 |
-
dynamic_seed = random.randint(0, 1000000)
|
613 |
-
|
614 |
-
# Call the generate_prompt function with the dynamic seed
|
615 |
-
result = prompt_generator.generate_prompt(dynamic_seed, *args)
|
616 |
-
|
617 |
-
# Return the result along with the used seed
|
618 |
-
return [dynamic_seed] + list(result)
|
619 |
-
|
620 |
-
pg_generate_button.click(
|
621 |
-
generate_prompt_with_dynamic_seed,
|
622 |
-
inputs=[pg_custom, pg_subject, pg_gender, pg_artform, pg_photo_type, pg_body_types, pg_default_tags, pg_roles, pg_hairstyles,
|
623 |
-
pg_additional_details, pg_photography_styles, pg_device, pg_photographer, pg_artist, pg_digital_artform,
|
624 |
-
pg_place, pg_lighting, pg_clothing, pg_composition, pg_pose, pg_background, pg_input_image],
|
625 |
-
outputs=[gr.Number(label="Used Seed", visible=True), pg_output, gr.Number(visible=False), pg_t5xxl_output, pg_clip_l_output, pg_clip_g_output]
|
626 |
-
)
|
627 |
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
)
|
633 |
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
pg_photography_styles, pg_device, pg_photographer, pg_artist, pg_digital_artform
|
647 |
-
]:
|
648 |
-
updates[dropdown] = gr.update(value="disabled")
|
649 |
-
elif choice == "Random":
|
650 |
-
for dropdown in [
|
651 |
-
pg_artform, pg_photo_type, pg_body_types, pg_default_tags, pg_roles, pg_hairstyles, pg_clothing,
|
652 |
-
pg_place, pg_lighting, pg_composition, pg_pose, pg_background, pg_additional_details,
|
653 |
-
pg_photography_styles, pg_device, pg_photographer, pg_artist, pg_digital_artform
|
654 |
-
]:
|
655 |
-
updates[dropdown] = gr.update(value="random")
|
656 |
-
else: # No Figure Random
|
657 |
-
for dropdown in [pg_photo_type, pg_body_types, pg_default_tags, pg_roles, pg_hairstyles, pg_clothing, pg_pose, pg_additional_details]:
|
658 |
-
updates[dropdown] = gr.update(value="disabled")
|
659 |
-
for dropdown in [pg_artform, pg_place, pg_lighting, pg_composition, pg_background, pg_photography_styles, pg_device, pg_photographer, pg_artist, pg_digital_artform]:
|
660 |
-
updates[dropdown] = gr.update(value="random")
|
661 |
-
return updates
|
662 |
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
667 |
pg_artform, pg_photo_type, pg_body_types, pg_default_tags, pg_roles, pg_hairstyles, pg_clothing,
|
668 |
pg_place, pg_lighting, pg_composition, pg_pose, pg_background, pg_additional_details,
|
669 |
pg_photography_styles, pg_device, pg_photographer, pg_artist, pg_digital_artform
|
670 |
-
]
|
671 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
672 |
|
673 |
app.queue()
|
674 |
app.launch()
|
|
|
596 |
pg_generate_text_button = gr.Button("Generate Prompt with LLM (Llama 3.1 70B)")
|
597 |
pg_text_output = gr.Textbox(label="Generated Text", lines=10)
|
598 |
|
599 |
+
description_ui()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
600 |
|
601 |
+
def create_caption(image):
|
602 |
+
if image is not None:
|
603 |
+
return florence_caption(image)
|
604 |
+
return ""
|
|
|
605 |
|
606 |
+
pg_create_caption_button.click(
|
607 |
+
create_caption,
|
608 |
+
inputs=[pg_input_image],
|
609 |
+
outputs=[pg_caption_output]
|
610 |
+
)
|
611 |
|
612 |
+
def generate_prompt_with_dynamic_seed(*args):
|
613 |
+
# Generate a new random seed
|
614 |
+
dynamic_seed = random.randint(0, 1000000)
|
615 |
+
|
616 |
+
# Call the generate_prompt function with the dynamic seed
|
617 |
+
result = prompt_generator.generate_prompt(dynamic_seed, *args)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
618 |
|
619 |
+
# Return the result along with the used seed
|
620 |
+
return [dynamic_seed] + list(result)
|
621 |
+
|
622 |
+
pg_generate_button.click(
|
623 |
+
generate_prompt_with_dynamic_seed,
|
624 |
+
inputs=[pg_custom, pg_subject, pg_gender, pg_artform, pg_photo_type, pg_body_types, pg_default_tags, pg_roles, pg_hairstyles,
|
625 |
+
pg_additional_details, pg_photography_styles, pg_device, pg_photographer, pg_artist, pg_digital_artform,
|
626 |
+
pg_place, pg_lighting, pg_clothing, pg_composition, pg_pose, pg_background, pg_input_image],
|
627 |
+
outputs=[gr.Number(label="Used Seed", visible=True), pg_output, gr.Number(visible=False), pg_t5xxl_output, pg_clip_l_output, pg_clip_g_output]
|
628 |
+
)
|
629 |
+
|
630 |
+
pg_add_caption_button.click(
|
631 |
+
prompt_generator.add_caption_to_prompt,
|
632 |
+
inputs=[pg_output, pg_caption_output],
|
633 |
+
outputs=[pg_output]
|
634 |
+
)
|
635 |
+
|
636 |
+
pg_generate_text_button.click(
|
637 |
+
huggingface_node.generate,
|
638 |
+
inputs=[pg_output, pg_happy_talk, pg_compress, pg_compression_level, pg_poster, pg_custom_base_prompt],
|
639 |
+
outputs=pg_text_output
|
640 |
+
)
|
641 |
+
|
642 |
+
def update_all_options(choice):
|
643 |
+
updates = {}
|
644 |
+
if choice == "Disabled":
|
645 |
+
for dropdown in [
|
646 |
pg_artform, pg_photo_type, pg_body_types, pg_default_tags, pg_roles, pg_hairstyles, pg_clothing,
|
647 |
pg_place, pg_lighting, pg_composition, pg_pose, pg_background, pg_additional_details,
|
648 |
pg_photography_styles, pg_device, pg_photographer, pg_artist, pg_digital_artform
|
649 |
+
]:
|
650 |
+
updates[dropdown] = gr.update(value="disabled")
|
651 |
+
elif choice == "Random":
|
652 |
+
for dropdown in [
|
653 |
+
pg_artform, pg_photo_type, pg_body_types, pg_default_tags, pg_roles, pg_hairstyles, pg_clothing,
|
654 |
+
pg_place, pg_lighting, pg_composition, pg_pose, pg_background, pg_additional_details,
|
655 |
+
pg_photography_styles, pg_device, pg_photographer, pg_artist, pg_digital_artform
|
656 |
+
]:
|
657 |
+
updates[dropdown] = gr.update(value="random")
|
658 |
+
else: # No Figure Random
|
659 |
+
for dropdown in [pg_photo_type, pg_body_types, pg_default_tags, pg_roles, pg_hairstyles, pg_clothing, pg_pose, pg_additional_details]:
|
660 |
+
updates[dropdown] = gr.update(value="disabled")
|
661 |
+
for dropdown in [pg_artform, pg_place, pg_lighting, pg_composition, pg_background, pg_photography_styles, pg_device, pg_photographer, pg_artist, pg_digital_artform]:
|
662 |
+
updates[dropdown] = gr.update(value="random")
|
663 |
+
return updates
|
664 |
+
|
665 |
+
pg_global_option.change(
|
666 |
+
update_all_options,
|
667 |
+
inputs=[pg_global_option],
|
668 |
+
outputs=[
|
669 |
+
pg_artform, pg_photo_type, pg_body_types, pg_default_tags, pg_roles, pg_hairstyles, pg_clothing,
|
670 |
+
pg_place, pg_lighting, pg_composition, pg_pose, pg_background, pg_additional_details,
|
671 |
+
pg_photography_styles, pg_device, pg_photographer, pg_artist, pg_digital_artform
|
672 |
+
]
|
673 |
+
)
|
674 |
|
675 |
app.queue()
|
676 |
app.launch()
|