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