cxeep commited on
Commit
e195121
1 Parent(s): 96c3387

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -9
app.py CHANGED
@@ -12,15 +12,16 @@ def inference(img, lang):
12
  ocr = PaddleOCR(use_angle_cls=True, lang=lang,use_gpu=False)
13
  img_path = img.name
14
  result = ocr.ocr(img_path, cls=True)[0]
15
- image = Image.open(img_path).convert('RGB')
16
  boxes = [line[0] for line in result]
17
  txts = [line[1][0] for line in result]
18
- scores = [line[1][1] for line in result]
19
- im_show = draw_ocr(image, boxes, txts, scores,
20
- font_path='simfang.ttf')
21
- im_show = Image.fromarray(im_show)
22
- im_show.save('result.jpg')
23
- return 'result.jpg'
 
24
 
25
  title = 'PaddleOCR'
26
  description = 'Gradio demo for PaddleOCR. PaddleOCR demo supports Chinese, English, French, German, Korean and Japanese. To use it, simply upload your image and choose a language from the dropdown menu, or click one of the examples to load them. Read more at the links below.'
@@ -29,8 +30,9 @@ examples = [['example.jpg','en']]
29
  css = ".output_image, .input_image {height: 40rem !important; width: 100% !important;}"
30
  gr.Interface(
31
  inference,
32
- [gr.inputs.Image(type='file', label='Input'),gr.inputs.Dropdown(choices=['ch', 'en', 'fr', 'german', 'korean', 'japan'], type="value", default='en', label='language')],
33
- gr.outputs.Image(type='file', label='Output'),
 
34
  title=title,
35
  description=description,
36
  article=article,
 
12
  ocr = PaddleOCR(use_angle_cls=True, lang=lang,use_gpu=False)
13
  img_path = img.name
14
  result = ocr.ocr(img_path, cls=True)[0]
15
+ # image = Image.open(img_path).convert('RGB')
16
  boxes = [line[0] for line in result]
17
  txts = [line[1][0] for line in result]
18
+ return '\n'.join(txts)
19
+ # scores = [line[1][1] for line in result]
20
+ # im_show = draw_ocr(image, boxes, txts, scores,
21
+ # font_path='simfang.ttf')
22
+ # im_show = Image.fromarray(im_show)
23
+ # im_show.save('result.jpg')
24
+ # return 'result.jpg'
25
 
26
  title = 'PaddleOCR'
27
  description = 'Gradio demo for PaddleOCR. PaddleOCR demo supports Chinese, English, French, German, Korean and Japanese. To use it, simply upload your image and choose a language from the dropdown menu, or click one of the examples to load them. Read more at the links below.'
 
30
  css = ".output_image, .input_image {height: 40rem !important; width: 100% !important;}"
31
  gr.Interface(
32
  inference,
33
+ [gr.inputs.Image(type='file', label='Input'),gr.inputs.Dropdown(choices=['ch', 'en', 'fr', 'german', 'korean', 'japan'], type="value", default='ch', label='language')],
34
+ # gr.outputs.Image(type='file', label='Output'),
35
+ outputs="text",
36
  title=title,
37
  description=description,
38
  article=article,