Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用训练好的识别模型进行预测, 报错 #44

Closed
NextGuido opened this issue May 15, 2020 · 4 comments
Closed

使用训练好的识别模型进行预测, 报错 #44

NextGuido opened this issue May 15, 2020 · 4 comments

Comments

@NextGuido
Copy link

你好, 非常感谢您的项目, 很棒! 我先后跑了检测和识别模型, 当识别模型训练完毕之后, 打算进行单张图片的预测, 因此执行提供的命令, python3 tools/infer_rec.py -c configs/rec/rec_chinese_lite_train.yml -o Global.checkpoints=./output/rec_CRNN/best_accuracy TestReader.infer_img=./doc/imgs_word/word_1.jpg, 但是发生了下面的报错, 可以麻烦帮我看一下原因吗?感谢

2020-05-15 23:06:04,952-INFO: {'Global': {'algorithm': 'CRNN', 'use_gpu': True, 'epoch_num': 3000, 'log_smooth_window': 20, 'print_batch_step': 10, 'save_model_dir': './output/rec_CRNN', 'save_epoch_step': 3, 'eval_batch_step': 2000, 'train_batch_size_per_card': 256, 'test_batch_size_per_card': 256, 'image_shape': [3, 32, 100], 'max_text_length': 25, 'character_type': 'ch', 'character_dict_path': './ppocr/utils/ppocr_keys_v1.txt', 'loss_type': 'ctc', 'reader_yml': './configs/rec/rec_chinese_reader.yml', 'pretrain_weights': './pretrain_models/CRNN/best_accuracy', 'checkpoints': './output/rec_CRNN/best_accuracy', 'save_inference_dir': None}, 'Architecture': {'function': 'ppocr.modeling.architectures.rec_model,RecModel'}, 'Backbone': {'function': 'ppocr.modeling.backbones.rec_mobilenet_v3,MobileNetV3', 'scale': 0.5, 'model_name': 'small'}, 'Head': {'function': 'ppocr.modeling.heads.rec_ctc_head,CTCPredict', 'encoder_type': 'rnn', 'SeqRNN': {'hidden_size': 48}}, 'Loss': {'function': 'ppocr.modeling.losses.rec_ctc_loss,CTCLoss'}, 'Optimizer': {'function': 'ppocr.optimizer,AdamDecay', 'base_lr': 0.0005, 'beta1': 0.9, 'beta2': 0.999}, 'TrainReader': {'reader_function': 'ppocr.data.rec.dataset_traversal,SimpleReader', 'num_workers': 8, 'img_set_dir': './train_data', 'label_file_path': './train_data/rec_gt_train.txt'}, 'EvalReader': {'reader_function': 'ppocr.data.rec.dataset_traversal,SimpleReader', 'img_set_dir': './train_data', 'label_file_path': './train_data/rec_gt_test.txt'}, 'TestReader': {'reader_function': 'ppocr.data.rec.dataset_traversal,SimpleReader', 'infer_img': './doc/imgs_word/word_1.jpg'}} W0515 23:06:05.985396 31885 device_context.cc:237] Please NOTE: device: 0, CUDA Capability: 70, Driver API Version: 10.1, Runtime API Version: 9.0 W0515 23:06:05.989531 31885 device_context.cc:245] device: 0, cuDNN Version: 7.3. Traceback (most recent call last): File "tools/infer_rec.py", line 130, in <module> main() File "tools/infer_rec.py", line 79, in main init_model(config, eval_prog, exe) File "/home/aistudio/ppocr/utils/save_load.py", line 114, in init_model fluid.load(program, path, exe) File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/io.py", line 1740, in load v.name, parameter_file_name) AssertionError: Can not find [conv11_se_1_offset] in model file [./output/rec_CRNN/best_accuracy.pdparams]

@dyning
Copy link
Collaborator

dyning commented May 15, 2020

感谢您的关注,我们尽快跟进查下问题。再就是,你也可以参考 基于预测引擎推理 章节,转成推理模型,看看是否可以正常预测。里面详细介绍了如何进行不同算法的文本检测模型推理、不同算法的文本识别模型推理、以及文本检测、识别串联推理中更换模型,以及如何在CPU运行。
https://github.com/PaddlePaddle/PaddleOCR/blob/develop/doc/inference.md

@tink2123
Copy link
Collaborator

方便提供一下训练的命令吗~也麻烦您确认一下 /output/rec_CRNN/ 这个路径下是否有训练好的权重文件呢?

@tink2123
Copy link
Collaborator

请问训练时 是否使用的是 configs/rec/rec_icdar15_train.yml 这个配置文件呢? 如果是的话,预测时请也使用同一配置文件进行预测:
python3 tools/infer_rec.py -c configs/rec/rec_icdar15_train.yml -o Global.checkpoints=./output/rec_CRNN/best_accuracy TestReader.infer_img=./doc/imgs_word/word_1.jpg
文档里介绍训练流程时以英文为例,可能造成了您的误解,我们会优化文档表达。感谢您的反馈~

@NextGuido
Copy link
Author

@dyning @tink2123 感谢答疑, 确实是因为配置文件加载出错导致的问题. 我是用configs/rec/rec_icdar15_train.yml文件进行训练的, 但是预测的时候加载了错误的中文配置文件, 非常感谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants