有时候会被 PaddleOCR 强大的功能吸引,但一看到安装就头大。其实,只要按顺序执行这三步,哪怕是小白也能一次成功。
PaddleOCR 是基于百度飞桨(PaddlePaddle)开发的,所以得先装它。
• 普通电脑(CPU版): 速度已经很快了,推荐大多数人选这个。
pip install paddlepaddle -i https://pypi.tuna.tsinghua.edu.cn/simple• 有显卡的电脑(GPU版): 如果有 NVIDIA 显卡,追求极致性能:
pip install paddlepaddle-gpu -i https://pypi.tuna.tsinghua.edu.cn/simple这就是你代码里调用的那个库。
pip install paddleocr -i https://pypi.tuna.tsinghua.edu.cn/simple如果在运行代码时提示缺少 shapely 或 opencv,直接一键补齐:
pip install shapely opencv-python -i https://pypi.tuna.tsinghua.edu.cn/simple最新的PP-OCRv6代码使用如下
from paddleocr import PaddleOCR
ocr = PaddleOCR(
text_detection_model_name="PP-OCRv6_small_det",
text_recognition_model_name="PP-OCRv6_small_rec"
)
result = ocr.predict("./your_image.png")
for res in result:
res.print()
res.save_to_img("output")-i https://pypi...),不然你可能会在下载进度条前思考人生,直到下载失败。Microsoft Visual C++ 14.0 is required,别怀疑,那是你 Windows 缺补丁了,去搜一下“VC_redist”装上重启就好。附录
https://huggingface.co/PaddlePaddle/PP-OCRv6_small_det
#ppocrv6 #paddleocr