File size: 774 Bytes
4d76f31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
os.system('pip install paddlepaddle')
os.system('pip install paddleocr')
import requests
from paddleocr import PaddleOCR, draw_ocr
from PIL import Image
import gradio as gr

img = "input_data/ocr_input/39890867421_3fa100d185_z.jpg"

def inference(img, lang):
	ocr = PaddleOCR(use_angle_cls=True, lang=lang,use_gpu=False)
	img_path = img  
	result = ocr.ocr(img_path, cls=True)[0]
	image = Image.open(img_path).convert('RGB')
	boxes = [line[0] for line in result]
	txts = [line[1][0] for line in result]
	scores = [line[1][1] for line in result]
    return txts
	# im_show = draw_ocr(image, boxes, txts, scores,
	# 		   font_path='./simfang.ttf')
	# im_show = Image.fromarray(im_show)
	# im_show.save('result.jpg')
	# return 'result.jpg'
print(inference(img,"ko"))