diff --git a/doc/imgs_words/word_1.jpg b/doc/imgs_words/ch/word_1.jpg similarity index 100% rename from doc/imgs_words/word_1.jpg rename to doc/imgs_words/ch/word_1.jpg diff --git a/doc/imgs_words/word_2.jpg b/doc/imgs_words/ch/word_2.jpg similarity index 100% rename from doc/imgs_words/word_2.jpg rename to doc/imgs_words/ch/word_2.jpg diff --git a/doc/imgs_words/word_3.jpg b/doc/imgs_words/ch/word_3.jpg similarity index 100% rename from doc/imgs_words/word_3.jpg rename to doc/imgs_words/ch/word_3.jpg diff --git a/doc/imgs_words/word_4.jpg b/doc/imgs_words/ch/word_4.jpg similarity index 100% rename from doc/imgs_words/word_4.jpg rename to doc/imgs_words/ch/word_4.jpg diff --git a/doc/imgs_words/word_5.jpg b/doc/imgs_words/ch/word_5.jpg similarity index 100% rename from doc/imgs_words/word_5.jpg rename to doc/imgs_words/ch/word_5.jpg diff --git a/doc/imgs_words/en/word_1.png b/doc/imgs_words/en/word_1.png new file mode 100644 index 0000000000000000000000000000000000000000..7b915fd6da3916bd269d9de85f2236df11bb3155 Binary files /dev/null and b/doc/imgs_words/en/word_1.png differ diff --git a/doc/imgs_words/en/word_2.png b/doc/imgs_words/en/word_2.png new file mode 100644 index 0000000000000000000000000000000000000000..019cb80c963ef18448d9db48d83d4ee7161a5f6e Binary files /dev/null and b/doc/imgs_words/en/word_2.png differ diff --git a/doc/imgs_words/en/word_3.png b/doc/imgs_words/en/word_3.png new file mode 100644 index 0000000000000000000000000000000000000000..f14e8d404c26169f36e150d46164b3735ebb16bf Binary files /dev/null and b/doc/imgs_words/en/word_3.png differ diff --git a/doc/imgs_words/en/word_4.png b/doc/imgs_words/en/word_4.png new file mode 100644 index 0000000000000000000000000000000000000000..60fb82816ca7919df6175a37208c071fa3259740 Binary files /dev/null and b/doc/imgs_words/en/word_4.png differ diff --git a/doc/imgs_words/en/word_5.png b/doc/imgs_words/en/word_5.png new file mode 100644 index 0000000000000000000000000000000000000000..10fd19f1c2fa8cb94a167241f52817e9f333a94e Binary files /dev/null and b/doc/imgs_words/en/word_5.png differ diff --git a/doc/inference.md b/doc/inference.md index d6bebf59507f140e54921a0fd548377b8d2b38fe..c0b5ea2846a4d86d41e14573edf92de5d62de3f8 100644 --- a/doc/inference.md +++ b/doc/inference.md @@ -91,14 +91,14 @@ python3 tools/infer/predict_det.py --image_dir="./doc/imgs_en/img_10.jpg" --det_ 超轻量中文识别模型推理,可以执行如下命令: ``` -python3 tools/infer/predict_rec.py --image_dir="./doc/imgs_words/word_4.jpg" --rec_model_dir="./inference/rec/" +python3 tools/infer/predict_rec.py --image_dir="./doc/imgs_words/ch/word_4.jpg" --rec_model_dir="./inference/rec/" ``` -![](imgs_words/word_4.jpg) +![](imgs_words/ch/word_4.jpg) 执行命令后,上面图像的预测结果(识别的文本和得分)会打印到屏幕上,示例如下: -Predicts of ./doc/imgs_words/word_4.jpg:['实力活力', 0.89552695] +Predicts of ./doc/imgs_words/ch/word_4.jpg:['实力活力', 0.89552695] ### 2.基于CTC损失的识别模型推理 diff --git a/doc/recognition.md b/doc/recognition.md index 64d00e5409650bdeaa5f195821de54d46faa9911..bd13ddaf0d00bb22af248a86849399d5288511c6 100644 --- a/doc/recognition.md +++ b/doc/recognition.md @@ -116,6 +116,7 @@ tar -xf rec_mv3_none_bilstm_ctc.tar && rm -rf rec_mv3_none_bilstm_ctc.tar export PYTHONPATH=$PYTHONPATH:. # GPU训练 支持单卡,多卡训练,通过CUDA_VISIBLE_DEVICES指定卡号 export CUDA_VISIBLE_DEVICES=0,1,2,3 +# 训练icdar15英文数据 python3 tools/train.py -c configs/rec/rec_icdar15_train.yml ``` @@ -123,7 +124,7 @@ PaddleOCR支持训练和评估交替进行, 可以在 `configs/rec/rec_icdar15_t 如果验证集很大,测试将会比较耗时,建议减少评估次数,或训练完再进行评估。 -* 提示: 可通过 -c 参数选择 `configs/rec/` 路径下的多种模型配置进行训练 +* 提示: 可通过 -c 参数选择 `configs/rec/` 路径下的多种模型配置进行训练,例如中文 9M 配置文件为 `rec_chinese_lite_train.yml` ### 评估 @@ -139,21 +140,43 @@ python3 tools/eval.py -c configs/rec/rec_chinese_lite_train.yml -o Global.checkp * 训练引擎的预测 -使用 PaddleOCR 训练好的中文模型,可以通过以下脚本进行快速预测。 +使用 PaddleOCR 训练好的模型,可以通过以下脚本进行快速预测。 默认预测图片存储在 `infer_img` 里,通过 `-o Global.checkpoints` 指定权重: ``` -python3 tools/infer_rec.py -c configs/rec/rec_chinese_lite_train.yml -o Global.checkpoints={path/to/weights}/best_accuracy TestReader.infer_img=doc/imgs_word/word_1.jpg +# 预测英文结果 +python3 tools/infer_rec.py -c configs/rec/rec_chinese_lite_train.yml -o Global.checkpoints={path/to/weights}/best_accuracy TestReader.infer_img=doc/imgs_word/en/word_1.jpg ``` + +预测图片: + +![](./imgs_words/en/word_1.png) + +得到输入图像的预测结果: + +``` +infer_img: doc/imgs_words/en/word_1.png + index: [19 24 18 23 29] + word : joint +``` + +预测使用的配置文件必须与训练一致,如您通过 `python3 tools/train.py -c configs/rec/rec_chinese_lite_train.yml` 完成了中文模型的训练, +您可以使用如下命令进行中文模型预测。 + +``` +# 预测中文结果 +python3 tools/infer_rec.py -c configs/rec/rec_chinese_lite_train.yml -o Global.checkpoints={path/to/weights}/best_accuracy TestReader.infer_img=doc/imgs_word/ch/word_1.jpg +``` + 预测图片: -![](./imgs_words/word_1.jpg) +![](./imgs_words/ch/word_1.jpg) 得到输入图像的预测结果: ``` -infer_img: doc/imgs_words/word_1.jpg +infer_img: doc/imgs_words/ch/word_1.jpg index: [2092 177 312 2503] word : 韩国小馆 ```