Spaces:
Runtime error
Runtime error
Commit
·
ab591a3
1
Parent(s):
d23d897
debug
Browse files
app.py
CHANGED
|
@@ -163,10 +163,10 @@ def apply_half(t):
|
|
| 163 |
|
| 164 |
|
| 165 |
def ocr(img):
|
| 166 |
-
|
| 167 |
results = get_images(img, reader)
|
| 168 |
box_list, image_list = zip(*results)
|
| 169 |
-
draw_boxes(
|
| 170 |
|
| 171 |
ocr_result = []
|
| 172 |
for box, image in zip(box_list, image_list):
|
|
@@ -181,7 +181,7 @@ def ocr(img):
|
|
| 181 |
|
| 182 |
result = '\n'.join(ocr_result)
|
| 183 |
|
| 184 |
-
return
|
| 185 |
|
| 186 |
|
| 187 |
title = "OFA-OCR"
|
|
@@ -189,7 +189,7 @@ description = "Gradio Demo for OFA-OCR. Upload your own image or click any one o
|
|
| 189 |
"\"Submit\" and then wait for the generated OCR result. "
|
| 190 |
article = "<p style='text-align: center'><a href='https://github.com/OFA-Sys/OFA' target='_blank'>OFA Github " \
|
| 191 |
"Repo</a></p> "
|
| 192 |
-
examples = [['lihe.png']
|
| 193 |
io = gr.Interface(fn=ocr, inputs=gr.inputs.Image(type='pil'),
|
| 194 |
outputs=[gr.outputs.Image(type='pil'), gr.outputs.Textbox(label="OCR result")],
|
| 195 |
title=title, description=description, article=article, examples=examples,
|
|
|
|
| 163 |
|
| 164 |
|
| 165 |
def ocr(img):
|
| 166 |
+
out_img = img
|
| 167 |
results = get_images(img, reader)
|
| 168 |
box_list, image_list = zip(*results)
|
| 169 |
+
draw_boxes(out_img, box_list)
|
| 170 |
|
| 171 |
ocr_result = []
|
| 172 |
for box, image in zip(box_list, image_list):
|
|
|
|
| 181 |
|
| 182 |
result = '\n'.join(ocr_result)
|
| 183 |
|
| 184 |
+
return out_img, result
|
| 185 |
|
| 186 |
|
| 187 |
title = "OFA-OCR"
|
|
|
|
| 189 |
"\"Submit\" and then wait for the generated OCR result. "
|
| 190 |
article = "<p style='text-align: center'><a href='https://github.com/OFA-Sys/OFA' target='_blank'>OFA Github " \
|
| 191 |
"Repo</a></p> "
|
| 192 |
+
examples = [['lihe.png'], ['chinese.jpg'], ['paibian.jpeg'], ['shupai.png'], ['zuowen.jpg']]
|
| 193 |
io = gr.Interface(fn=ocr, inputs=gr.inputs.Image(type='pil'),
|
| 194 |
outputs=[gr.outputs.Image(type='pil'), gr.outputs.Textbox(label="OCR result")],
|
| 195 |
title=title, description=description, article=article, examples=examples,
|