Size mismatch when loading CRNN weights in OCR model #1757
Replies: 1 comment
-
I have found the answared because vocab when i training, if any body have some issue refer to this solution link: #1109 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi everyone,
I'm currently working on an OCR project using Doctr, and I encountered a size mismatch error when loading the weights for a CRNN model. Below is the relevant part of my code:
reco_model = crnn_vgg16_bn(pretrained=False, pretrained_backbone=False) reco_params = torch.load('/path/to/crnn_vgg16_bn_20241023-163747.pt', map_location="cpu") reco_model.load_state_dict(reco_params)
When I run the code, I get the following error:
RuntimeError: Error(s) in loading state_dict for CRNN: size mismatch for linear.weight: copying a param with shape torch.Size([127, 256]) from checkpoint, the shape in current model is torch.Size([124, 256]). size mismatch for linear.bias: copying a param with shape torch.Size([127]) from checkpoint, the shape in current model is torch.Size([124]).
It seems like there’s a size mismatch in the linear.weight and linear.bias layers when loading the checkpoint. I’m not sure why this is happening, as I expected the checkpoint to be compatible with the current model.
Does anyone have suggestions on how to resolve this size mismatch or insights into why this might be happening?
Beta Was this translation helpful? Give feedback.
All reactions