但是文档写的垃圾,没有完整的用法。
看了好多其他文章,也是或多或少有问题,要么制作镜像不成功,要么运行失败。
给出一份最后成功的Dockerfile文件:
# Version: 2.6.1
FROM registry.baidubce.com/paddlepaddle/paddle:2.6.1
# 设置python源为清华
RUN pip3 install pip -U
RUN pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip3 install paddlehub --upgrade
RUN git clone https://github.com/PaddlePaddle/PaddleOCR.git /PaddleOCR
WORKDIR /PaddleOCR
RUN pip3 install -r requirements.txt
RUN mkdir -p /PaddleOCR/inference/
# Download orc detect model(light version). if you want to change normal version, you can change ch_ppocr_mobile_v2.0_det_infer to ch_ppocr_server_v2.0_det_infer, also remember change det_model_dir in deploy/hubserving/ocr_system/params.py)
# Download direction classifier(light version). If you want to change normal version, you can change ch_ppocr_mobile_v2.0_cls_infer to ch_ppocr_mobile_v2.0_cls_infer, also remember change cls_model_dir in deploy/hubserving/ocr_system/params.py)
# Download orc recognition model(light version). If you want to change normal version, you can change ch_ppocr_mobile_v2.0_rec_infer to ch_ppocr_server_v2.0_rec_infer, also remember change rec_model_dir in deploy/hubserving/ocr_system/params.py)
# 下载并解压 OCR 文本检测模型
ADD https://paddleocr.bj.bcebos.com/PP-OCRv3/chinese/ch_PP-OCRv3_det_infer.tar /PaddleOCR/inference/
# 下载并解压 OCR 文本方向分类模型
ADD https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_cls_infer.tar /PaddleOCR/inference/
# 下载并解压 OCR 文本识别模型
ADD https://paddleocr.bj.bcebos.com/PP-OCRv3/chinese/ch_PP-OCRv3_rec_infer.tar /PaddleOCR/inference/
RUN tar xf /PaddleOCR/inference/ch_PP-OCRv3_det_infer.tar -C /PaddleOCR/inference/
RUN tar xf /PaddleOCR/inference/ch_ppocr_mobile_v2.0_cls_infer.tar -C /PaddleOCR/inference/
RUN tar xf /PaddleOCR/inference/ch_PP-OCRv3_rec_infer.tar -C /PaddleOCR/inference/
RUN pip3 uninstall -y astroid
RUN pip3 install astroid==2.12.2
RUN pip3 uninstall -y protobuf
RUN pip3 install protobuf==3.20.0
# 安装ocr\_system服务
RUN hub install deploy/hubserving/ocr_system/
EXPOSE 8868
CMD ["/bin/bash","-c","hub install deploy/hubserving/ocr_system/ && hub serving start -m ocr_system"]
制作镜像
docker build -t ppocr:v2 .
启动容器
docker run -dp 8866:8866 --name ppocrv2 ppocr:v2
然后就可以访问IP:8866服务了