clovaai / deep-text-recognition-benchmark

Text recognition (optical character recognition) with deep learning methods, ICCV 2019
Apache License 2.0
3.77k stars 1.11k forks source link

Adding new characters causes error #413

Open dysff opened 9 months ago

dysff commented 9 months ago

When I add extra character(for instance standard length of symbols was 35) or remove one letter, I get this error. But if I just replace one letter with another everything is okay. How to fix this?(I'm using russian alphabet, upper and lower characters) (I checked a lot of issues, but didn't find mine)

PS E:\VScodeProjects\draft> py deep-text-recognition-benchmark\train.py --train_data lmdb_output --valid_data lmdb_output --select_data "/" --batch_ratio 1.0 --Transformation TPS --FeatureExtraction ResNet --SequenceModeling BiLSTM --Prediction Attn --batch_size 2 --data_filtering_off --workers 0 --batch_max_length 80 --num_iter 100 --valInterval 5 --saved_model TPS-ResNet-BiLSTM-Attn.pth
--------------------------------------------------------------------------------
dataset_root: lmdb_output
opt.select_data: ['/']
opt.batch_ratio: ['1.0']
--------------------------------------------------------------------------------
dataset_root:    lmdb_output     dataset: /
sub-directory:  /.       num samples: 10
num total samples of /: 10 x 1.0 (total_data_usage_ratio) = 10
num samples of / per batch: 2 x 1.0 (batch_ratio) = 2
--------------------------------------------------------------------------------
Total_batch_size: 2 = 2
--------------------------------------------------------------------------------
dataset_root:    lmdb_output     dataset: /
sub-directory:  /.       num samples: 10
--------------------------------------------------------------------------------
model input parameters 32 100 20 1 512 256 76 80 TPS ResNet BiLSTM Attn
Skip Transformation.LocalizationNetwork.localization_fc2.weight as it is already initialized
Skip Transformation.LocalizationNetwork.localization_fc2.bias as it is already initialized  
loading pretrained model from TPS-ResNet-BiLSTM-Attn.pth
Traceback (most recent call last):
  File "E:\VScodeProjects\draft\deep-text-recognition-benchmark\train.py", line 319, in <module>
    train(opt)
  File "E:\VScodeProjects\draft\deep-text-recognition-benchmark\train.py", line 88, in train
    model.load_state_dict(torch.load(opt.saved_model,map_location='cpu'))
  File "E:\python\lib\site-packages\torch\nn\modules\module.py", line 2153, in load_state_dict
    raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
RuntimeError: Error(s) in loading state_dict for DataParallel:
        size mismatch for module.Prediction.attention_cell.rnn.weight_ih: copying a param with shape torch.Size([1024, 294]) from checkpoint, the shape in current 
model is torch.Size([1024, 332]).
        size mismatch for module.Prediction.generator.weight: copying a param with shape torch.Size([38, 256]) from checkpoint, the shape in current model is torch.Size([76, 256]).
        size mismatch for module.Prediction.generator.bias: copying a param with shape torch.Size([38]) from checkpoint, the shape in current model is torch.Size([76]).

I only get that there's something wrong in architecture when I do this.

khalilRhouma commented 7 months ago

@dysff maybe settingnew_prediction: True could fix the issue

Deromchik commented 6 months ago

also faced with this problem. @dysff were you able to solve this problem? if so, i will be grateful for your answer 🙏🏻