clovaai / deep-text-recognition-benchmark

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

Transfer learning with pretrained model on custom dataset #98

Closed aashish-0393 closed 4 years ago

aashish-0393 commented 5 years ago

hi , I want to train model on small custom dataset . Ho to set the parameters for transfer learning

akarazniewicz commented 4 years ago
  1. Prepare your dataset as described, create lmdb. Easiest way is just preserver the same structure like MJ dataset prepared by authors
  2. Download pretrained model, You'd like to finetune. For example TPS-ResNet-BiLSTM-Attn.pth; rename it to TPS-ResNet-BiLSTM-Attn_<iteration to start over>.pth (for example TPS-ResNet-BiLSTM-Attn_15000.pth to resume training from 15000 iteration).
  3. Just train with --FT flag. python3 train.py --train_data train/MJ --valid_data validation --select_data / --batch_ratio 1 --Transformation TPS --FeatureExtraction ResNet --SequenceModeling BiLSTM --Prediction Attn --FT --saved_model pretrained/TPS-ResNet-BiLSTM-Attn_15000.pth
aihyper11 commented 4 years ago

@akarazniewicz thank you for the details. I also want to fine tune the models on small dataset, just want to make it sure, this is the only change that is required in command line to fine tune the models. We can do same selection of iteration for other models, CRNN-pyTorchCTC_15000.pth. Is there any logic to come with 15000 number. Also, if I don't want to use TPS, still fine tuning will work using pretrained models right?

HSILA commented 3 years ago
  1. Download pretrained model, You'd like to finetune. For example TPS-ResNet-BiLSTM-Attn.pth; rename it to TPS-ResNet-BiLSTM-Attn_<iteration to start over>.pth (for example TPS-ResNet-BiLSTM-Attn_15000.pth to resume training from 15000 iteration).

I renamed the weight file to None-VGG-BiLSTM-CTC_300000.pth so it starts from iteration 300000: continue to train, start_iter: 300000 I set the --num_iter to 1500 (I know it's not high, just for testing). So training should end after 300000+1500 iterations. But it continues. Why?

[301710/1500] Train loss: 0.00004, Valid loss: 2.33314, Elapsed_time: 3631.69746
Current_accuracy : 24.211, Current_norm_ED  : 0.62
Best_accuracy    : 26.316, Best_norm_ED     : 0.62
athithya-raj commented 2 years ago
  1. Download pretrained model, You'd like to finetune. For example TPS-ResNet-BiLSTM-Attn.pth; rename it to TPS-ResNet-BiLSTM-Attn_<iteration to start over>.pth (for example TPS-ResNet-BiLSTM-Attn_15000.pth to resume training from 15000 iteration).

I renamed the weight file to None-VGG-BiLSTM-CTC_300000.pth so it starts from iteration 300000: continue to train, start_iter: 300000 I set the --num_iter to 1500 (I know it's not high, just for testing). So training should end after 300000+1500 iterations. But it continues. Why?

[301710/1500] Train loss: 0.00004, Valid loss: 2.33314, Elapsed_time: 3631.69746
Current_accuracy : 24.211, Current_norm_ED  : 0.62
Best_accuracy    : 26.316, Best_norm_ED     : 0.62

Did you find anything for this?