Closed Cyuliang closed 2 years ago
可以发一下 inference model 转换命令吗?
好的。 python tools/export_model.py -c configs/rec/rec_r50fpn_vd_none_srn.yml -o Global.pretrained_model=./rec/rec_r50fpn_vd_none_srn_train/best_accuracy Global.save_inference_dir=./rec/inference/ Global.load_static_weights=False
请问您自己训练的模型是否修改了字典文件呢?如果是的话,在预测是需要设置--rec_char_dict_path="your/dict/path"
是的,使用自定义的字典
(python38) cc:~/Documents/PaddleOCR-release-2.4> python tools/infer/predict_rec.py --rec_model_dir=/home/cc/Downloads/output/rec/srn_new/infernece/ --use_gpu=False --rec_algorithm='SRN' --image_dir=/run/media/cc/IMG_Disk/01/crop_img/202104010014140806_crop_0.jpg --rec_char_dict_path=./output/rec/CRNN/con_keys_v1.txt --rec_image_shape=3,64,256 [2022/05/10 14:57:40] root INFO: Traceback (most recent call last): File "tools/infer/predict_rec.py", line 400, in main recres, = text_recognizer(img_list) File "tools/infer/predict_rec.py", line 370, in call rec_result = self.postprocess_op(preds) File "/home/cc/Documents/PaddleOCR-release-2.4/ppocr/postprocess/rec_postprocess.py", line 376, in call pred = np.reshape(pred, [-1, char_num]) File "<__array_function__ internals>", line 180, in reshape File "/home/cc/Public/anaconda3/envs/python38/lib/python3.8/site-packages/numpy/core/fromnumeric.py", line 298, in reshape return _wrapfunc(a, 'reshape', newshape, order=order) File "/home/cc/Public/anaconda3/envs/python38/lib/python3.8/site-packages/numpy/core/fromnumeric.py", line 57, in _wrapfunc return bound(*args, **kwds) ValueError: cannot reshape array of size 950 into shape (39)
[2022/05/10 14:57:40] root INFO: cannot reshape array of size 950 into shape (39)
--rec_image_shape=3,64,256 我更改了训练参数,重新训练导出的模型。测试也不行。原来是--rec_image_shape=1,64,256 。
完整的配置文件 Global: use_gpu: True epoch_num: 72 log_smooth_window: 20 print_batch_step: 50 save_model_dir: ./Downloads/output/rec/srn_new save_epoch_step: 72
eval_batch_step: [1000, 1000] cal_metric_during_train: True pretrained_model: ./output/rec/rec_r50_vd_srn_train/best_accuracy checkpoints: ./output/rec/srn_new/best_accuracy save_inference_dir: ./output/rec/srn_new/infernece/ use_visualdl: True infer_img: doc/imgs_words/ch/word_1.jpg
character_dict_path: ./output/rec/srn_new/con_keys_v1.txt max_text_length: 25 num_heads: 8 infer_mode: False use_space_char: False save_res_path: ./output/rec_srn/predicts_srn.txt
Optimizer: name: Adam beta1: 0.9 beta2: 0.999 clip_norm: 10.0 lr: learning_rate: 0.0001
Architecture: model_type: rec algorithm: SRN in_channels: 1 Transform: Backbone: name: ResNetFPN Head: name: SRNHead max_text_length: 25 num_heads: 8 num_encoder_TUs: 2 num_decoder_TUs: 4 hidden_dims: 512
Loss: name: SRNLoss
PostProcess: name: SRNLabelDecode
Metric: name: RecMetric main_indicator: acc
Train: dataset: name: SimpleDataSet data_dir: ./data/images/rec_train/train label_file_list:
Eval: dataset: name: SimpleDataSet data_dir: ./data/images/rec_train/test label_file_list:
问题已解决 inference:tools/infer/predict_rec.py --rec_char_dict_path=./ppocr/utils/ic15_dict.txt --rec_image_shape="1,64,256" --rec_algorithm="SRN" --use_space_char=False --min_subgraph_size=3
请提供下述完整信息以便快速定位问题/Please provide the following information to quickly locate the problem
Eval: dataset: name: SimpleDataSet data_dir: ./images/rec_train/test label_file_list: