Spaces:
Configuration error
Configuration error
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,11 +7,11 @@ import numpy as np
|
|
| 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)
|
| 9 |
model = model.eval().cuda()
|
|
|
|
| 10 |
|
| 11 |
@spaces.GPU
|
| 12 |
def run_GOT(image_array, got_mode, fine_grained_mode="", ocr_color="", ocr_box=""):
|
| 13 |
image = image_array
|
| 14 |
-
html_file = './demo.html'
|
| 15 |
if got_mode == "plain texts OCR":
|
| 16 |
res = model.chat(tokenizer, image, ocr_type='ocr')
|
| 17 |
elif got_mode == "format texts OCR":
|
|
@@ -128,6 +128,8 @@ with gr.Blocks() as demo:
|
|
| 128 |
\\]
|
| 129 |
"""
|
| 130 |
)
|
|
|
|
|
|
|
| 131 |
with gr.Column():
|
| 132 |
html_result = gr.HTML(
|
| 133 |
value="""
|
|
|
|
| 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)
|
| 9 |
model = model.eval().cuda()
|
| 10 |
+
html_file = './demo.html'
|
| 11 |
|
| 12 |
@spaces.GPU
|
| 13 |
def run_GOT(image_array, got_mode, fine_grained_mode="", ocr_color="", ocr_box=""):
|
| 14 |
image = image_array
|
|
|
|
| 15 |
if got_mode == "plain texts OCR":
|
| 16 |
res = model.chat(tokenizer, image, ocr_type='ocr')
|
| 17 |
elif got_mode == "format texts OCR":
|
|
|
|
| 128 |
\\]
|
| 129 |
"""
|
| 130 |
)
|
| 131 |
+
with gr.Column():
|
| 132 |
+
html_show = gr.HTML(f'<a href="{html_file}" target="_blank">Open Demo HTML</a>')
|
| 133 |
with gr.Column():
|
| 134 |
html_result = gr.HTML(
|
| 135 |
value="""
|