georgeretsi / defHTR

Deformation-invariant line-level Handwritten Text Recognition (HTR) using a convolutional-only architecture.
MIT License
7 stars 2 forks source link

How to use the cnn_df.pt #2

Open MaSinless opened 1 year ago

MaSinless commented 1 year ago

Thanks so much for the paper and repo. I encountered some errors when using cnn_df.pt model, could you please tell me how to load this file? image image

georgeretsi commented 1 year ago

Greetings! Can you please provide the whole error description. Probably is a size missmatch of tensors.

MaSinless commented 1 year ago

Thanks for your reply, the following is the whole error description. net.load_state_dict(torch.load('cnn_df.pt')) File "D:\Program Files\anaconda3\envs\pytorch-gpu-1.11\lib\site-packages\torch\nn\modules\module.py", line 1497, in load_state_dict raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format( RuntimeError: Error(s) in loading state_dict for HTRNetC: Unexpected key(s) in state_dict: "features.features.cnv1.stn.cnn.0.weight", "features.features.cnv1.stn.cnn.0.bias", "features.features.cnv1.stn.last.weight", "features.features.cnv1.stn.last.bias", "features.features.cnv2.stn.cnn.0.weight", "features.features.cnv2.stn.cnn.0.bias", "features.features.cnv2.stn.last.weight", "features.features.cnv2.stn.last.bias", "features.features.cnv3.stn.cnn.0.weight", "features.features.cnv3.stn.cnn.0.bias", "features.features.cnv3.stn.last.weight", "features.features.cnv3.stn.last.bias", "features.features.cnv4.stn.cnn.0.weight", "features.features.cnv4.stn.cnn.0.bias", "features.features.cnv4.stn.last.weight", "features.features.cnv4.stn.last.bias", "features.features.cnv5.stn.cnn.0.weight", "features.features.cnv5.stn.cnn.0.bias", "features.features.cnv5.stn.last.weight", "features.features.cnv5.stn.last.bias", "features.features.cnv6.stn.cnn.0.weight", "features.features.cnv6.stn.cnn.0.bias", "features.features.cnv6.stn.last.weight", "features.features.cnv6.stn.last.bias", "features.features.cnv7.stn.cnn.0.weight", "features.features.cnv7.stn.cnn.0.bias", "features.features.cnv7.stn.last.weight", "features.features.cnv7.stn.last.bias", "features.features.cnv8.stn.cnn.0.weight", "features.features.cnv8.stn.cnn.0.bias", "features.features.cnv8.stn.last.weight", "features.features.cnv8.stn.last.bias", "features.features.cnv9.stn.cnn.0.weight", "features.features.cnv9.stn.cnn.0.bias", "features.features.cnv9.stn.last.weight", "features.features.cnv9.stn.last.bias", "features.features.cnv10.stn.cnn.0.weight", "features.features.cnv10.stn.cnn.0.bias", "features.features.cnv10.stn.last.weight", "features.features.cnv10.stn.last.bias". And I did not reproduce the accuracy published in the paper, could you please share the hyperparameters setting in the experiment?

georgeretsi commented 1 year ago

The error indicates that the saved model has enabled the STN submodule. You can try the definition of the model with stn=True and check if this works alright.