PaddlePaddle / PaddleOCR

Awesome multilingual OCR toolkits based on PaddlePaddle (practical ultra lightweight OCR system, support 80+ languages recognition, provide data annotation and synthesis tools, support training and deployment among server, mobile, embedded and IoT devices)
https://paddlepaddle.github.io/PaddleOCR/
Apache License 2.0
43.9k stars 7.8k forks source link

使用中文识别训练模型进行finetune之后,生成的模型无法推理,推理内容为空 #1564

Closed h6266427 closed 3 years ago

h6266427 commented 3 years ago

我用ch_ppocr_mobile_v1.1_rec的“训练模型” (注意是训练模型,不是预训练模型)上进行finetune,训练收敛后acc达到0.75,我使用export_model得出的推理模型进行推理,结果输入图片得不到输出,用infer_rec.py也一样。 而用我自己从头开始训的模型则可以正常识别,请问是哪里出了问题?

我的yml配置文件如下: 主要修改了max_text_length,从25改为44训练

===========rec_chinese_lite_train_v1.1.yml=================== Global: algorithm: CRNN use_gpu: true epoch_num: 1000 log_smooth_window: 1 print_batch_step: 1 save_model_dir: ./output/ch_ppocr_rec_train_ft_lr0005 save_epoch_step: 10 eval_batch_step: 10 train_batch_size_per_card: 256 test_batch_size_per_card: 8 image_shape: [3, 32, 320] max_text_length: 44 character_type: ch character_dict_path: ./ppocr/utils/ppocr_keys_v1.txt loss_type: ctc distort: true use_space_char: true reader_yml: ./configs/rec/rec_chinese_reader.yml pretrain_weights: output/ch_ppocr_mobile_rec_train/best_accuracy checkpoints: save_inference_dir: infer_img:

Architecture: function: ppocr.modeling.architectures.rec_model,RecModel

Backbone: function: ppocr.modeling.backbones.rec_mobilenet_v3,MobileNetV3 scale: 0.5 model_name: small small_stride: [1, 2, 2, 2]

Head: function: ppocr.modeling.heads.rec_ctc_head,CTCPredict encoder_type: rnn fc_decay: 0.00001 SeqRNN: hidden_size: 48

Loss: function: ppocr.modeling.losses.rec_ctc_loss,CTCLoss

Optimizer: function: ppocr.optimizer,AdamDecay base_lr: 0.0005 #0.0005 l2_decay: 0.00001 beta1: 0.9 beta2: 0.999 decay: function: cosine_decay_warmup step_each_epoch: 254 total_epoch: 500 warmup_minibatch: 1000

推理时的输出如下:

2020-12-23 16:01:38,251-INFO: infer_img:./train_data/test/chinise.png
2020-12-23 16:01:38,311-INFO: infer_img:./train_data/test/16.png
2020-12-23 16:01:38,366-INFO: infer_img:./train_data/test/68783387CHN9006.png
2020-12-23 16:01:38,429-INFO: infer_img:./train_data/test/OCT.png
2020-12-23 16:01:38,486-INFO: infer_img:./train_data/test/he.png
2020-12-23 16:01:38,569-INFO: infer_img:./train_data/test/MOMBPK__.png

没有识别结果!!

h6266427 commented 3 years ago

@LDOUBLEV @littletomatodonkey @dyning @WenmuZhou @tink2123 @MissPenguin Please help me! Emergency!

h6266427 commented 3 years ago

我通过使用原来的yml配置文件来生成推理模型,从而解决了这个问题。 I solved this issue by using the original configuration file :"rec_chinese_lite_train_v1.1.yml". So I can close this issue.

leminhyen2 commented 3 years ago

@h6266427 did you retrain using the original configuration file or do you evaluate using that file?

h6266427 commented 3 years ago

@h6266427 did you retrain using the original configuration file or do you evaluate using that file?

@leminhyen2 In evaluating.