Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,30 +1,26 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
#
|
21 |
-
#
|
22 |
-
|
23 |
-
#
|
24 |
-
#
|
25 |
-
|
26 |
-
|
27 |
-
# render the formatted OCR results:
|
28 |
-
# res = model.chat(tokenizer, image_file, ocr_type='format', render=True, save_render_file = './demo.html')
|
29 |
-
|
30 |
-
print(res)
|
|
|
1 |
+
import os
|
2 |
+
os.system('pip install paddlepaddle')
|
3 |
+
os.system('pip install paddleocr')
|
4 |
+
import requests
|
5 |
+
from paddleocr import PaddleOCR, draw_ocr
|
6 |
+
from PIL import Image
|
7 |
+
import gradio as gr
|
8 |
+
|
9 |
+
img = "input_data/ocr_input/39890867421_3fa100d185_z.jpg"
|
10 |
+
|
11 |
+
def inference(img, lang):
|
12 |
+
ocr = PaddleOCR(use_angle_cls=True, lang=lang,use_gpu=False)
|
13 |
+
img_path = img
|
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 |
+
return txts
|
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 |
+
print(inference(img,"ko"))
|
|
|
|
|
|
|
|