Open5

MMDeployの試行

PINTOPINTO
git clone https://github.com/open-mmlab/mmdeploy.git && cd mmdeploy
git checkout 8daba0218163959514e02fd5a1e48180411fd8aa

cd docker/GPU
docker build -t pinto0309/mmdeploy:20220320 .
docker push pinto0309/mmdeploy:20220320
cd ../..
PINTOPINTO
  • MMOCR
docker pull pinto0309/mmdeploy:20220320

docker run --rm -it --gpus all \
-v `pwd`:/workdir \
pinto0309/mmdeploy:20220320

cd /workdir
git clone https://github.com/open-mmlab/mmocr.git && cd mmocr
git checkout 44ee889141605ab64c2ba5b2025e5d7e26d9c17a
pip install mmdet
pip install -r requirements.txt
pip install -v -e .
pip install onnx-simplifier
export PYTHONPATH=$(pwd):$PYTHONPATH
cd ..

# DBNet
wget https://download.openmmlab.com/mmocr/textdet/dbnet/dbnet_r18_fpnc_sbn_1200e_icdar2015_20210329-ba3ab597.pth -O mmocr/configs/textdet/dbnet/dbnet_r18_fpnc_sbn_1200e_icdar2015_20210329-ba3ab597.pth

# CRNN
wget https://download.openmmlab.com/mmocr/textrecog/crnn/crnn_academic-a723a1c5.pth -O mmocr/configs/textrecog/crnn/crnn_academic-a723a1c5.pth

# SAR
wget https://download.openmmlab.com/mmocr/textrecog/sar/sar_r31_parallel_decoder_academic-dba3a4a3.pth -O mmocr/configs/textrecog/sar/sar_r31_parallel_decoder_academic-dba3a4a3.pth
wget https://download.openmmlab.com/mmocr/textrecog/sar/sar_r31_sequential_decoder_academic-d06c9a8e.pth -O mmocr/configs/textrecog/sar/sar_r31_sequential_decoder_academic-d06c9a8e.pth
PINTOPINTO
  • DBNet
python ./tools/deploy.py \
configs/mmocr/text-detection/text-detection_onnxruntime_static.py \
mmocr/configs/textdet/dbnet/dbnet_r18_fpnc_1200e_icdar2015.py \
mmocr/configs/textdet/dbnet/dbnet_r18_fpnc_sbn_1200e_icdar2015_20210329-ba3ab597.pth \
mmocr/demo/demo_text_det.jpg \
--work-dir work_dir \
--device cpu

onnxsim \
work_dir/end2end.onnx \
work_dir/dbnet_r18_fpnc_sbn_1200e_icdar2015_20210329.onnx

python ./tools/deploy.py \
configs/mmocr/text-detection/text-detection_onnxruntime_dynamic.py \
mmocr/configs/textdet/dbnet/dbnet_r18_fpnc_1200e_icdar2015.py \
mmocr/configs/textdet/dbnet/dbnet_r18_fpnc_sbn_1200e_icdar2015_20210329-ba3ab597.pth \
mmocr/demo/demo_text_det.jpg \
--work-dir work_dir \
--device cpu

mv work_dir/end2end.onnx work_dir/dbnet_r18_fpnc_sbn_1200e_icdar2015_20210329_NxHxW.onnx
  • CRNN
python ./tools/deploy.py \
configs/mmocr/text-recognition/text-recognition_onnxruntime_static.py \
mmocr/configs/textrecog/crnn/crnn_academic_dataset.py \
mmocr/configs/textrecog/crnn/crnn_academic-a723a1c5.pth \
mmocr/demo/demo_text_det.jpg \
--work-dir work_dir \
--device cpu

onnxsim \
work_dir/end2end.onnx \
work_dir/crnn_academic.onnx
  • SAR
### parallel
python ./tools/deploy.py \
configs/mmocr/text-recognition/text-recognition_onnxruntime_static.py \
mmocr/configs/textrecog/sar/sar_r31_parallel_decoder_academic.py \
mmocr/configs/textrecog/sar/sar_r31_parallel_decoder_academic-dba3a4a3.pth \
mmocr/demo/demo_text_det.jpg \
--work-dir work_dir \
--device cpu

onnxsim \
work_dir/end2end.onnx \
work_dir/sar_r31_parallel_decoder_academic.onnx

python ./tools/deploy.py \
configs/mmocr/text-recognition/text-recognition_onnxruntime_dynamic.py \
mmocr/configs/textrecog/sar/sar_r31_parallel_decoder_academic.py \
mmocr/configs/textrecog/sar/sar_r31_parallel_decoder_academic-dba3a4a3.pth \
mmocr/demo/demo_text_det.jpg \
--work-dir work_dir \
--device cpu

mv work_dir/end2end.onnx work_dir/sar_r31_parallel_decoder_academic_Nx3x48xW.onnx

### Sequential
python ./tools/deploy.py \
configs/mmocr/text-recognition/text-recognition_onnxruntime_static.py \
mmocr/configs/textrecog/sar/sar_r31_sequential_decoder_academic.py \
mmocr/configs/textrecog/sar/sar_r31_sequential_decoder_academic-d06c9a8e.pth \
mmocr/demo/demo_text_det.jpg \
--work-dir work_dir \
--device cpu

onnxsim \
work_dir/end2end.onnx \
work_dir/sar_r31_sequential_decoder_academic.onnx

python ./tools/deploy.py \
configs/mmocr/text-recognition/text-recognition_onnxruntime_dynamic.py \
mmocr/configs/textrecog/sar/sar_r31_sequential_decoder_academic.py \
mmocr/configs/textrecog/sar/sar_r31_sequential_decoder_academic-d06c9a8e.pth \
mmocr/demo/demo_text_det.jpg \
--work-dir work_dir \
--device cpu

mv work_dir/end2end.onnx work_dir/sar_r31_sequential_decoder_academic_Nx3x48xW.onnx
PINTOPINTO
  • Textsnake
# Textsnake
wget https://download.openmmlab.com/mmocr/textdet/textsnake/textsnake_r50_fpn_unet_1200e_ctw1500-27f65b64.pth -O mmocr/configs/textdet/textsnake/textsnake_r50_fpn_unet_1200e_ctw1500-27f65b64.pth

python ./tools/deploy.py \
configs/mmocr/text-detection/text-detection_onnxruntime_static.py \
mmocr/configs/textdet/textsnake/textsnake_r50_fpn_unet_1200e_ctw1500.py \
mmocr/configs/textdet/textsnake/textsnake_r50_fpn_unet_1200e_ctw1500-27f65b64.pth \
mmocr/demo/demo_text_det.jpg \
--work-dir work_dir \
--device cpu

onnxsim \
work_dir/end2end.onnx \
work_dir/textsnake_r50_fpn_unet_1200e_ctw1500.onnx

python ./tools/deploy.py \
configs/mmocr/text-detection/text-detection_onnxruntime_dynamic.py \
mmocr/configs/textdet/textsnake/textsnake_r50_fpn_unet_1200e_ctw1500.py \
mmocr/configs/textdet/textsnake/textsnake_r50_fpn_unet_1200e_ctw1500-27f65b64.pth \
mmocr/demo/demo_text_det.jpg \
--work-dir work_dir \
--device cpu

mv work_dir/end2end.onnx work_dir/textsnake_r50_fpn_unet_1200e_ctw1500_Nx3xHxW.onnx