frotms / PaddleOCR2Pytorch

PaddleOCR inference in PyTorch. Converted from [PaddleOCR](https://github.com/PaddlePaddle/PaddleOCR)
Apache License 2.0
842 stars 165 forks source link

tools/infer predict_rec.py #19

Open birchmi opened 2 years ago

birchmi commented 2 years ago

字符识别infer时,出现错误 ,det 和 cls是正常的 RuntimeError: Error(s) in loading state_dict for BaseModel: Missing key(s) in state_dict: "backbone.blocks.0.mid_se.conv1.weight", "backbone.blocks.0.mid_se.conv1.bias", "backbone.blocks.0.mid_se.conv2.weight", "backbone.blocks.0.mid_se.conv2.bias", "backbone.blocks.6.mid_se.conv1.weigh

frotms commented 2 years ago

@mijunhua 请发一下完整的命令或代码

birchmi commented 2 years ago

python ./tools/infer/predict_rec.py --image_dir ./doc/imgs/plate_1.jpg --rec_model_path ./pt_models/rec_models/rec_mv3_tps_bilstm_att_v2.0_infer.pth {'fc_decay': 4e-05, 'in_channels': 96} Traceback (most recent call last): File "./tools/infer/predict_rec.py", line 294, in main(utility.parse_args()) File "./tools/infer/predict_rec.py", line 263, in main text_recognizer = TextRecognizer(args) File "./tools/infer/predict_rec.py", line 64, in init self.load_state_dict(weights) File "D:\project\OCR\PaddleOCR2Pytorch\pytorchocr\base_ocr_v20.py", line 71, in load_state_dict self.net.load_state_dict(weights) File "D:\software\anaconda\envs\pysot\lib\site-packages\torch\nn\modules\module.py", line 1407, in load_state_dict self.class.name, "\n\t".join(error_msgs))) RuntimeError: Error(s) in loading state_dict for BaseModel: Missing key(s) in state_dict: "backbone.blocks.0.mid_se.conv1.weight", "backbone.blocks.0.mid_se.conv1.bias", "backbone.blocks.0.mid_se.conv2.weight", "backbone.blocks.0.mid_se.conv2.bias", "backbone.blocks.6.mid_se.conv1.weigh t", "backbone.blocks.6.mid_se.conv1.bias", "backbone.blocks.6.mid_se.conv2.weight", "backbone.blocks.6.mid_se.conv2.bias", "backbone.blocks.7.mid_se.conv1.weight", "backbone.blocks.7.mid_se.conv1.bias", "backbone.blocks.7.mid_se.conv2. weight", "backbone.blocks.7.mid_se.conv2.bias", "backbone.blocks.8.mid_se.conv1.weight", "backbone.blocks.8.mid_se.conv1.bias", "backbone.blocks.8.mid_se.conv2.weight", "backbone.blocks.8.mid_se.conv2.bias", "backbone.blocks.9.mid_se.c onv1.weight", "backbone.blocks.9.mid_se.conv1.bias", "backbone.blocks.9.mid_se.conv2.weight", "backbone.blocks.9.mid_se.conv2.bias", "head.fc.weight", "head.fc.bias". Unexpected key(s) in state_dict: "transform.loc_net.block_list.loc_conv0.conv.weight", "transform.loc_net.block_list.loc_conv0.bn.weight", "transform.loc_net.block_list.loc_conv0.bn.bias", "transform.loc_net.block_list.loc_conv 0.bn.running_mean", "transform.loc_net.block_list.loc_conv0.bn.running_var", "transform.loc_net.block_list.loc_conv0.bn.num_batches_tracked", "transform.loc_net.block_list.loc_conv1.conv.weight", "transform.loc_net.block_list.loc_conv1 .bn.weight", "transform.loc_net.block_list.loc_conv1.bn.bias", "transform.loc_net.block_list.loc_conv1.bn.running_mean", "transform.loc_net.block_list.loc_conv1.bn.running_var", "transform.loc_net.block_list.loc_conv1.bn.num_batches_tr acked", "transform.loc_net.block_list.loc_conv2.conv.weight", "transform.loc_net.block_list.loc_conv2.bn.weight", "transform.loc_net.block_list.loc_conv2.bn.bias", "transform.loc_net.block_list.loc_conv2.bn.running_mean", "transform.lo c_net.block_list.loc_conv2.bn.running_var", "transform.loc_net.block_list.loc_conv2.bn.num_batches_tracked", "transform.loc_net.block_list.loc_conv3.conv.weight", "transform.loc_net.block_list.loc_conv3.bn.weight", "transform.loc_net.b lock_list.loc_conv3.bn.bias", "transform.loc_net.block_list.loc_conv3.bn.running_mean", "transform.loc_net.block_list.loc_conv3.bn.running_var", "transform.loc_net.block_list.loc_conv3.bn.num_batches_tracked", "transform.loc_net.fc1.we ight", "transform.loc_net.fc1.bias", "transform.loc_net.fc2.weight", "transform.loc_net.fc2.bias", "transform.grid_generator.fc.weight", "transform.grid_generator.fc.bias", "backbone.blocks.11.expand_conv.conv.weight", "backbone.blocks .11.expand_conv.bn.weight", "backbone.blocks.11.expand_conv.bn.bias", "backbone.blocks.11.expand_conv.bn.running_mean", "backbone.blocks.11.expand_conv.bn.running_var", "backbone.blocks.11.expand_conv.bn.num_batches_tracked", "backbone .blocks.11.bottleneck_conv.conv.weight", "backbone.blocks.11.bottleneck_conv.bn.weight", "backbone.blocks.11.bottleneck_conv.bn.bias", "backbone.blocks.11.bottleneck_conv.bn.running_mean", "backbone.blocks.11.bottleneck_conv.bn.running _var", "backbone.blocks.11.bottleneck_conv.bn.num_batches_tracked", "backbone.blocks.11.mid_se.conv1.weight", "backbone.blocks.11.mid_se.conv1.bias", "backbone.blocks.11.mid_se.conv2.weight", "backbone.blocks.11.mid_se.conv2.bias", "ba ckbone.blocks.11.linear_conv.conv.weight", "backbone.blocks.11.linear_conv.bn.weight", "backbone.blocks.11.linear_conv.bn.bias", "backbone.blocks.11.linear_conv.bn.running_mean", "backbone.blocks.11.linear_conv.bn.running_var", "backbo ne.blocks.11.linear_conv.bn.num_batches_tracked", "backbone.blocks.12.expand_conv.conv.weight", "backbone.blocks.12.expand_conv.bn.weight", "backbone.blocks.12.expand_conv.bn.bias", "backbone.blocks.12.expand_conv.bn.running_mean", "ba ckbone.blocks.12.expand_conv.bn.running_var", "backbone.blocks.12.expand_conv.bn.num_batches_tracked", "backbone.blocks.12.bottleneck_conv.conv.weight", "backbone.blocks.12.bottleneck_conv.bn.weight", "backbone.blocks.12.bottleneck_con v.bn.bias", "backbone.blocks.12.bottleneck_conv.bn.running_mean", "backbone.blocks.12.bottleneck_conv.bn.running_var", "backbone.blocks.12.bottleneck_conv.bn.num_batches_tracked", "backbone.blocks.12.mid_se.conv1.weight", "backbone.blo cks.12.mid_se.conv1.bias", "backbone.blocks.12.mid_se.conv2.weight", "backbone.blocks.12.mid_se.conv2.bias", "backbone.blocks.12.linear_conv.conv.weight", "backbone.blocks.12.linear_conv.bn.weight", "backbone.blocks.12.linear_conv.bn.b ias", "backbone.blocks.12.linear_conv.bn.running_mean", "backbone.blocks.12.linear_conv.bn.running_var", "backbone.blocks.12.linear_conv.bn.num_batches_tracked", "backbone.blocks.13.expandconv.conv.weight", "backbone.blocks.13.expand conv.bn.weight", "backbone.blocks.13.expand_conv.bn.bias", "backbone.blocks.13.expand_conv.bn.running_mean", "backbone.blocks.13.expand_conv.bn.running_var", "backbone.blocks.13.expand_conv.bn.num_batches_tracked", "backbone.blocks.13. bottleneck_conv.conv.weight", "backbone.blocks.13.bottleneck_conv.bn.weight", "backbone.blocks.13.bottleneck_conv.bn.bias", "backbone.blocks.13.bottleneck_conv.bn.running_mean", "backbone.blocks.13.bottleneck_conv.bn.running_var", "bac kbone.blocks.13.bottleneck_conv.bn.num_batches_tracked", "backbone.blocks.13.mid_se.conv1.weight", "backbone.blocks.13.mid_se.conv1.bias", "backbone.blocks.13.mid_se.conv2.weight", "backbone.blocks.13.mid_se.conv2.bias", "backbone.bloc ks.13.linear_conv.conv.weight", "backbone.blocks.13.linear_conv.bn.weight", "backbone.blocks.13.linear_conv.bn.bias", "backbone.blocks.13.linear_conv.bn.running_mean", "backbone.blocks.13.linear_conv.bn.running_var", "backbone.blocks.1 3.linear_conv.bn.num_batches_tracked", "backbone.blocks.14.expand_conv.conv.weight", "backbone.blocks.14.expand_conv.bn.weight", "backbone.blocks.14.expand_conv.bn.bias", "backbone.blocks.14.expand_conv.bn.running_mean", "backbone.bloc ks.14.expand_conv.bn.running_var", "backbone.blocks.14.expand_conv.bn.num_batches_tracked", "backbone.blocks.14.bottleneck_conv.conv.weight", "backbone.blocks.14.bottleneck_conv.bn.weight", "backbone.blocks.14.bottleneck_conv.bn.bias", "backbone.blocks.14.bottleneck_conv.bn.running_mean", "backbone.blocks.14.bottleneck_conv.bn.running_var", "backbone.blocks.14.bottleneck_conv.bn.num_batches_tracked", "backbone.blocks.14.midse.conv1.weight", "backbone.blocks.14.mid se.conv1.bias", "backbone.blocks.14.mid_se.conv2.weight", "backbone.blocks.14.mid_se.conv2.bias", "backbone.blocks.14.linear_conv.conv.weight", "backbone.blocks.14.linear_conv.bn.weight", "backbone.blocks.14.linear_conv.bn.bias", "back bone.blocks.14.linear_conv.bn.running_mean", "backbone.blocks.14.linear_conv.bn.running_var", "backbone.blocks.14.linear_conv.bn.num_batches_tracked", "head.attention_cell.i2h.weight", "head.attentioncell.h2h.weight", "head.attention cell.h2h.bias", "head.attention_cell.score.weight", "head.attention_cell.rnn.weight_ih", "head.attention_cell.rnn.weight_hh", "head.attention_cell.rnn.bias_ih", "head.attention_cell.rnn.bias_hh", "head.generator.weight", "head.generato r.bias". size mismatch for backbone.blocks.1.expand_conv.conv.weight: copying a param with shape torch.Size([32, 8, 1, 1]) from checkpoint, the shape in current model is torch.Size([40, 8, 1, 1]). size mismatch for backbone.blocks.1.expand_conv.bn.weight: copying a param with shape torch.Size([32]) from checkpoint, the shape in current model is torch.Size([40]). size mismatch for backbone.blocks.1.expand_conv.bn.bias: copying a param with shape torch.Size([32]) from checkpoint, the shape in current model is torch.Size([40]). size mismatch for backbone.blocks.1.expand_conv.bn.running_mean: copying a param with shape torch.Size([32]) from checkpoint, the shape in current model is torch.Size([40]). size mismatch for backbone.blocks.1.expand_conv.bn.running_var: copying a param with shape torch.Size([32]) from checkpoint, the shape in current model is torch.Size([40]). size mismatch for backbone.blocks.1.bottleneck_conv.conv.weight: copying a param with shape torch.Size([32, 1, 3, 3]) from checkpoint, the shape in current model is torch.Size([40, 1, 3, 3]). size mismatch for backbone.blocks.1.bottleneck_conv.bn.weight: copying a param with shape torch.Size([32]) from checkpoint, the shape in current model is torch.Size([40]). size mismatch for backbone.blocks.1.bottleneck_conv.bn.bias: copying a param with shape torch.Size([32]) from checkpoint, the shape in current model is torch.Size([40]). size mismatch for backbone.blocks.1.bottleneck_conv.bn.running_mean: copying a param with shape torch.Size([32]) from checkpoint, the shape in current model is torch.Size([40]). size mismatch for backbone.blocks.1.bottleneck_conv.bn.running_var: copying a param with shape torch.Size([32]) from checkpoint, the shape in current model is torch.Size([40]). size mismatch for backbone.blocks.1.linear_conv.conv.weight: copying a param with shape torch.Size([16, 32, 1, 1]) from checkpoint, the shape in current model is torch.Size([16, 40, 1, 1]). size mismatch for backbone.blocks.2.expand_conv.conv.weight: copying a param with shape torch.Size([40, 16, 1, 1]) from checkpoint, the shape in current model is torch.Size([48, 16, 1, 1]). size mismatch for backbone.blocks.2.expand_conv.bn.weight: copying a param with shape torch.Size([40]) from checkpoint, the shape in current model is torch.Size([48]). size mismatch for backbone.blocks.2.expand_conv.bn.bias: copying a param with shape torch.Size([40]) from checkpoint, the shape in current model is torch.Size([48]). size mismatch for backbone.blocks.2.expand_conv.bn.running_mean: copying a param with shape torch.Size([40]) from checkpoint, the shape in current model is torch.Size([48]). size mismatch for backbone.blocks.2.expand_conv.bn.running_var: copying a param with shape torch.Size([40]) from checkpoint, the shape in current model is torch.Size([48]). size mismatch for backbone.blocks.2.bottleneck_conv.conv.weight: copying a param with shape torch.Size([40, 1, 3, 3]) from checkpoint, the shape in current model is torch.Size([48, 1, 3, 3]). size mismatch for backbone.blocks.2.bottleneck_conv.bn.weight: copying a param with shape torch.Size([40]) from checkpoint, the shape in current model is torch.Size([48]). size mismatch for backbone.blocks.2.bottleneck_conv.bn.bias: copying a param with shape torch.Size([40]) from checkpoint, the shape in current model is torch.Size([48]). size mismatch for backbone.blocks.2.bottleneck_conv.bn.running_mean: copying a param with shape torch.Size([40]) from checkpoint, the shape in current model is torch.Size([48]). size mismatch for backbone.blocks.2.bottleneck_conv.bn.running_var: copying a param with shape torch.Size([40]) from checkpoint, the shape in current model is torch.Size([48]). size mismatch for backbone.blocks.2.linear_conv.conv.weight: copying a param with shape torch.Size([16, 40, 1, 1]) from checkpoint, the shape in current model is torch.Size([16, 48, 1, 1]). size mismatch for backbone.blocks.3.expand_conv.conv.weight: copying a param with shape torch.Size([40, 16, 1, 1]) from checkpoint, the shape in current model is torch.Size([48, 16, 1, 1]). size mismatch for backbone.blocks.3.expand_conv.bn.weight: copying a param with shape torch.Size([40]) from checkpoint, the shape in current model is torch.Size([48]). size mismatch for backbone.blocks.3.expand_conv.bn.bias: copying a param with shape torch.Size([40]) from checkpoint, the shape in current model is torch.Size([48]). size mismatch for backbone.blocks.3.expand_conv.bn.running_mean: copying a param with shape torch.Size([40]) from checkpoint, the shape in current model is torch.Size([48]). size mismatch for backbone.blocks.3.expand_conv.bn.running_var: copying a param with shape torch.Size([40]) from checkpoint, the shape in current model is torch.Size([48]). size mismatch for backbone.blocks.3.bottleneck_conv.conv.weight: copying a param with shape torch.Size([40, 1, 5, 5]) from checkpoint, the shape in current model is torch.Size([48, 1, 5, 5]). size mismatch for backbone.blocks.3.bottleneck_conv.bn.weight: copying a param with shape torch.Size([40]) from checkpoint, the shape in current model is torch.Size([48]). size mismatch for backbone.blocks.3.bottleneck_conv.bn.bias: copying a param with shape torch.Size([40]) from checkpoint, the shape in current model is torch.Size([48]). size mismatch for backbone.blocks.3.bottleneck_conv.bn.running_mean: copying a param with shape torch.Size([40]) from checkpoint, the shape in current model is torch.Size([48]). size mismatch for backbone.blocks.3.bottleneck_conv.bn.running_var: copying a param with shape torch.Size([40]) from checkpoint, the shape in current model is torch.Size([48]). size mismatch for backbone.blocks.3.mid_se.conv1.weight: copying a param with shape torch.Size([10, 40, 1, 1]) from checkpoint, the shape in current model is torch.Size([12, 48, 1, 1]). size mismatch for backbone.blocks.3.mid_se.conv1.bias: copying a param with shape torch.Size([10]) from checkpoint, the shape in current model is torch.Size([12]). size mismatch for backbone.blocks.3.mid_se.conv2.weight: copying a param with shape torch.Size([40, 10, 1, 1]) from checkpoint, the shape in current model is torch.Size([48, 12, 1, 1]). size mismatch for backbone.blocks.3.mid_se.conv2.bias: copying a param with shape torch.Size([40]) from checkpoint, the shape in current model is torch.Size([48]). size mismatch for backbone.blocks.3.linear_conv.conv.weight: copying a param with shape torch.Size([24, 40, 1, 1]) from checkpoint, the shape in current model is torch.Size([24, 48, 1, 1]). size mismatch for backbone.blocks.4.expand_conv.conv.weight: copying a param with shape torch.Size([64, 24, 1, 1]) from checkpoint, the shape in current model is torch.Size([120, 24, 1, 1]). size mismatch for backbone.blocks.4.expand_conv.bn.weight: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([120]). size mismatch for backbone.blocks.4.expand_conv.bn.bias: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([120]). size mismatch for backbone.blocks.4.expand_conv.bn.running_mean: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([120]). size mismatch for backbone.blocks.4.expand_conv.bn.running_var: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([120]). size mismatch for backbone.blocks.4.bottleneck_conv.conv.weight: copying a param with shape torch.Size([64, 1, 5, 5]) from checkpoint, the shape in current model is torch.Size([120, 1, 5, 5]). size mismatch for backbone.blocks.4.bottleneck_conv.bn.weight: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([120]). size mismatch for backbone.blocks.4.bottleneck_conv.bn.bias: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([120]). size mismatch for backbone.blocks.4.bottleneck_conv.bn.running_mean: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([120]). size mismatch for backbone.blocks.4.bottleneck_conv.bn.running_var: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([120]). size mismatch for backbone.blocks.4.mid_se.conv1.weight: copying a param with shape torch.Size([16, 64, 1, 1]) from checkpoint, the shape in current model is torch.Size([30, 120, 1, 1]). size mismatch for backbone.blocks.4.mid_se.conv1.bias: copying a param with shape torch.Size([16]) from checkpoint, the shape in current model is torch.Size([30]). size mismatch for backbone.blocks.4.mid_se.conv2.weight: copying a param with shape torch.Size([64, 16, 1, 1]) from checkpoint, the shape in current model is torch.Size([120, 30, 1, 1]). size mismatch for backbone.blocks.4.mid_se.conv2.bias: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([120]). size mismatch for backbone.blocks.4.linear_conv.conv.weight: copying a param with shape torch.Size([24, 64, 1, 1]) from checkpoint, the shape in current model is torch.Size([24, 120, 1, 1]). size mismatch for backbone.blocks.5.expand_conv.conv.weight: copying a param with shape torch.Size([64, 24, 1, 1]) from checkpoint, the shape in current model is torch.Size([120, 24, 1, 1]). size mismatch for backbone.blocks.5.expand_conv.bn.weight: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([120]). size mismatch for backbone.blocks.5.expand_conv.bn.bias: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([120]). size mismatch for backbone.blocks.5.expand_conv.bn.running_mean: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([120]). size mismatch for backbone.blocks.5.expand_conv.bn.running_var: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([120]). size mismatch for backbone.blocks.5.bottleneck_conv.conv.weight: copying a param with shape torch.Size([64, 1, 5, 5]) from checkpoint, the shape in current model is torch.Size([120, 1, 5, 5]). size mismatch for backbone.blocks.5.bottleneck_conv.bn.weight: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([120]). size mismatch for backbone.blocks.5.bottleneck_conv.bn.bias: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([120]). size mismatch for backbone.blocks.5.bottleneck_conv.bn.running_mean: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([120]). size mismatch for backbone.blocks.5.bottleneck_conv.bn.running_var: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([120]). size mismatch for backbone.blocks.5.mid_se.conv1.weight: copying a param with shape torch.Size([16, 64, 1, 1]) from checkpoint, the shape in current model is torch.Size([30, 120, 1, 1]). size mismatch for backbone.blocks.5.mid_se.conv1.bias: copying a param with shape torch.Size([16]) from checkpoint, the shape in current model is torch.Size([30]). size mismatch for backbone.blocks.5.mid_se.conv2.weight: copying a param with shape torch.Size([64, 16, 1, 1]) from checkpoint, the shape in current model is torch.Size([120, 30, 1, 1]). size mismatch for backbone.blocks.5.mid_se.conv2.bias: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([120]). size mismatch for backbone.blocks.5.linear_conv.conv.weight: copying a param with shape torch.Size([24, 64, 1, 1]) from checkpoint, the shape in current model is torch.Size([24, 120, 1, 1]). size mismatch for backbone.blocks.6.expand_conv.conv.weight: copying a param with shape torch.Size([120, 24, 1, 1]) from checkpoint, the shape in current model is torch.Size([64, 24, 1, 1]). size mismatch for backbone.blocks.6.expand_conv.bn.weight: copying a param with shape torch.Size([120]) from checkpoint, the shape in current model is torch.Size([64]). size mismatch for backbone.blocks.6.expand_conv.bn.bias: copying a param with shape torch.Size([120]) from checkpoint, the shape in current model is torch.Size([64]). size mismatch for backbone.blocks.6.expand_conv.bn.running_mean: copying a param with shape torch.Size([120]) from checkpoint, the shape in current model is torch.Size([64]). size mismatch for backbone.blocks.6.expand_conv.bn.running_var: copying a param with shape torch.Size([120]) from checkpoint, the shape in current model is torch.Size([64]). size mismatch for backbone.blocks.6.bottleneck_conv.conv.weight: copying a param with shape torch.Size([120, 1, 3, 3]) from checkpoint, the shape in current model is torch.Size([64, 1, 5, 5]). size mismatch for backbone.blocks.6.bottleneck_conv.bn.weight: copying a param with shape torch.Size([120]) from checkpoint, the shape in current model is torch.Size([64]). size mismatch for backbone.blocks.6.bottleneck_conv.bn.bias: copying a param with shape torch.Size([120]) from checkpoint, the shape in current model is torch.Size([64]). size mismatch for backbone.blocks.6.bottleneck_conv.bn.running_mean: copying a param with shape torch.Size([120]) from checkpoint, the shape in current model is torch.Size([64]). size mismatch for backbone.blocks.6.bottleneck_conv.bn.running_var: copying a param with shape torch.Size([120]) from checkpoint, the shape in current model is torch.Size([64]). size mismatch for backbone.blocks.6.linear_conv.conv.weight: copying a param with shape torch.Size([40, 120, 1, 1]) from checkpoint, the shape in current model is torch.Size([24, 64, 1, 1]). size mismatch for backbone.blocks.6.linear_conv.bn.weight: copying a param with shape torch.Size([40]) from checkpoint, the shape in current model is torch.Size([24]). size mismatch for backbone.blocks.6.linear_conv.bn.bias: copying a param with shape torch.Size([40]) from checkpoint, the shape in current model is torch.Size([24]). size mismatch for backbone.blocks.6.linear_conv.bn.running_mean: copying a param with shape torch.Size([40]) from checkpoint, the shape in current model is torch.Size([24]). size mismatch for backbone.blocks.6.linear_conv.bn.running_var: copying a param with shape torch.Size([40]) from checkpoint, the shape in current model is torch.Size([24]). size mismatch for backbone.blocks.7.expand_conv.conv.weight: copying a param with shape torch.Size([104, 40, 1, 1]) from checkpoint, the shape in current model is torch.Size([72, 24, 1, 1]). size mismatch for backbone.blocks.7.expand_conv.bn.weight: copying a param with shape torch.Size([104]) from checkpoint, the shape in current model is torch.Size([72]). size mismatch for backbone.blocks.7.expand_conv.bn.bias: copying a param with shape torch.Size([104]) from checkpoint, the shape in current model is torch.Size([72]). size mismatch for backbone.blocks.7.expand_conv.bn.running_mean: copying a param with shape torch.Size([104]) from checkpoint, the shape in current model is torch.Size([72]). size mismatch for backbone.blocks.7.expand_conv.bn.running_var: copying a param with shape torch.Size([104]) from checkpoint, the shape in current model is torch.Size([72]). size mismatch for backbone.blocks.7.bottleneck_conv.conv.weight: copying a param with shape torch.Size([104, 1, 3, 3]) from checkpoint, the shape in current model is torch.Size([72, 1, 5, 5]). size mismatch for backbone.blocks.7.bottleneck_conv.bn.weight: copying a param with shape torch.Size([104]) from checkpoint, the shape in current model is torch.Size([72]). size mismatch for backbone.blocks.7.bottleneck_conv.bn.bias: copying a param with shape torch.Size([104]) from checkpoint, the shape in current model is torch.Size([72]). size mismatch for backbone.blocks.7.bottleneck_conv.bn.running_mean: copying a param with shape torch.Size([104]) from checkpoint, the shape in current model is torch.Size([72]). size mismatch for backbone.blocks.7.bottleneck_conv.bn.running_var: copying a param with shape torch.Size([104]) from checkpoint, the shape in current model is torch.Size([72]). size mismatch for backbone.blocks.7.linear_conv.conv.weight: copying a param with shape torch.Size([40, 104, 1, 1]) from checkpoint, the shape in current model is torch.Size([24, 72, 1, 1]). size mismatch for backbone.blocks.7.linear_conv.bn.weight: copying a param with shape torch.Size([40]) from checkpoint, the shape in current model is torch.Size([24]). size mismatch for backbone.blocks.7.linear_conv.bn.bias: copying a param with shape torch.Size([40]) from checkpoint, the shape in current model is torch.Size([24]). size mismatch for backbone.blocks.7.linear_conv.bn.running_mean: copying a param with shape torch.Size([40]) from checkpoint, the shape in current model is torch.Size([24]). size mismatch for backbone.blocks.7.linear_conv.bn.running_var: copying a param with shape torch.Size([40]) from checkpoint, the shape in current model is torch.Size([24]). size mismatch for backbone.blocks.8.expand_conv.conv.weight: copying a param with shape torch.Size([96, 40, 1, 1]) from checkpoint, the shape in current model is torch.Size([144, 24, 1, 1]). size mismatch for backbone.blocks.8.expand_conv.bn.weight: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([144]). size mismatch for backbone.blocks.8.expand_conv.bn.bias: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([144]). size mismatch for backbone.blocks.8.expand_conv.bn.running_mean: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([144]). size mismatch for backbone.blocks.8.expand_conv.bn.running_var: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([144]). size mismatch for backbone.blocks.8.bottleneck_conv.conv.weight: copying a param with shape torch.Size([96, 1, 3, 3]) from checkpoint, the shape in current model is torch.Size([144, 1, 5, 5]). size mismatch for backbone.blocks.8.bottleneck_conv.bn.weight: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([144]). size mismatch for backbone.blocks.8.bottleneck_conv.bn.bias: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([144]). size mismatch for backbone.blocks.8.bottleneck_conv.bn.running_mean: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([144]). size mismatch for backbone.blocks.8.bottleneck_conv.bn.running_var: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([144]). size mismatch for backbone.blocks.8.linear_conv.conv.weight: copying a param with shape torch.Size([40, 96, 1, 1]) from checkpoint, the shape in current model is torch.Size([48, 144, 1, 1]). size mismatch for backbone.blocks.8.linear_conv.bn.weight: copying a param with shape torch.Size([40]) from checkpoint, the shape in current model is torch.Size([48]). size mismatch for backbone.blocks.8.linear_conv.bn.bias: copying a param with shape torch.Size([40]) from checkpoint, the shape in current model is torch.Size([48]). size mismatch for backbone.blocks.8.linear_conv.bn.running_mean: copying a param with shape torch.Size([40]) from checkpoint, the shape in current model is torch.Size([48]). size mismatch for backbone.blocks.8.linear_conv.bn.running_var: copying a param with shape torch.Size([40]) from checkpoint, the shape in current model is torch.Size([48]). size mismatch for backbone.blocks.9.expand_conv.conv.weight: copying a param with shape torch.Size([96, 40, 1, 1]) from checkpoint, the shape in current model is torch.Size([288, 48, 1, 1]). size mismatch for backbone.blocks.9.expand_conv.bn.weight: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([288]). size mismatch for backbone.blocks.9.expand_conv.bn.bias: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([288]). size mismatch for backbone.blocks.9.expand_conv.bn.running_mean: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([288]). size mismatch for backbone.blocks.9.expand_conv.bn.running_var: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([288]). size mismatch for backbone.blocks.9.bottleneck_conv.conv.weight: copying a param with shape torch.Size([96, 1, 3, 3]) from checkpoint, the shape in current model is torch.Size([288, 1, 5, 5]). size mismatch for backbone.blocks.9.bottleneck_conv.bn.weight: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([288]). size mismatch for backbone.blocks.9.bottleneck_conv.bn.bias: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([288]). size mismatch for backbone.blocks.9.bottleneck_conv.bn.running_mean: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([288]). size mismatch for backbone.blocks.9.bottleneck_conv.bn.running_var: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([288]). size mismatch for backbone.blocks.9.linear_conv.conv.weight: copying a param with shape torch.Size([40, 96, 1, 1]) from checkpoint, the shape in current model is torch.Size([48, 288, 1, 1]). size mismatch for backbone.blocks.9.linear_conv.bn.weight: copying a param with shape torch.Size([40]) from checkpoint, the shape in current model is torch.Size([48]). size mismatch for backbone.blocks.9.linear_conv.bn.bias: copying a param with shape torch.Size([40]) from checkpoint, the shape in current model is torch.Size([48]). size mismatch for backbone.blocks.9.linear_conv.bn.running_mean: copying a param with shape torch.Size([40]) from checkpoint, the shape in current model is torch.Size([48]). size mismatch for backbone.blocks.9.linear_conv.bn.running_var: copying a param with shape torch.Size([40]) from checkpoint, the shape in current model is torch.Size([48]). size mismatch for backbone.blocks.10.expand_conv.conv.weight: copying a param with shape torch.Size([240, 40, 1, 1]) from checkpoint, the shape in current model is torch.Size([288, 48, 1, 1]). size mismatch for backbone.blocks.10.expand_conv.bn.weight: copying a param with shape torch.Size([240]) from checkpoint, the shape in current model is torch.Size([288]). size mismatch for backbone.blocks.10.expand_conv.bn.bias: copying a param with shape torch.Size([240]) from checkpoint, the shape in current model is torch.Size([288]). size mismatch for backbone.blocks.10.expand_conv.bn.running_mean: copying a param with shape torch.Size([240]) from checkpoint, the shape in current model is torch.Size([288]). size mismatch for backbone.blocks.10.expand_conv.bn.running_var: copying a param with shape torch.Size([240]) from checkpoint, the shape in current model is torch.Size([288]). size mismatch for backbone.blocks.10.bottleneck_conv.conv.weight: copying a param with shape torch.Size([240, 1, 3, 3]) from checkpoint, the shape in current model is torch.Size([288, 1, 5, 5]). size mismatch for backbone.blocks.10.bottleneck_conv.bn.weight: copying a param with shape torch.Size([240]) from checkpoint, the shape in current model is torch.Size([288]). size mismatch for backbone.blocks.10.bottleneck_conv.bn.bias: copying a param with shape torch.Size([240]) from checkpoint, the shape in current model is torch.Size([288]). size mismatch for backbone.blocks.10.bottleneck_conv.bn.running_mean: copying a param with shape torch.Size([240]) from checkpoint, the shape in current model is torch.Size([288]). size mismatch for backbone.blocks.10.bottleneck_conv.bn.running_var: copying a param with shape torch.Size([240]) from checkpoint, the shape in current model is torch.Size([288]). size mismatch for backbone.blocks.10.mid_se.conv1.weight: copying a param with shape torch.Size([60, 240, 1, 1]) from checkpoint, the shape in current model is torch.Size([72, 288, 1, 1]). size mismatch for backbone.blocks.10.mid_se.conv1.bias: copying a param with shape torch.Size([60]) from checkpoint, the shape in current model is torch.Size([72]). size mismatch for backbone.blocks.10.mid_se.conv2.weight: copying a param with shape torch.Size([240, 60, 1, 1]) from checkpoint, the shape in current model is torch.Size([288, 72, 1, 1]). size mismatch for backbone.blocks.10.mid_se.conv2.bias: copying a param with shape torch.Size([240]) from checkpoint, the shape in current model is torch.Size([288]). size mismatch for backbone.blocks.10.linear_conv.conv.weight: copying a param with shape torch.Size([56, 240, 1, 1]) from checkpoint, the shape in current model is torch.Size([48, 288, 1, 1]). size mismatch for backbone.blocks.10.linear_conv.bn.weight: copying a param with shape torch.Size([56]) from checkpoint, the shape in current model is torch.Size([48]). size mismatch for backbone.blocks.10.linear_conv.bn.bias: copying a param with shape torch.Size([56]) from checkpoint, the shape in current model is torch.Size([48]). size mismatch for backbone.blocks.10.linear_conv.bn.running_mean: copying a param with shape torch.Size([56]) from checkpoint, the shape in current model is torch.Size([48]). size mismatch for backbone.blocks.10.linear_conv.bn.running_var: copying a param with shape torch.Size([56]) from checkpoint, the shape in current model is torch.Size([48]). size mismatch for backbone.conv2.conv.weight: copying a param with shape torch.Size([480, 80, 1, 1]) from checkpoint, the shape in current model is torch.Size([288, 48, 1, 1]). size mismatch for backbone.conv2.bn.weight: copying a param with shape torch.Size([480]) from checkpoint, the shape in current model is torch.Size([288]). size mismatch for backbone.conv2.bn.bias: copying a param with shape torch.Size([480]) from checkpoint, the shape in current model is torch.Size([288]). size mismatch for backbone.conv2.bn.running_mean: copying a param with shape torch.Size([480]) from checkpoint, the shape in current model is torch.Size([288]). size mismatch for backbone.conv2.bn.running_var: copying a param with shape torch.Size([480]) from checkpoint, the shape in current model is torch.Size([288]). size mismatch for neck.encoder.lstm.weight_ih_l0: copying a param with shape torch.Size([384, 480]) from checkpoint, the shape in current model is torch.Size([192, 288]). size mismatch for neck.encoder.lstm.weight_hh_l0: copying a param with shape torch.Size([384, 96]) from checkpoint, the shape in current model is torch.Size([192, 48]). size mismatch for neck.encoder.lstm.bias_ih_l0: copying a param with shape torch.Size([384]) from checkpoint, the shape in current model is torch.Size([192]). size mismatch for neck.encoder.lstm.bias_hh_l0: copying a param with shape torch.Size([384]) from checkpoint, the shape in current model is torch.Size([192]). size mismatch for neck.encoder.lstm.weight_ih_l0_reverse: copying a param with shape torch.Size([384, 480]) from checkpoint, the shape in current model is torch.Size([192, 288]). size mismatch for neck.encoder.lstm.weight_hh_l0_reverse: copying a param with shape torch.Size([384, 96]) from checkpoint, the shape in current model is torch.Size([192, 48]). size mismatch for neck.encoder.lstm.bias_ih_l0_reverse: copying a param with shape torch.Size([384]) from checkpoint, the shape in current model is torch.Size([192]). size mismatch for neck.encoder.lstm.bias_hh_l0_reverse: copying a param with shape torch.Size([384]) from checkpoint, the shape in current model is torch.Size([192]). size mismatch for neck.encoder.lstm.weight_ih_l1: copying a param with shape torch.Size([384, 192]) from checkpoint, the shape in current model is torch.Size([192, 96]). size mismatch for neck.encoder.lstm.weight_hh_l1: copying a param with shape torch.Size([384, 96]) from checkpoint, the shape in current model is torch.Size([192, 48]). size mismatch for neck.encoder.lstm.bias_ih_l1: copying a param with shape torch.Size([384]) from checkpoint, the shape in current model is torch.Size([192]). size mismatch for neck.encoder.lstm.bias_ih_l0_reverse: copying a param with shape torch.Size([384]) from checkpo int, the shape in current model is torch.Size([192]). size mismatch for neck.encoder.lstm.bias_hh_l0_reverse: copying a param with shape torch.Size([384]) from checkpo int, the shape in current model is torch.Size([192]). size mismatch for neck.encoder.lstm.weight_ih_l1: copying a param with shape torch.Size([384, 192]) from checkpoi nt, the shape in current model is torch.Size([192, 96]). size mismatch for neck.encoder.lstm.weight_hh_l1: copying a param with shape torch.Size([384, 96]) from checkpoin t, the shape in current model is torch.Size([192, 48]). size mismatch for neck.encoder.lstm.bias_ih_l1: copying a param with shape torch.Size([384]) from checkpoint, the shape in current model is torch.Size([192]). size mismatch for neck.encoder.lstm.bias_hh_l1: copying a param with shape torch.Size([384]) from checkpoint, the shape in current model is torch.Size([192]). size mismatch for neck.encoder.lstm.weight_ih_l1_reverse: copying a param with shape torch.Size([384, 192]) from checkpoint, the shape in current model is torch.Size([192, 96]). size mismatch for neck.encoder.lstm.weight_hh_l1_reverse: copying a param with shape torch.Size([384, 96]) from checkpoint, the shape in current model is torch.Size([192, 48]). size mismatch for neck.encoder.lstm.bias_ih_l1_reverse: copying a param with shape torch.Size([384]) from checkpoint, the shape in current model is torch.Size([192]). size mismatch for neck.encoder.lstm.bias_ih_l1_reverse: copying a param with shape torch.Size([384]) from checkpo size mismatch for neck.encoder.lstm.bias_hh_l1_reverse: copying a param with shape torch.Size([384]) from checkpoint, the shape in current model is torch.Size([192]).

frotms commented 2 years ago

@mijunhua 使用RARE模型的话,试试下面的命令

python ./tools/infer/predict_rec.py --rec_model_path ./pt_models/rec_models/rec_mv3_tps_bilstm_att_v2.0_infer.pth --image_dir ./doc/imgs/plate_1.jpg --rec_image_shape 3,32,100 --rec_char_type en --rec_algorithm RARE --rec_yaml_path ./configs/rec/rec_mv3_tps_bilstm_att.yml

mxz2013 commented 1 year ago

@frotms I am having a similar error when I run python ./tools/infer/predict_rec.py --rec_model_path /Users/sky/Documents/work_dataset_realestate/work_paddle_OCR/PyTorch_models/from_paul/ch_ptocr_v3_rec_infer.pth --image_dir /Users/sky/Documents/work_dataset_realestate/work_paddle_OCR/test_images/word_4.jpg --rec_image_shape 3,46,225 --rec_yaml_path /Users/sky/Documents/work_dataset_realestate/work_paddle_OCR/PaddleOCR2Pytorch/configs/rec/PP-OCRv3/ch_PP-OCRv3_rec.yml

The error I got is: Traceback (most recent call last): File "/Users/sky/Documents/work_dataset_realestate/work_paddle_OCR/PaddleOCR2Pytorch/./tools/infer/predict_rec.py", line 464, in main(utility.parse_args()) File "/Users/sky/Documents/work_dataset_realestate/work_paddle_OCR/PaddleOCR2Pytorch/./tools/infer/predict_rec.py", line 438, in main text_recognizer = TextRecognizer(args) File "/Users/sky/Documents/work_dataset_realestate/work_paddle_OCR/PaddleOCR2Pytorch/./tools/infer/predict_rec.py", line 83, in init self.out_channels = self.get_out_channels(weights) File "/Users/sky/Documents/work_dataset_realestate/work_paddle_OCR/PaddleOCR2Pytorch/pytorchocr/base_ocr_v20.py", line 71, in get_out_channels out_channels = list(weights.values())[-1].numpy().shape[0]

If I manually change the out_channels to " out_channels = list(weights.values())[-2].numpy().shape[0]". I get another error that reads: raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format( RuntimeError: Error(s) in loading state_dict for BaseModel: Missing key(s) in state_dict: "neck.encoder.conv1.conv.weight", "neck.encoder.conv1.norm.weight", "neck.encoder.conv1.norm.bias", "neck.encoder.conv1.norm.running_mean", "neck.encoder.conv1.norm.running_var", "neck.encoder.conv2.conv.weight", "neck.encoder.conv2.norm.weight", "neck.encoder.conv2.norm.bias", "neck.encoder.conv2.norm.running_mean", "neck.encoder.conv2.norm.running_var", "neck.encoder.svtr_block.0.norm1.weight", "neck.encoder.svtr_block.0.norm1.bias", "neck.encoder.svtr_block.0.mixer.qkv.weight", "neck.encoder.svtr_block.0.mixer.qkv.bias", "neck.encoder.svtr_block.0.mixer.proj.weight", "neck.encoder.svtr_block.0.mixer.proj.bias", "neck.encoder.svtr_block.0.norm2.weight", "neck.encoder.svtr_block.0.norm2.bias", "neck.encoder.svtr_block.0.mlp.fc1.weight", "neck.encoder.svtr_block.0.mlp.fc1.bias", "neck.encoder.svtr_block.0.mlp.fc2.weight", "neck.encoder.svtr_block.0.mlp.fc2.bias", "neck.encoder.svtr_block.1.norm1.weight", "neck.encoder.svtr_block.1.norm1.bias", "neck.encoder.svtr_block.1.mixer.qkv.weight", "neck.encoder.svtr_block.1.mixer.qkv.bias", "neck.encoder.svtr_block.1.mixer.proj.weight", "neck.encoder.svtr_block.1.mixer.proj.bias", "neck.encoder.svtr_block.1.norm2.weight", "neck.encoder.svtr_block.1.norm2.bias", "neck.encoder.svtr_block.1.mlp.fc1.weight", "neck.encoder.svtr_block.1.mlp.fc1.bias", "neck.encoder.svtr_block.1.mlp.fc2.weight", "neck.encoder.svtr_block.1.mlp.fc2.bias", "neck.encoder.norm.weight", "neck.encoder.norm.bias", "neck.encoder.conv3.conv.weight", "neck.encoder.conv3.norm.weight", "neck.encoder.conv3.norm.bias", "neck.encoder.conv3.norm.running_mean", "neck.encoder.conv3.norm.running_var", "neck.encoder.conv4.conv.weight", "neck.encoder.conv4.norm.weight", "neck.encoder.conv4.norm.bias", "neck.encoder.conv4.norm.running_mean", "neck.encoder.conv4.norm.running_var", "neck.encoder.conv1x1.conv.weight", "neck.encoder.conv1x1.norm.weight", "neck.encoder.conv1x1.norm.bias", "neck.encoder.conv1x1.norm.running_mean", "neck.encoder.conv1x1.norm.running_var". Unexpected key(s) in state_dict: "neck.conv1.conv.weight", "neck.conv1.bn.weight", "neck.conv1.bn.bias", "neck.conv1.bn.running_mean", "neck.conv1.bn.running_var", "neck.conv1.bn.num_batches_tracked", "neck.conv2.conv.weight", "neck.conv2.bn.weight", "neck.conv2.bn.bias", "neck.conv2.bn.running_mean", "neck.conv2.bn.running_var", "neck.conv2.bn.num_batches_tracked", "neck.svtr_block.0.norm1.weight", "neck.svtr_block.0.norm1.bias", "neck.svtr_block.0.mixer.qkv.weight", "neck.svtr_block.0.mixer.qkv.bias", "neck.svtr_block.0.mixer.proj.weight", "neck.svtr_block.0.mixer.proj.bias", "neck.svtr_block.0.norm2.weight", "neck.svtr_block.0.norm2.bias", "neck.svtr_block.0.mlp.fc1.weight", "neck.svtr_block.0.mlp.fc1.bias", "neck.svtr_block.0.mlp.fc2.weight", "neck.svtr_block.0.mlp.fc2.bias", "neck.svtr_block.1.norm1.weight", "neck.svtr_block.1.norm1.bias", "neck.svtr_block.1.mixer.qkv.weight", "neck.svtr_block.1.mixer.qkv.bias", "neck.svtr_block.1.mixer.proj.weight", "neck.svtr_block.1.mixer.proj.bias", "neck.svtr_block.1.norm2.weight", "neck.svtr_block.1.norm2.bias", "neck.svtr_block.1.mlp.fc1.weight", "neck.svtr_block.1.mlp.fc1.bias", "neck.svtr_block.1.mlp.fc2.weight", "neck.svtr_block.1.mlp.fc2.bias", "neck.norm.weight", "neck.norm.bias", "neck.conv3.conv.weight", "neck.conv3.bn.weight", "neck.conv3.bn.bias", "neck.conv3.bn.running_mean", "neck.conv3.bn.running_var", "neck.conv3.bn.num_batches_tracked", "neck.conv4.conv.weight", "neck.conv4.bn.weight", "neck.conv4.bn.bias", "neck.conv4.bn.running_mean", "neck.conv4.bn.running_var", "neck.conv4.bn.num_batches_tracked", "neck.conv1x1.conv.weight", "neck.conv1x1.bn.weight", "neck.conv1x1.bn.bias", "neck.conv1x1.bn.running_mean", "neck.conv1x1.bn.running_var", "neck.conv1x1.bn.num_batches_tracked". size mismatch for head.fc.weight: copying a param with shape torch.Size([6625, 64]) from checkpoint, the shape in current model is torch.Size([512, 64]). size mismatch for head.fc.bias: copying a param with shape torch.Size([6625]) from checkpoint, the shape in current model is torch.Size([512]).

Can you help?