axiilay commited on
Commit
3bc3aa3
·
1 Parent(s): f608959

the file in temp dir will be deleted, use PIL

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -93,13 +93,16 @@ def process_image(image, model_size, task_type, is_eval_mode):
93
  else:
94
  markdown_content = "Markdown result was not generated. This is expected for 'Free OCR' task."
95
 
 
 
96
  # Check if the annotated image exists
97
- final_image_path = (
98
- image_result_path if os.path.exists(image_result_path) else None
99
- )
100
 
101
  # Return all three results. Gradio will handle the temporary file path for the image.
102
- return final_image_path, markdown_content, plain_text_result
 
103
 
104
 
105
  # Create Gradio interface
 
93
  else:
94
  markdown_content = "Markdown result was not generated. This is expected for 'Free OCR' task."
95
 
96
+
97
+ result_image = None
98
  # Check if the annotated image exists
99
+ if os.path.exists(image_result_path):
100
+ result_image = Image.open(image_result_path)
101
+ result_image.load()
102
 
103
  # Return all three results. Gradio will handle the temporary file path for the image.
104
+ text_result = plain_text_result if plain_text_result else markdown_content
105
+ return result_image, markdown_content, plain_text_result
106
 
107
 
108
  # Create Gradio interface