Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -211,13 +211,17 @@ def process_image(image, task_prompt, text_input=None, model_id='microsoft/Flore
|
|
211 |
elif task_prompt == 'OCR':
|
212 |
task_prompt = '<OCR>'
|
213 |
results = run_example(task_prompt, image, model_id=model_id)
|
214 |
-
|
|
|
|
|
215 |
elif task_prompt == 'OCR with Region':
|
216 |
task_prompt = '<OCR_WITH_REGION>'
|
217 |
results = run_example(task_prompt, image, model_id=model_id)
|
218 |
output_image = copy.deepcopy(image)
|
219 |
output_image = draw_ocr_bboxes(output_image, results['<OCR_WITH_REGION>'])
|
220 |
-
|
|
|
|
|
221 |
else:
|
222 |
return "", None # Return empty string and None for unknown task prompts
|
223 |
|
|
|
211 |
elif task_prompt == 'OCR':
|
212 |
task_prompt = '<OCR>'
|
213 |
results = run_example(task_prompt, image, model_id=model_id)
|
214 |
+
# Ensure the OCR results are returned as text output
|
215 |
+
ocr_text = results.get('<OCR>', "")
|
216 |
+
return ocr_text, None # Return OCR results as text
|
217 |
elif task_prompt == 'OCR with Region':
|
218 |
task_prompt = '<OCR_WITH_REGION>'
|
219 |
results = run_example(task_prompt, image, model_id=model_id)
|
220 |
output_image = copy.deepcopy(image)
|
221 |
output_image = draw_ocr_bboxes(output_image, results['<OCR_WITH_REGION>'])
|
222 |
+
# Ensure the OCR text content is extracted for download
|
223 |
+
ocr_text = results.get('<OCR_WITH_REGION>', {}).get('text', "")
|
224 |
+
return ocr_text, output_image
|
225 |
else:
|
226 |
return "", None # Return empty string and None for unknown task prompts
|
227 |
|