Spaces:
Running
on
Zero
Running
on
Zero
update output
Browse files
app.py
CHANGED
@@ -59,7 +59,7 @@ def run_example(task_prompt, image, text_input=None, model_id='dwb2023/florence2
|
|
59 |
task=task_prompt,
|
60 |
image_size=(image.width, image.height)
|
61 |
)
|
62 |
-
return parsed_answer
|
63 |
|
64 |
def plot_bbox(image, data):
|
65 |
fig, ax = plt.subplots()
|
@@ -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,
|
124 |
-
return
|
125 |
else:
|
126 |
return "", None # Return empty string and None for unknown task prompts
|
127 |
|
@@ -148,6 +148,7 @@ with gr.Blocks(theme="sudeepshouche/minimalist") as demo:
|
|
148 |
submit_btn = gr.Button(value="Submit")
|
149 |
with gr.Column():
|
150 |
output_text = gr.Textbox(label="Output Text")
|
|
|
151 |
output_img = gr.Image(label="Output Image")
|
152 |
|
153 |
gr.Examples(
|
@@ -169,7 +170,7 @@ with gr.Blocks(theme="sudeepshouche/minimalist") as demo:
|
|
169 |
label='Try examples'
|
170 |
)
|
171 |
|
172 |
-
submit_btn.click(process_image, [input_img, task_prompt, model_selector], [output_text, output_img])
|
173 |
|
174 |
gr.Markdown("## 🚀Other Cool Stuff:")
|
175 |
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!")
|
|
|
59 |
task=task_prompt,
|
60 |
image_size=(image.width, image.height)
|
61 |
)
|
62 |
+
return parsed_answer, generated_text
|
63 |
|
64 |
def plot_bbox(image, data):
|
65 |
fig, ax = plt.subplots()
|
|
|
119 |
image = Image.fromarray(image) # Convert NumPy array to PIL Image
|
120 |
if task_prompt == 'Object Detection':
|
121 |
task_prompt = '<OD>'
|
122 |
+
parsed_answer, generated_text = run_example(task_prompt, image, model_id=model_id)
|
123 |
+
fig = plot_bbox(image, parsed_answer['<OD>'])
|
124 |
+
return parsed_answer, generated_text, 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 |
output_text = gr.Textbox(label="Output Text")
|
151 |
+
parsed_text = gr.Textbox(label="Parsed Text")
|
152 |
output_img = gr.Image(label="Output Image")
|
153 |
|
154 |
gr.Examples(
|
|
|
170 |
label='Try examples'
|
171 |
)
|
172 |
|
173 |
+
submit_btn.click(process_image, [input_img, task_prompt, model_selector], [output_text, parsed_text, output_img])
|
174 |
|
175 |
gr.Markdown("## 🚀Other Cool Stuff:")
|
176 |
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!")
|