Kaushik Bar
commited on
Commit
·
5c712db
1
Parent(s):
0034c33
zsod
Browse files
app.py
CHANGED
@@ -11,21 +11,22 @@ def inference(img, lang):
|
|
11 |
boxes = [line[0] for line in result]
|
12 |
txts = [line[1][0] for line in result]
|
13 |
scores = [line[1][1] for line in result]
|
14 |
-
im_show = draw_ocr(image, boxes, txts, scores
|
|
|
15 |
im_show = Image.fromarray(im_show)
|
16 |
im_show.save('result.jpg')
|
17 |
return 'result.jpg'
|
18 |
|
19 |
title = 'OCR'
|
20 |
description = 'OCR demo (supports Chinese, English, French, German, Korean and Japanese). Simply upload your image and choose a language from the dropdown menu.'
|
21 |
-
|
22 |
gr.Interface(
|
23 |
inference,
|
24 |
[gr.inputs.Image(type='file', label='Input'),gr.inputs.Dropdown(choices=['ch', 'en', 'fr', 'german', 'korean', 'japan'], type="value", default='en', label='language')],
|
25 |
gr.outputs.Image(type='file', label='Output'),
|
26 |
title=title,
|
27 |
description=description,
|
28 |
-
|
29 |
enable_queue=True
|
30 |
).launch(debug=True)
|
31 |
|
|
|
11 |
boxes = [line[0] for line in result]
|
12 |
txts = [line[1][0] for line in result]
|
13 |
scores = [line[1][1] for line in result]
|
14 |
+
im_show = draw_ocr(image, boxes, txts, scores,
|
15 |
+
font_path='https://huggingface.co/spaces/PaddlePaddle/PaddleOCR/blob/main/simfang.ttf')
|
16 |
im_show = Image.fromarray(im_show)
|
17 |
im_show.save('result.jpg')
|
18 |
return 'result.jpg'
|
19 |
|
20 |
title = 'OCR'
|
21 |
description = 'OCR demo (supports Chinese, English, French, German, Korean and Japanese). Simply upload your image and choose a language from the dropdown menu.'
|
22 |
+
css = ".output_image, .input_image {height: 40rem !important; width: 100% !important;}"
|
23 |
gr.Interface(
|
24 |
inference,
|
25 |
[gr.inputs.Image(type='file', label='Input'),gr.inputs.Dropdown(choices=['ch', 'en', 'fr', 'german', 'korean', 'japan'], type="value", default='en', label='language')],
|
26 |
gr.outputs.Image(type='file', label='Output'),
|
27 |
title=title,
|
28 |
description=description,
|
29 |
+
css=css,
|
30 |
enable_queue=True
|
31 |
).launch(debug=True)
|
32 |
|