Spaces:
Running
on
Zero
Running
on
Zero
the file in temp dir will be deleted, use PIL
Browse files
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 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
|
| 101 |
# Return all three results. Gradio will handle the temporary file path for the image.
|
| 102 |
-
|
|
|
|
| 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
|