Spaces:
Sleeping
Sleeping
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")) | |