训练好图片样本后,采取文字识别训练检测步骤表现良好:
python tools/infer_det.py -c configs/det/det_mv3_db.yml -o Global.infer_img="./train_data/try/" Global.pretrained_model="./output/db_mv3/best_accuracy"
cmd显示:
[2021/09/14 15:54:32] root INFO: The detected Image saved in ./output/det_db/det_results/200215.pngsub_pic88_8.png
[2021/09/14 15:54:32] root INFO: infer_img: ./train_data/try/200215.pngsub_pic89_8.png
[2021/09/14 15:54:34] root INFO: The detected Image saved in ./output/det_db/det_results/200215.pngsub_pic89_8.png
[2021/09/14 15:54:34] root INFO: infer_img: ./train_data/try/200215.pngsub_pic8_8.png
[2021/09/14 15:54:36] root INFO: The detected Image saved in ./output/det_db/det_results/200215.pngsub_pic8_8.png
[2021/09/14 15:54:36] root INFO: infer_img: ./train_data/try/200215.pngsub_pic90_8.png
[2021/09/14 15:54:38] root INFO: The detected Image saved in ./output/det_db/det_results/200215.pngsub_pic90_8.png
[2021/09/14 15:54:38] root INFO: infer_img: ./train_data/try/200215.pngsub_pic91_8.png
[2021/09/14 15:54:40] root INFO: The detected Image saved in ./output/det_db/det_results/200215.pngsub_pic91_8.png
[2021/09/14 15:54:40] root INFO: infer_img: ./train_data/try/200215.pngsub_pic92_8.png
[2021/09/14 15:54:42] root INFO: The detected Image saved in ./output/det_db/det_results/200215.pngsub_pic92_8.png
[2021/09/14 15:54:42] root INFO: infer_img: ./train_data/try/200215.pngsub_pic94_8.png
[2021/09/14 15:54:44] root INFO: The detected Image saved in ./output/det_db/det_results/200215.pngsub_pic94_8.png
[2021/09/14 15:54:44] root INFO: infer_img: ./train_data/try/200215.pngsub_pic96_8.png
[2021/09/14 15:54:46] root INFO: The detected Image saved in ./output/det_db/det_results/200215.pngsub_pic96_8.png
[2021/09/14 15:54:46] root INFO: infer_img: ./train_data/try/200215.pngsub_pic97_8.png
按照教程转inference模型:
# 保存自己训练的模型
python tools/export_model.py -c configs/det/det_mv3_db.yml -o Global.pretrained_model=./output/db_mv3/best_accuracy Global.save_inference_dir=./inference/db_mv3/
训练的识别模型与上述检测模型情况相似,用best_accuracy测试准确度很好。
但最终使用inference文件检测时,无法识别,均显示空白
python tools/infer/predict_system.py --image_dir="./train_data/test/" --det_model_dir="./inference/db_mv3" --rec_model_dir="./inference/rec_ic" --use_angle_cls=false
cmd显示:
2021/09/14 19:14:36] root INFO: The visualized image saved in ./inference_results/190205.pngsub_pic1_8.png
[2021/09/14 19:14:36] root INFO: dt_boxes num : 0, elapse : 0.007974624633789062
[2021/09/14 19:14:36] root INFO: rec_res num : 0, elapse : 0
[2021/09/14 19:14:36] root INFO: Predict time of ./train_data/test/190205.pngsub_pic2_3.png: 0.009s
[2021/09/14 19:14:36] root INFO: The visualized image saved in ./inference_results/190205.pngsub_pic2_3.png
[2021/09/14 19:14:36] root INFO: dt_boxes num : 0, elapse : 0.010001420974731445
[2021/09/14 19:14:36] root INFO: rec_res num : 0, elapse : 0
[2021/09/14 19:14:36] root INFO: Predict time of ./train_data/test/190205.pngsub_pic2_5.png: 0.012s
[2021/09/14 19:14:36] root INFO: The visualized image saved in ./inference_results/190205.pngsub_pic2_5.png
[2021/09/14 19:14:36] root INFO: dt_boxes num : 0, elapse : 0.008976459503173828
[2021/09/14 19:14:36] root INFO: rec_res num : 0, elapse : 0
[2021/09/14 19:14:36] root INFO: Predict time of ./train_data/test/190205.pngsub_pic2_7.png: 0.010s
[2021/09/14 19:14:36] root INFO: The visualized image saved in ./inference_results/190205.pngsub_pic2_7.png
[2021/09/14 19:14:36] root INFO: dt_boxes num : 0, elapse : 0.010007619857788086
[2021/09/14 19:14:36] root INFO: rec_res num : 0, elapse : 0
[2021/09/14 19:14:36] root INFO: Predict time of ./train_data/test/190205.pngsub_pic2_8.png: 0.014s
[2021/09/14 19:14:36] root INFO: The visualized image saved in ./inference_results/190205.pngsub_pic2_8.png
[2021/09/14 19:14:36] root INFO: dt_boxes num : 0, elapse : 0.011003732681274414
[2021/09/14 19:14:36] root INFO: rec_res num : 0, elapse : 0
[2021/09/14 19:14:36] root INFO: Predict time of ./train_data/test/190205.pngsub_pic3_8.png: 0.015s
[2021/09/14 19:14:36] root INFO: The visualized image saved in ./inference_results/190205.pngsub_pic3_8.png
[2021/09/14 19:14:36] root INFO: dt_boxes num : 0, elapse : 0.012963056564331055
[2021/09/14 19:14:36] root INFO: rec_res num : 0, elapse : 0
————————————————————————
补充:
尝试使用自行训练后生成的inference文件单独识别图片。
对于自己的图片,没有反应,但是官方的测试图片,虽然准确性差,是可以有识别动作的。
命令语句:python tools/infer/predict_det.py --image_dir="./doc/imgs/11.jpg" --det_model_dir="./inference/db_mv3/"
#db_mv3为自行训练后转换的inference文件夹
结果:
预测使用的图片是不是和训练时采用的相同的预处理呢
采用inference文件预测的图片和采用best_accuracy文件预测的图片,是同一个组图片。想请教一下,预处理具体指什么呢?
图片尺寸调整,归一化等,甚至有些ocr预处理还进行灰度化
预测和训练的图片比较简单,都没有预处理过
为什么判别后的图片多出一块儿白的呢?打印下形状看看和读取的有什么不同吧
导出的时候有变化?
同问
not find model file path ./outputall/db_mv3/best_accuracy/inference.pdmodel
这个文件你那边目录有生成的吗