Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding new characters causes error #413

Open
dysff opened this issue Feb 24, 2024 · 2 comments
Open

Adding new characters causes error #413

dysff opened this issue Feb 24, 2024 · 2 comments

Comments

@dysff
Copy link

dysff commented Feb 24, 2024

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
Copy link

@dysff maybe setting new_prediction: True could fix the issue

@Deromchik
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants