Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,7 +8,7 @@ from apscheduler.schedulers.background import BackgroundScheduler
|
|
| 8 |
from modules.classifyTags import classify_tags,process_tags
|
| 9 |
from modules.reorganizer_model import reorganizer_list,reorganizer_class
|
| 10 |
from modules.tag_enhancer import prompt_enhancer
|
| 11 |
-
|
| 12 |
|
| 13 |
os.environ['PYTORCH_ENABLE_MPS_FALLBACK']='1'
|
| 14 |
|
|
@@ -551,30 +551,30 @@ with gr.Blocks(title=TITLE, css=css, theme=gr.themes.Soft(), fill_width=True) as
|
|
| 551 |
character_mcut_enabled,
|
| 552 |
],
|
| 553 |
)
|
| 554 |
-
|
| 555 |
-
|
| 556 |
-
|
| 557 |
-
|
| 558 |
-
|
| 559 |
-
|
| 560 |
-
|
| 561 |
-
|
| 562 |
-
|
| 563 |
-
|
| 564 |
-
|
| 565 |
-
|
| 566 |
-
|
| 567 |
-
|
| 568 |
-
|
| 569 |
-
|
| 570 |
-
|
| 571 |
-
|
| 572 |
-
|
| 573 |
-
|
| 574 |
-
|
| 575 |
-
|
| 576 |
-
|
| 577 |
-
|
| 578 |
with gr.Tab("Booru Image Fetcher"):
|
| 579 |
with gr.Row():
|
| 580 |
with gr.Column():
|
|
|
|
| 8 |
from modules.classifyTags import classify_tags,process_tags
|
| 9 |
from modules.reorganizer_model import reorganizer_list,reorganizer_class
|
| 10 |
from modules.tag_enhancer import prompt_enhancer
|
| 11 |
+
from modules.florence2 import process_image,single_task_list,update_task_dropdown
|
| 12 |
|
| 13 |
os.environ['PYTORCH_ENABLE_MPS_FALLBACK']='1'
|
| 14 |
|
|
|
|
| 551 |
character_mcut_enabled,
|
| 552 |
],
|
| 553 |
)
|
| 554 |
+
with gr.Tab(label="Florence 2 Image Captioning"):
|
| 555 |
+
with gr.Row():
|
| 556 |
+
with gr.Column(variant="panel"):
|
| 557 |
+
input_img = gr.Image(label="Input Picture")
|
| 558 |
+
task_type = gr.Radio(choices=['Single task', 'Cascaded task'], label='Task type selector', value='Single task')
|
| 559 |
+
task_prompt = gr.Dropdown(choices=single_task_list, label="Task Prompt", value="Caption")
|
| 560 |
+
task_type.change(fn=update_task_dropdown, inputs=task_type, outputs=task_prompt)
|
| 561 |
+
text_input = gr.Textbox(label="Text Input (optional)")
|
| 562 |
+
submit_btn = gr.Button(value="Submit")
|
| 563 |
+
with gr.Column(variant="panel"):
|
| 564 |
+
output_text = gr.Textbox(label="Output Text", show_label=True, show_copy_button=True, lines=8)
|
| 565 |
+
output_img = gr.Image(label="Output Image")
|
| 566 |
+
gr.Examples(
|
| 567 |
+
examples=[
|
| 568 |
+
["images/image1.png", 'Object Detection'],
|
| 569 |
+
["images/image2.png", 'OCR with Region']
|
| 570 |
+
],
|
| 571 |
+
inputs=[input_img, task_prompt],
|
| 572 |
+
outputs=[output_text, output_img],
|
| 573 |
+
fn=process_image,
|
| 574 |
+
cache_examples=False,
|
| 575 |
+
label='Try examples'
|
| 576 |
+
)
|
| 577 |
+
submit_btn.click(process_image, [input_img, task_prompt, text_input], [output_text, output_img])
|
| 578 |
with gr.Tab("Booru Image Fetcher"):
|
| 579 |
with gr.Row():
|
| 580 |
with gr.Column():
|