Spaces:
Sleeping
Sleeping
change labels of text boxes
Browse files
app.py
CHANGED
@@ -119,9 +119,9 @@ def process_image(image, task_prompt, text_input=None, model_id='dwb2023/florenc
|
|
119 |
image = Image.fromarray(image) # Convert NumPy array to PIL Image
|
120 |
if task_prompt == 'Object Detection':
|
121 |
task_prompt = '<OD>'
|
122 |
-
|
123 |
fig = plot_bbox(image, parsed_answer['<OD>'])
|
124 |
-
return
|
125 |
else:
|
126 |
return "", None # Return empty string and None for unknown task prompts
|
127 |
|
@@ -148,9 +148,9 @@ with gr.Blocks(theme="sudeepshouche/minimalist") as demo:
|
|
148 |
submit_btn = gr.Button(value="Submit")
|
149 |
with gr.Column():
|
150 |
with gr.Accordion("Parsed Text", open=False):
|
151 |
-
|
152 |
with gr.Accordion("Output Text", open=False):
|
153 |
-
|
154 |
output_img = gr.Image(label="Output Image")
|
155 |
|
156 |
gr.Examples(
|
@@ -172,7 +172,7 @@ with gr.Blocks(theme="sudeepshouche/minimalist") as demo:
|
|
172 |
label='Try examples'
|
173 |
)
|
174 |
|
175 |
-
submit_btn.click(process_image, [input_img, task_prompt, model_selector], [
|
176 |
|
177 |
gr.Markdown("## 🚀Other Cool Stuff:")
|
178 |
gr.Markdown("- [Florence 2 Whitepaper](https://arxiv.org/pdf/2311.06242) - how I found out about the Roboflow 100 and the BCCD dataset. Turns out this nugget was from the original [Florence whitepaper](https://arxiv.org/pdf/2111.11432) but useful all the same!")
|
|
|
119 |
image = Image.fromarray(image) # Convert NumPy array to PIL Image
|
120 |
if task_prompt == 'Object Detection':
|
121 |
task_prompt = '<OD>'
|
122 |
+
parsed_od, generated_od = run_example(task_prompt, image, model_id=model_id)
|
123 |
fig = plot_bbox(image, parsed_answer['<OD>'])
|
124 |
+
return parsed_od, generated_od, fig_to_pil(fig)
|
125 |
else:
|
126 |
return "", None # Return empty string and None for unknown task prompts
|
127 |
|
|
|
148 |
submit_btn = gr.Button(value="Submit")
|
149 |
with gr.Column():
|
150 |
with gr.Accordion("Parsed Text", open=False):
|
151 |
+
generated_od = gr.Textbox(label="Object Detection - Generated Text")
|
152 |
with gr.Accordion("Output Text", open=False):
|
153 |
+
parsed_od = gr.Textbox(label="Object Detection - Parsed Text")
|
154 |
output_img = gr.Image(label="Output Image")
|
155 |
|
156 |
gr.Examples(
|
|
|
172 |
label='Try examples'
|
173 |
)
|
174 |
|
175 |
+
submit_btn.click(process_image, [input_img, task_prompt, model_selector], [parsed_od, generated_od, output_img])
|
176 |
|
177 |
gr.Markdown("## 🚀Other Cool Stuff:")
|
178 |
gr.Markdown("- [Florence 2 Whitepaper](https://arxiv.org/pdf/2311.06242) - how I found out about the Roboflow 100 and the BCCD dataset. Turns out this nugget was from the original [Florence whitepaper](https://arxiv.org/pdf/2111.11432) but useful all the same!")
|