Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -54,14 +54,24 @@ def run_GOT(pdf_file):
|
|
54 |
image_path = os.path.join(UPLOAD_FOLDER, f"{unique_id}_page_{i+1}.png")
|
55 |
image.save(image_path)
|
56 |
|
57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
results.append({
|
59 |
"page_number": i + 1,
|
60 |
-
"text": res
|
|
|
61 |
})
|
62 |
|
63 |
if os.path.exists(image_path):
|
64 |
os.remove(image_path)
|
|
|
|
|
65 |
except Exception as e:
|
66 |
return f"Error: {str(e)}", None
|
67 |
finally:
|
|
|
54 |
image_path = os.path.join(UPLOAD_FOLDER, f"{unique_id}_page_{i+1}.png")
|
55 |
image.save(image_path)
|
56 |
|
57 |
+
result_path = os.path.join(RESULTS_FOLDER, f"{unique_id}_page_{i+1}.html")
|
58 |
+
|
59 |
+
res = model.chat_crop(tokenizer, image_path, ocr_type='format', render=True, save_render_file=result_path)
|
60 |
+
|
61 |
+
# Read the rendered HTML content
|
62 |
+
with open(result_path, 'r') as f:
|
63 |
+
html_content = f.read()
|
64 |
+
|
65 |
results.append({
|
66 |
"page_number": i + 1,
|
67 |
+
"text": res,
|
68 |
+
"html": html_content
|
69 |
})
|
70 |
|
71 |
if os.path.exists(image_path):
|
72 |
os.remove(image_path)
|
73 |
+
if os.path.exists(result_path):
|
74 |
+
os.remove(result_path)
|
75 |
except Exception as e:
|
76 |
return f"Error: {str(e)}", None
|
77 |
finally:
|