Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ import spaces
|
|
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,6 +27,7 @@ def run_GOT(image_array, got_mode, fine_grained_mode="", ocr_color="", ocr_box="
|
|
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
|
|
|
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 |
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
|