Spaces:
Running
Running
Ahsen Khaliq
commited on
Commit
·
047007f
1
Parent(s):
0b5ffa0
Update app.py
Browse files
app.py
CHANGED
@@ -1,30 +1,36 @@
|
|
1 |
-
|
|
|
|
|
2 |
from PIL import Image
|
3 |
import gradio as gr
|
4 |
ocr = PaddleOCR(use_angle_cls=True, lang='en')
|
|
|
|
|
5 |
def inference(img):
|
6 |
img_path = img.name
|
7 |
result = ocr.ocr(img_path, cls=True)
|
8 |
for line in result:
|
9 |
-
print
|
10 |
image = Image.open(img_path).convert('RGB')
|
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 |
-
|
20 |
-
|
|
|
21 |
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>"
|
22 |
|
23 |
gr.Interface(
|
24 |
-
inference,
|
25 |
-
gr.inputs.Image(type=
|
26 |
-
gr.outputs.Image(type=
|
27 |
title=title,
|
28 |
description=description,
|
29 |
-
article=article
|
30 |
-
|
|
|
1 |
+
#!/usr/bin/python
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
from paddleocr import PaddleOCR, draw_ocr
|
4 |
from PIL import Image
|
5 |
import gradio as gr
|
6 |
ocr = PaddleOCR(use_angle_cls=True, lang='en')
|
7 |
+
|
8 |
+
|
9 |
def inference(img):
|
10 |
img_path = img.name
|
11 |
result = ocr.ocr(img_path, cls=True)
|
12 |
for line in result:
|
13 |
+
print line
|
14 |
image = Image.open(img_path).convert('RGB')
|
15 |
boxes = [line[0] for line in result]
|
16 |
txts = [line[1][0] for line in result]
|
17 |
scores = [line[1][1] for line in result]
|
18 |
+
im_show = draw_ocr(image, boxes, txts, scores,
|
19 |
+
font_path='simfang.ttf')
|
20 |
im_show = Image.fromarray(im_show)
|
21 |
im_show.save('result.jpg')
|
22 |
return 'result.jpg'
|
23 |
|
24 |
+
|
25 |
+
title = 'PaddleOCR'
|
26 |
+
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.'
|
27 |
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>"
|
28 |
|
29 |
gr.Interface(
|
30 |
+
inference,
|
31 |
+
gr.inputs.Image(type='file', label='Input'),
|
32 |
+
gr.outputs.Image(type='file', label='Output'),
|
33 |
title=title,
|
34 |
description=description,
|
35 |
+
article=article,
|
36 |
+
).launch(debug=True)
|