acharyaaditya26 commited on
Commit
486fb7a
·
verified ·
1 Parent(s): 664cbfd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -1
app.py CHANGED
@@ -76,9 +76,21 @@ def run_GOT(pdf_file):
76
 
77
  res = model.chat_crop(tokenizer, image_path, ocr_type='format', render=True, save_render_file=result_path)
78
 
 
 
 
 
 
 
 
 
 
 
79
  results.append({
80
  "page_number": i + 1,
81
- "text": res # Directly use the output from model.chat_crop
 
 
82
  })
83
 
84
  if os.path.exists(image_path):
 
76
 
77
  res = model.chat_crop(tokenizer, image_path, ocr_type='format', render=True, save_render_file=result_path)
78
 
79
+ # Read the rendered HTML content
80
+ with open(result_path, 'r') as f:
81
+ html_content = f.read()
82
+
83
+ # Encode the HTML content to base64
84
+ encoded_html = base64.b64encode(html_content.encode('utf-8')).decode('utf-8')
85
+ iframe_src = f"data:text/html;base64,{encoded_html}"
86
+ iframe = f'<iframe src="{iframe_src}" width="100%" height="600px"></iframe>'
87
+ download_link = f'<a href="data:text/html;base64,{encoded_html}" download="result_{unique_id}_page_{i+1}.html">Download Full Result</a>'
88
+
89
  results.append({
90
  "page_number": i + 1,
91
+ "text": res, # Directly use the output from model.chat_crop
92
+ "html": iframe,
93
+ "download_link": download_link
94
  })
95
 
96
  if os.path.exists(image_path):