From 141e801c8e2021d6021e0a3479fc1e088a354678 Mon Sep 17 00:00:00 2001 From: Alex Zhang Date: Fri, 16 Dec 2022 16:55:06 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E4=BA=86Dockerfi?= =?UTF-8?q?le?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Vision/OCR/Dockerfile | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Vision/OCR/Dockerfile diff --git a/Vision/OCR/Dockerfile b/Vision/OCR/Dockerfile new file mode 100644 index 0000000..8971dcb --- /dev/null +++ b/Vision/OCR/Dockerfile @@ -0,0 +1,15 @@ +ARG OCR_LANG=zh_CN +ARG PRETRAINED_MODEL=ch_PP-OCRv3_rec_distillation + +FROM nvcr.io/nvidia/paddlepaddle:22.05-py3 + +RUN git clone https://gitee.com/paddlepaddle/PaddleOCR.git /PaddleOCR --depth=1 && \ + cd /PaddleOCR && \ + pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple && \ + pip install opencv-python-headless -i https://pypi.tuna.tsinghua.edu.cn/simple + +COPY output/$OCR_LANG /workspace/output/$OCR_LANG +COPY output/render/$OCR_LANG /workspace/output/render/$OCR_LANG +COPY pretrained_model/$PRETRAINED_MODEL /workspace/pretrained_model/$PRETRAINED_MODEL +COPY *.yml /workspace/ +WORKDIR /workspace From 8a34520cf387d7c6dbc5bc5fe5fe44184f04be7e Mon Sep 17 00:00:00 2001 From: Alex Zhang Date: Fri, 16 Dec 2022 17:22:37 +0800 Subject: [PATCH 2/2] =?UTF-8?q?doc:=20=E6=B7=BB=E5=8A=A0Docker=E7=9A=84?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Vision/OCR/Dockerfile | 4 ++-- Vision/OCR/README.md | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Vision/OCR/Dockerfile b/Vision/OCR/Dockerfile index 8971dcb..77e8bd3 100644 --- a/Vision/OCR/Dockerfile +++ b/Vision/OCR/Dockerfile @@ -1,7 +1,7 @@ ARG OCR_LANG=zh_CN ARG PRETRAINED_MODEL=ch_PP-OCRv3_rec_distillation - -FROM nvcr.io/nvidia/paddlepaddle:22.05-py3 +ARG VERSION=22.05 +FROM nvcr.io/nvidia/paddlepaddle:{22.05}-py3 RUN git clone https://gitee.com/paddlepaddle/PaddleOCR.git /PaddleOCR --depth=1 && \ cd /PaddleOCR && \ diff --git a/Vision/OCR/README.md b/Vision/OCR/README.md index 61d85d6..5aff9f7 100644 --- a/Vision/OCR/README.md +++ b/Vision/OCR/README.md @@ -70,6 +70,27 @@ 只是个大致的流程,都还是 PaddleOCR 的那套,更多详细的参数等请参考 PaddleOCR 的文档 +## 训练方法(Docker) +如果你是用恰好有nvidia-docker并且不想折腾环境可以试试Docker, 本教程假设你知道一些常用的 +0. 依赖 +- `docker` 以及 `nvidia-docker` 具体安装流程参考[Nvidia文档](https://docs.nvidia.com/datacenter/tesla/tesla-installation-notes/index.html) +- 对应版本的CUDA, 本仓库提供的Dockerfile默认版本支持nvidia驱动版本>=515 (CUDA >= 11.7) +1. 获取镜像 + ```bash + docker build -t maa_train . \ # 以下为可选参数 + --build-arg VERSION=22.05 \ # Nvdia 镜像的版本,默认为22.05, 可选的版本参考之前的链接 + --build-arg OCR_LANG=zh_CN \ # 训练数据集的语言,docker将拷贝对应语言数据集到镜像,默认zh_CN, 可选`zh_CN | ja_JP | zh_TW | en_US` + --build_arg PRETRAINED_MODEL=ch_PP-OCRv3_rec_distillation # 预训练模型权重名称, 默认为简中知识蒸馏模型 + ``` +2. 运行镜像 + ```bash + # 如果启动失败,可尝试删除 --ulimit memlock=-1 或者添加sudo运行 + docker --gpus all --shm-size=1g --ulimit memlock=-1 run -it maa_train /bin/bash + ``` + 进入容器后,将第六步中PaddleOCR的位置替换为`../PaddleOCR`,即 + ``` + python ../PaddleOCR/tools/train.py -c ch_PP-OCRv3_rec_distillation.yml + ``` ## 开源库 - [PaddleOCR](https://github.com/PaddlePaddle/PaddleOCR): Awesome multilingual OCR toolkits based on PaddlePaddle