gokaygokay commited on
Commit
9d0b540
1 Parent(s): d69fd19

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -121,34 +121,34 @@ def process_image(image, task_prompt, text_input=None):
121
  elif task_prompt == '<OD>':
122
  results = run_example(task_prompt, image)
123
  fig = plot_bbox(image, results['<OD>'])
124
- return "", fig_to_pil(fig)
125
  elif task_prompt == '<DENSE_REGION_CAPTION>':
126
  results = run_example(task_prompt, image)
127
  fig = plot_bbox(image, results['<DENSE_REGION_CAPTION>'])
128
- return "", fig_to_pil(fig)
129
  elif task_prompt == '<REGION_PROPOSAL>':
130
  results = run_example(task_prompt, image)
131
  fig = plot_bbox(image, results['<REGION_PROPOSAL>'])
132
- return "", fig_to_pil(fig)
133
  elif task_prompt == '<CAPTION_TO_PHRASE_GROUNDING>':
134
  results = run_example(task_prompt, image, text_input)
135
  fig = plot_bbox(image, results['<CAPTION_TO_PHRASE_GROUNDING>'])
136
- return "", fig_to_pil(fig)
137
  elif task_prompt == '<REFERRING_EXPRESSION_SEGMENTATION>':
138
  results = run_example(task_prompt, image, text_input)
139
  output_image = copy.deepcopy(image)
140
  output_image = draw_polygons(output_image, results['<REFERRING_EXPRESSION_SEGMENTATION>'], fill_mask=True)
141
- return "", output_image
142
  elif task_prompt == '<REGION_TO_SEGMENTATION>':
143
  results = run_example(task_prompt, image, text_input)
144
  output_image = copy.deepcopy(image)
145
  output_image = draw_polygons(output_image, results['<REGION_TO_SEGMENTATION>'], fill_mask=True)
146
- return "", output_image
147
  elif task_prompt == '<OPEN_VOCABULARY_DETECTION>':
148
  results = run_example(task_prompt, image, text_input)
149
  bbox_results = convert_to_od_format(results['<OPEN_VOCABULARY_DETECTION>'])
150
  fig = plot_bbox(image, bbox_results)
151
- return "", fig_to_pil(fig)
152
  elif task_prompt == '<REGION_TO_CATEGORY>':
153
  results = run_example(task_prompt, image, text_input)
154
  return results, None
@@ -162,7 +162,7 @@ def process_image(image, task_prompt, text_input=None):
162
  results = run_example(task_prompt, image)
163
  output_image = copy.deepcopy(image)
164
  output_image = draw_ocr_bboxes(output_image, results['<OCR_WITH_REGION>'])
165
- return "", output_image
166
  else:
167
  return "", None # Return empty string and None for unknown task prompts
168
 
 
121
  elif task_prompt == '<OD>':
122
  results = run_example(task_prompt, image)
123
  fig = plot_bbox(image, results['<OD>'])
124
+ return results, fig_to_pil(fig)
125
  elif task_prompt == '<DENSE_REGION_CAPTION>':
126
  results = run_example(task_prompt, image)
127
  fig = plot_bbox(image, results['<DENSE_REGION_CAPTION>'])
128
+ return results, fig_to_pil(fig)
129
  elif task_prompt == '<REGION_PROPOSAL>':
130
  results = run_example(task_prompt, image)
131
  fig = plot_bbox(image, results['<REGION_PROPOSAL>'])
132
+ return results, fig_to_pil(fig)
133
  elif task_prompt == '<CAPTION_TO_PHRASE_GROUNDING>':
134
  results = run_example(task_prompt, image, text_input)
135
  fig = plot_bbox(image, results['<CAPTION_TO_PHRASE_GROUNDING>'])
136
+ return results, fig_to_pil(fig)
137
  elif task_prompt == '<REFERRING_EXPRESSION_SEGMENTATION>':
138
  results = run_example(task_prompt, image, text_input)
139
  output_image = copy.deepcopy(image)
140
  output_image = draw_polygons(output_image, results['<REFERRING_EXPRESSION_SEGMENTATION>'], fill_mask=True)
141
+ return results, output_image
142
  elif task_prompt == '<REGION_TO_SEGMENTATION>':
143
  results = run_example(task_prompt, image, text_input)
144
  output_image = copy.deepcopy(image)
145
  output_image = draw_polygons(output_image, results['<REGION_TO_SEGMENTATION>'], fill_mask=True)
146
+ return results, output_image
147
  elif task_prompt == '<OPEN_VOCABULARY_DETECTION>':
148
  results = run_example(task_prompt, image, text_input)
149
  bbox_results = convert_to_od_format(results['<OPEN_VOCABULARY_DETECTION>'])
150
  fig = plot_bbox(image, bbox_results)
151
+ return results, fig_to_pil(fig)
152
  elif task_prompt == '<REGION_TO_CATEGORY>':
153
  results = run_example(task_prompt, image, text_input)
154
  return results, None
 
162
  results = run_example(task_prompt, image)
163
  output_image = copy.deepcopy(image)
164
  output_image = draw_ocr_bboxes(output_image, results['<OCR_WITH_REGION>'])
165
+ return results, output_image
166
  else:
167
  return "", None # Return empty string and None for unknown task prompts
168