Upload 5 files
Browse files- BreezeSans-Light.ttf +0 -0
- app.py +37 -0
- requirements.txt +3 -0
- result.jpg +0 -0
- test2.png +0 -0
BreezeSans-Light.ttf
ADDED
|
Binary file (218 kB). View file
|
|
|
app.py
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from paddleocr import PaddleOCR, draw_ocr
|
| 2 |
+
from PIL import Image
|
| 3 |
+
import gradio as gr
|
| 4 |
+
|
| 5 |
+
def inference(img, lang):
|
| 6 |
+
ocr = PaddleOCR(use_angle_cls=True, lang=lang,use_gpu=False)
|
| 7 |
+
img_path = img
|
| 8 |
+
result = ocr.ocr(img_path, cls=True)[0]
|
| 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='BreezeSans-Light.ttf')
|
| 15 |
+
im_show = Image.fromarray(im_show)
|
| 16 |
+
im_show.save('result.jpg')
|
| 17 |
+
|
| 18 |
+
return 'result.jpg'
|
| 19 |
+
|
| 20 |
+
title = 'PaddleOCR'
|
| 21 |
+
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.'
|
| 22 |
+
article = "<p style='text-align: center'><a href='http://claireye.com.tw'>Claireye</a> | 2023</p>"
|
| 23 |
+
examples = [
|
| 24 |
+
["02.png", 'tr']
|
| 25 |
+
]
|
| 26 |
+
gr.Interface(
|
| 27 |
+
inference,
|
| 28 |
+
[gr.inputs.Image(type='filepath', label='Input'),
|
| 29 |
+
gr.inputs.Dropdown(choices=['tr', 'az'], type="value", default='tr', label='language')],
|
| 30 |
+
gr.outputs.Image(type='filepath', label='Output'),
|
| 31 |
+
title=title,
|
| 32 |
+
description=description,
|
| 33 |
+
article=article,
|
| 34 |
+
examples=examples,
|
| 35 |
+
cache_examples=True,
|
| 36 |
+
enable_queue=True
|
| 37 |
+
).launch(debug=True)
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Pillow
|
| 2 |
+
paddlepaddle
|
| 3 |
+
paddleocr
|
result.jpg
ADDED
|
test2.png
ADDED
|