Ahsen Khaliq commited on
Commit
ebb9438
1 Parent(s): 3e91a01

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py CHANGED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from paddleocr import PaddleOCR, draw_ocr
2
+ from PIL import Image
3
+ import gradio as gr
4
+ ocr = PaddleOCR(use_angle_cls=True, lang='en')
5
+
6
+ def inference(img):
7
+ img_path = img.name
8
+ result = ocr.ocr(img_path, cls=True)
9
+ image = Image.open(img_path).convert('RGB')
10
+ boxes = [line[0] for line in result]
11
+ txts = [line[1][0] for line in result]
12
+ scores = [line[1][1] for line in result]
13
+ im_show = draw_ocr(image, boxes, txts, scores,
14
+ font_path='simfang.ttf')
15
+ im_show = Image.fromarray(im_show)
16
+ im_show.save('result.jpg')
17
+ return 'result.jpg'
18
+
19
+
20
+ title = 'PaddleOCR'
21
+ description = 'Gradio demo for PaddleOCR. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below.'
22
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2104.05703'>Adversarial Open Domain Adaption for Sketch-to-Photo Synthesis</a> | <a href='https://github.com/Mukosame/Anime2Sketch'>Github Repo</a></p>"
23
+
24
+ gr.Interface(
25
+ inference,
26
+ gr.inputs.Image(type='file', label='Input'),
27
+ gr.outputs.Image(type='file', label='Output'),
28
+ title=title,
29
+ description=description,
30
+ article=article,
31
+ ).launch(debug=True)