Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -11,23 +11,24 @@ model = model.eval().cuda()
|
|
11 |
@spaces.GPU
|
12 |
def run_GOT(image_array, got_mode, fine_grained_mode="", ocr_color="", ocr_box=""):
|
13 |
image = image_array
|
|
|
14 |
if got_mode == "plain texts OCR":
|
15 |
res = model.chat(tokenizer, image, ocr_type='ocr')
|
16 |
elif got_mode == "format texts OCR":
|
17 |
-
res = model.chat(tokenizer, image, ocr_type='format', render=True, save_render_file=
|
18 |
elif got_mode == "plain multi-crop OCR":
|
19 |
res = model.chat_crop(tokenizer, image, ocr_type='ocr')
|
20 |
elif got_mode == "format multi-crop OCR":
|
21 |
-
res = model.chat_crop(tokenizer, image, ocr_type='format', render=True, save_render_file=
|
22 |
-
|
23 |
elif got_mode == "plain fine-grained OCR":
|
24 |
res = model.chat(tokenizer, image, ocr_type='ocr', ocr_box=ocr_box, ocr_color=ocr_color)
|
25 |
elif got_mode == "format fine-grained OCR":
|
26 |
-
res = model.chat(tokenizer, image, ocr_type='format', ocr_box=ocr_box, ocr_color=ocr_color, render=True, save_render_file=
|
27 |
|
28 |
if "format" in got_mode:
|
29 |
-
with open(
|
30 |
demo_html = f.read()
|
|
|
31 |
return res, demo_html
|
32 |
return res, None
|
33 |
|
|
|
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":
|
18 |
+
res = model.chat(tokenizer, image, ocr_type='format', render=True, save_render_file=html_file)
|
19 |
elif got_mode == "plain multi-crop OCR":
|
20 |
res = model.chat_crop(tokenizer, image, ocr_type='ocr')
|
21 |
elif got_mode == "format multi-crop OCR":
|
22 |
+
res = model.chat_crop(tokenizer, image, ocr_type='format', render=True, save_render_file=html_file)
|
|
|
23 |
elif got_mode == "plain fine-grained OCR":
|
24 |
res = model.chat(tokenizer, image, ocr_type='ocr', ocr_box=ocr_box, ocr_color=ocr_color)
|
25 |
elif got_mode == "format fine-grained OCR":
|
26 |
+
res = model.chat(tokenizer, image, ocr_type='format', ocr_box=ocr_box, ocr_color=ocr_color, render=True, save_render_file=html_file)
|
27 |
|
28 |
if "format" in got_mode:
|
29 |
+
with open(html_file, 'r') as f:
|
30 |
demo_html = f.read()
|
31 |
+
print("demo_html: \n", demo_html)
|
32 |
return res, demo_html
|
33 |
return res, None
|
34 |
|