RUN pip install uvicorn -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install python-multipart -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install paddleocr -i https://pypi.tuna.tsinghua.edu.cn/simple
CMD [“python”, “/paddle/main_ocr.py”]
5. 核心代码
ocr_paddle.py
from paddleocr import PaddleOCR, draw_ocr
Paddleocr目前支持的多语言语种可以通过修改lang参数进行切换
例如ch
, en
, fr
, german
, korean
, japan
def ocr(file_name):
ocr = PaddleOCR(use_angle_cls=True, lang=“ch”) # need to run only once to download and load model into memory
img_path = ‘./uploads/’+file_name
result = ocr.ocr(img_path, cls=True)
final_txt=[]
for idx in range(len(result)):
res = result[id