Spaces:
Running
on
Zero
Running
on
Zero
Revert to commit 6c3c1e89b3ab981b79a13afc00dc7e6ddc3f7fe0
Browse files
app.py
CHANGED
@@ -45,7 +45,7 @@ model = model.eval().cuda()
|
|
45 |
model.config.pad_token_id = tokenizer.eos_token_id
|
46 |
|
47 |
@spaces.GPU
|
48 |
-
def process_image(image, task, ocr_type=None, ocr_box=None, ocr_color=None, render=
|
49 |
if task == "Plain Text OCR":
|
50 |
res = model.chat(tokenizer, image, ocr_type='ocr', attention_mask=attention_mask)
|
51 |
elif task == "Format Text OCR":
|
@@ -84,8 +84,8 @@ def update_inputs(task):
|
|
84 |
elif task == "Render Formatted OCR":
|
85 |
return [gr.update(visible=False)] * 3 + [gr.update(visible=True)]
|
86 |
|
87 |
-
def ocr_demo(image, task, ocr_type, ocr_box, ocr_color
|
88 |
-
res, html_content = process_image(image, task, ocr_type, ocr_box, ocr_color
|
89 |
if html_content:
|
90 |
return res, html_content
|
91 |
return res, None
|
|
|
45 |
model.config.pad_token_id = tokenizer.eos_token_id
|
46 |
|
47 |
@spaces.GPU
|
48 |
+
def process_image(image, task, ocr_type=None, ocr_box=None, ocr_color=None, render=False):
|
49 |
if task == "Plain Text OCR":
|
50 |
res = model.chat(tokenizer, image, ocr_type='ocr', attention_mask=attention_mask)
|
51 |
elif task == "Format Text OCR":
|
|
|
84 |
elif task == "Render Formatted OCR":
|
85 |
return [gr.update(visible=False)] * 3 + [gr.update(visible=True)]
|
86 |
|
87 |
+
def ocr_demo(image, task, ocr_type, ocr_box, ocr_color):
|
88 |
+
res, html_content = process_image(image, task, ocr_type, ocr_box, ocr_color)
|
89 |
if html_content:
|
90 |
return res, html_content
|
91 |
return res, None
|