AstarLight / Lets_OCR

A repository for OCR, which inlcudes some classical OCR algorithms Pytorch implementation such as CTPN, EAST and CRNN.
MIT License
656 stars 327 forks source link

python3 infer.py error: #52

Open molyswu opened 5 years ago

molyswu commented 5 years ago

python3 infer.py error: Traceback (most recent call last): File "infer.py", line 58, in model.load_state_dict(torch.load(crnn_model_path)) File "/usr/local/lib/python3.5/dist-packages/torch/nn/modules/module.py", line 721, in load_state_dict self.class.name, "\n\t".join(error_msgs))) RuntimeError: Error(s) in loading state_dict for CRNN: Unexpected key(s) in state_dict: "cnn.vgg_16.BatchNorm1.num_batches_tracked", "cnn.vgg_16.BatchNorm2.num_batches_tracked".

my model for ./w160_bs64_model/netCRNN_4_48000.pth'

thank you for your help!

harrymore commented 5 years ago

我也出现同样的问题,估计是alphabet.py的问题。因为替换了里面的字符集,导致长度与原来模型里的不一样,但是因为现在的训练集的索引又和原来的对不上,所以还是自己训练吧。

wkevin commented 5 years ago

torch==0.4.0 我也遇到此问题,升级到 torch=0.4.1 消失。 搜索看有网友提到:pytorch0.4.1添加了num_batches_tracked

oweiii commented 4 years ago

若只是用训练好的模型infer可以不用改po主的alphabet.py 因为正确版的字符集编译之后就会变成po主那样 infer时是可以显示正确对应的字符的

Yaoxingtian commented 3 years ago

升级到 torch=0.4.1 消失 正解,cudnn 用7.1.2