scooter7 commited on
Commit
fd98535
1 Parent(s): a835580

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
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
- return results, None
 
 
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
- return results, output_image
 
 
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