forked from PaddlePaddle/PaddleOCR
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix rec distillation (PaddlePaddle#3995)
* fix rec distillation * add dist cfg * fix cfg
- Loading branch information
1 parent
3805cc2
commit cc24646
Showing
7 changed files
with
255 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
160 changes: 160 additions & 0 deletions
160
configs/rec/ch_PP-OCRv2/ch_PP-OCRv2_rec_distillation.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
Global: | ||
debug: false | ||
use_gpu: true | ||
epoch_num: 800 | ||
log_smooth_window: 20 | ||
print_batch_step: 10 | ||
save_model_dir: ./output/rec_pp-OCRv2_distillation | ||
save_epoch_step: 3 | ||
eval_batch_step: [0, 2000] | ||
cal_metric_during_train: true | ||
pretrained_model: | ||
checkpoints: | ||
save_inference_dir: | ||
use_visualdl: false | ||
infer_img: doc/imgs_words/ch/word_1.jpg | ||
character_dict_path: ppocr/utils/ppocr_keys_v1.txt | ||
character_type: ch | ||
max_text_length: 25 | ||
infer_mode: false | ||
use_space_char: true | ||
distributed: true | ||
save_res_path: ./output/rec/predicts_pp-OCRv2_distillation.txt | ||
|
||
|
||
Optimizer: | ||
name: Adam | ||
beta1: 0.9 | ||
beta2: 0.999 | ||
lr: | ||
name: Piecewise | ||
decay_epochs : [700, 800] | ||
values : [0.001, 0.0001] | ||
warmup_epoch: 5 | ||
regularizer: | ||
name: L2 | ||
factor: 2.0e-05 | ||
|
||
Architecture: | ||
model_type: &model_type "rec" | ||
name: DistillationModel | ||
algorithm: Distillation | ||
Models: | ||
Teacher: | ||
pretrained: | ||
freeze_params: false | ||
return_all_feats: true | ||
model_type: *model_type | ||
algorithm: CRNN | ||
Transform: | ||
Backbone: | ||
name: MobileNetV1Enhance | ||
scale: 0.5 | ||
Neck: | ||
name: SequenceEncoder | ||
encoder_type: rnn | ||
hidden_size: 64 | ||
Head: | ||
name: CTCHead | ||
mid_channels: 96 | ||
fc_decay: 0.00002 | ||
Student: | ||
pretrained: | ||
freeze_params: false | ||
return_all_feats: true | ||
model_type: *model_type | ||
algorithm: CRNN | ||
Transform: | ||
Backbone: | ||
name: MobileNetV1Enhance | ||
scale: 0.5 | ||
Neck: | ||
name: SequenceEncoder | ||
encoder_type: rnn | ||
hidden_size: 64 | ||
Head: | ||
name: CTCHead | ||
mid_channels: 96 | ||
fc_decay: 0.00002 | ||
|
||
|
||
Loss: | ||
name: CombinedLoss | ||
loss_config_list: | ||
- DistillationCTCLoss: | ||
weight: 1.0 | ||
model_name_list: ["Student", "Teacher"] | ||
key: head_out | ||
- DistillationDMLLoss: | ||
weight: 1.0 | ||
act: "softmax" | ||
use_log: true | ||
model_name_pairs: | ||
- ["Student", "Teacher"] | ||
key: head_out | ||
- DistillationDistanceLoss: | ||
weight: 1.0 | ||
mode: "l2" | ||
model_name_pairs: | ||
- ["Student", "Teacher"] | ||
key: backbone_out | ||
|
||
PostProcess: | ||
name: DistillationCTCLabelDecode | ||
model_name: ["Student", "Teacher"] | ||
key: head_out | ||
|
||
Metric: | ||
name: DistillationMetric | ||
base_metric_name: RecMetric | ||
main_indicator: acc | ||
key: "Student" | ||
|
||
Train: | ||
dataset: | ||
name: SimpleDataSet | ||
data_dir: ./train_data/ | ||
label_file_list: | ||
- ./train_data/train_list.txt | ||
transforms: | ||
- DecodeImage: | ||
img_mode: BGR | ||
channel_first: false | ||
- RecAug: | ||
- CTCLabelEncode: | ||
- RecResizeImg: | ||
image_shape: [3, 32, 320] | ||
- KeepKeys: | ||
keep_keys: | ||
- image | ||
- label | ||
- length | ||
loader: | ||
shuffle: true | ||
batch_size_per_card: 128 | ||
drop_last: true | ||
num_sections: 1 | ||
num_workers: 8 | ||
Eval: | ||
dataset: | ||
name: SimpleDataSet | ||
data_dir: ./train_data | ||
label_file_list: | ||
- ./train_data/val_list.txt | ||
transforms: | ||
- DecodeImage: | ||
img_mode: BGR | ||
channel_first: false | ||
- CTCLabelEncode: | ||
- RecResizeImg: | ||
image_shape: [3, 32, 320] | ||
- KeepKeys: | ||
keep_keys: | ||
- image | ||
- label | ||
- length | ||
loader: | ||
shuffle: false | ||
drop_last: false | ||
batch_size_per_card: 128 | ||
num_workers: 8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.