Update app.py
Browse files
app.py
CHANGED
@@ -16,7 +16,7 @@ import pandas as pd
|
|
16 |
from mmocr.utils.ocr import MMOCR
|
17 |
import os
|
18 |
|
19 |
-
def inference(img,
|
20 |
print(datetime.datetime.now(), 'start')
|
21 |
# ocr = MMOCR(det='PS_CTW', recog='SAR', kie='SDMGR')
|
22 |
# ocr = MMOCR(det=det, recog=recog, kie='SDMGR')
|
@@ -44,7 +44,7 @@ files.sort()
|
|
44 |
for f in files:
|
45 |
file = os.path.join(path, f)
|
46 |
if os.path.isfile(file):
|
47 |
-
examples.append([file,
|
48 |
|
49 |
det = gr.inputs.Dropdown(choices=[
|
50 |
'DB_r18',
|
@@ -82,7 +82,7 @@ recog = gr.inputs.Dropdown(choices=[
|
|
82 |
], type="value", default='SAR', label='recog')
|
83 |
|
84 |
gr.Interface(inference,
|
85 |
-
[gr.inputs.Image(type='file', label='Input'),
|
86 |
# [gr.outputs.Image(type='pil', label='Output'), gr.outputs.Dataframe(headers=['text', 'text_score', 'label', 'label_score'])],
|
87 |
[gr.outputs.Image(type='pil', label='Output'), gr.outputs.Textbox(type='str', label='Prediction')],
|
88 |
title='MMOCR',
|
@@ -90,5 +90,5 @@ gr.Interface(inference,
|
|
90 |
article=article,
|
91 |
examples=examples,
|
92 |
css=".output_image, .input_image {height: 40rem !important; width: 100% !important;}",
|
93 |
-
enable_queue=
|
94 |
).launch(debug=True)
|
|
|
16 |
from mmocr.utils.ocr import MMOCR
|
17 |
import os
|
18 |
|
19 |
+
def inference(img, det, recog):
|
20 |
print(datetime.datetime.now(), 'start')
|
21 |
# ocr = MMOCR(det='PS_CTW', recog='SAR', kie='SDMGR')
|
22 |
# ocr = MMOCR(det=det, recog=recog, kie='SDMGR')
|
|
|
44 |
for f in files:
|
45 |
file = os.path.join(path, f)
|
46 |
if os.path.isfile(file):
|
47 |
+
examples.append([file, 'PS_CTW', 'SAR'])
|
48 |
|
49 |
det = gr.inputs.Dropdown(choices=[
|
50 |
'DB_r18',
|
|
|
82 |
], type="value", default='SAR', label='recog')
|
83 |
|
84 |
gr.Interface(inference,
|
85 |
+
[gr.inputs.Image(type='file', label='Input'), det, recog ],
|
86 |
# [gr.outputs.Image(type='pil', label='Output'), gr.outputs.Dataframe(headers=['text', 'text_score', 'label', 'label_score'])],
|
87 |
[gr.outputs.Image(type='pil', label='Output'), gr.outputs.Textbox(type='str', label='Prediction')],
|
88 |
title='MMOCR',
|
|
|
90 |
article=article,
|
91 |
examples=examples,
|
92 |
css=".output_image, .input_image {height: 40rem !important; width: 100% !important;}",
|
93 |
+
enable_queue=True
|
94 |
).launch(debug=True)
|