dwb2023 commited on
Commit
e99c6b4
·
verified ·
1 Parent(s): 49d7405

change labels of text boxes

Browse files
Files changed (1) hide show
  1. app.py +5 -5
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
- 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,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
- parsed_text = gr.Textbox(label="Parsed Text")
152
  with gr.Accordion("Output Text", open=False):
153
- output_text = gr.Textbox(label="Output Text")
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], [output_text, parsed_text, 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!")
 
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!")