PaddleOCR docker实现 文字检测 身份证识别

百度PaddleOcr已集成服务调用,端口8866。  

docker pull 987846/paddleocr
sudo docker run --name ppdocr -p 8866:8866 -d 987846/paddleocr:latest
sudo docker exec -it ppdocr bash
python3 tools/infer/predict_system.py --image_dir="./doc/imgs/11.jpg" --det_model_dir="./inference/ch_ppocr_mobile_v1.1_det_infer/" --rec_model_dir="./inference/ch_ppocr_mobile_v1.1_rec_infer/"

出现错误:

λ 2de7decafecb /home/PaddleOCR {develop} python3 tools/infer/predict_system.py --image_dir="./doc/imgs/11.jpg" --det_model_dir="./inference/ch_det_mv3_db/" --rec_model_dir="./inference/ch_rec_mv3_crnn/"
Traceback (most recent call last):
  File "tools/infer/predict_system.py", line 21, in <module>
    import tools.infer.utility as utility
  File "/home/PaddleOCR/tools/infer/utility.py", line 17, in <module>
    from ppocr.utils.utility import initial_logger
  File "/home/PaddleOCR/ppocr/utils/utility.py", line 19, in <module>
    from paddle import fluid
  File "/usr/local/python3.5.1/lib/python3.5/site-packages/paddle/__init__.py", line 30, in <module>
    import paddle.dataset
  File "/usr/local/python3.5.1/lib/python3.5/site-packages/paddle/dataset/__init__.py", line 28, in <module>
    import paddle.dataset.mq2007
  File "/usr/local/python3.5.1/lib/python3.5/site-packages/paddle/dataset/mq2007.py", line 30, in <module>
    import rarfile
  File "/usr/local/python3.5.1/lib/python3.5/site-packages/rarfile.py", line 64, in <module>
    from hashlib import blake2s, sha1, sha256
ImportError: cannot import name 'blake2s'

解决:

pip3 uninstall rarfile
pip3 install rarfile==3.0
python3 tools/infer/predict_system.py --image_dir="./doc/imgs/11.jpg" --det_model_dir="./inference/ch_ppocr_mobile_v1.1_det_infer/" --rec_model_dir="./inference/ch_ppocr_mobile_v1.1_rec_infer/"

用自己的图片进行测试:

sudo docker cp ./test 2de7decafecb:/home/PaddleOCR
 python3 tools/infer/predict_system.py --image_dir="./test/1.jpg" --det_model_dir="./inference/ch_ppocr_mobile_v1.1_det_infer/" --rec_model_dir="./inference/ch_ppocr_mobile_v1.1_rec_infer/"

发送预测请求:

python3 tools/test_hubserving.py http://127.0.0.1:8866/predict/ocr_system ./test/

也可参考:https://blog.csdn.net/runlion_123/article/details/108646482

猜你喜欢

转载自blog.csdn.net/qq_34717531/article/details/112244722
今日推荐