ucaslcl commited on
Commit
ed2ee0e
·
verified ·
1 Parent(s): 87a239d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -3
app.py CHANGED
@@ -3,7 +3,6 @@ import spaces
3
  from transformers import AutoModel, AutoTokenizer
4
  from PIL import Image
5
  import numpy as np
6
- import webbrowser
7
 
8
  tokenizer = AutoTokenizer.from_pretrained('ucaslcl/GOT-OCR2_0', trust_remote_code=True)
9
  model = AutoModel.from_pretrained('ucaslcl/GOT-OCR2_0', trust_remote_code=True, low_cpu_mem_usage=True, device_map='cuda', use_safetensors=True)
@@ -27,7 +26,6 @@ def run_GOT(image_array, got_mode, fine_grained_mode="", ocr_color="", ocr_box="
27
  res = model.chat(tokenizer, image, ocr_type='format', ocr_box=ocr_box, ocr_color=ocr_color, render=True, save_render_file='./demo.html')
28
 
29
  if "format" in got_mode:
30
- webbrowser.open('./demo.html')
31
  with open('./demo.html', 'r') as f:
32
  demo_html = f.read()
33
  return res, demo_html
@@ -106,6 +104,7 @@ with gr.Blocks() as demo:
106
 
107
  with gr.Column():
108
  ocr_result = gr.Textbox(label="GOT output")
 
109
  html_result = gr.HTML(label="rendered html")
110
 
111
  gr.Examples(
@@ -141,4 +140,4 @@ with gr.Blocks() as demo:
141
  outputs=[ocr_result, html_result]
142
  )
143
 
144
- demo.launch(share=True)
 
3
  from transformers import AutoModel, AutoTokenizer
4
  from PIL import Image
5
  import numpy as np
 
6
 
7
  tokenizer = AutoTokenizer.from_pretrained('ucaslcl/GOT-OCR2_0', trust_remote_code=True)
8
  model = AutoModel.from_pretrained('ucaslcl/GOT-OCR2_0', trust_remote_code=True, low_cpu_mem_usage=True, device_map='cuda', use_safetensors=True)
 
26
  res = model.chat(tokenizer, image, ocr_type='format', ocr_box=ocr_box, ocr_color=ocr_color, render=True, save_render_file='./demo.html')
27
 
28
  if "format" in got_mode:
 
29
  with open('./demo.html', 'r') as f:
30
  demo_html = f.read()
31
  return res, demo_html
 
104
 
105
  with gr.Column():
106
  ocr_result = gr.Textbox(label="GOT output")
107
+ with gr.Column():
108
  html_result = gr.HTML(label="rendered html")
109
 
110
  gr.Examples(
 
140
  outputs=[ocr_result, html_result]
141
  )
142
 
143
+ demo.launch()