You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import io
import numpy as np
from PIL import Image
from fastapi import File, UploadFile
from paddleocr import PaddleOCR
# Paddleocr目前支持的多语言语种可以通过修改lang参数进行切换
# 例如`ch`, `en`, `fr`, `german`, `korean`, `japan`
ocr = PaddleOCR(use_angle_cls=True, lang="ch", enable_mkldnn=True,
cpu_threads=16, use_gpu=False) # need to run only once to download and load model into memory
async def single(file: UploadFile = File(...)):
# 读取文件的二进制内容z`
image_bytes = await file.read()
# 将字节流转换为PIL图像
image = Image.open(io.BytesIO(image_bytes))
# 将PIL图像转换为numpy数组
image_np = np.array(image)
result = ocr.ocr(image_np, cls=True)
for idx in range(len(result)):
res = result[idx]
if res is None or len(res) != 1:
return '未识别'
else:
return res
The text was updated successfully, but these errors were encountered:
请提出你的问题 Please ask your question
问题:
我在没有gpu驱动的docker环境下,以及有gpu的环境,使用相同的代码运行,前者可以开启多线程qps为10.2/s,而后者则是单线程qps只有1.1/s
代码
The text was updated successfully, but these errors were encountered: