4、picodet 小目标训练全流程(13)


因为训练过程中使用在线数据增强方式 , 所以test就用训练集做 , 这可能不科学 , 也就是说test是增强后的train的子集 , 但至少能说明模型收敛情况 。
!cp dataset/pqdetection_sliced2voc/train_256.txt dataset/pqdetection_sliced2voc/test_256.txt!cp dataset/pqdetection_sliced2voc/train_416.txt dataset/pqdetection_sliced2voc/test_416.txt
! tree -L 2 dataset/pqdetection_sliced2voc
[01;34mdataset/pqdetection_sliced2voc[0m├── [01;34mpq_160_75[0m│├── [01;34mimages[0m│└── [01;34mlabels[0m├── [01;34mpq_192_75[0m│├── [01;34mimages[0m│└── [01;34mlabels[0m├── [01;34mpq_224_75[0m│├── [01;34mimages[0m│└── [01;34mlabels[0m├── [01;34mpq_256_75[0m│├── [01;34mimages[0m│└── [01;34mlabels[0m├── [01;34mpq_288_75[0m│├── [01;34mimages[0m│└── [01;34mlabels[0m├── [01;34mpq_320_75[0m│├── [01;34mimages[0m│└── [01;34mlabels[0m├── [01;34mpq_352_75[0m│├── [01;34mimages[0m│└── [01;34mlabels[0m├── [01;34mpq_384_75[0m│├── [01;34mimages[0m│└── [01;34mlabels[0m├── [01;34mpq_416_75[0m│├── [01;34mimages[0m│└── [01;34mlabels[0m├── [01;34mpq_448_75[0m│├── [01;34mimages[0m│└── [01;34mlabels[0m├── [01;34mpq_480_75[0m│├── [01;34mimages[0m│└── [01;34mlabels[0m├── [01;34mpq_512_75[0m│├── [01;34mimages[0m│└── [01;34mlabels[0m├── [00mtest_256.txt[0m├── [00mtest_416.txt[0m├── [00mtrain_256.txt[0m└── [00mtrain_416.txt[0m37 directories, 4 files
5、模型训练
以256为例 , 预训练模型使用我们之前的即可,更多配置说明可以参考
配置文件内容大概是:
_BASE_: ['../datasets/voc_pingpang_20230405.yml','../runtime.yml','_base_/picodet_v2.yml','_base_/optimizer_300e.yml',]#pretrain_weights: pretrained/PPLCNet_x0_75_pretrained.pdparamspretrain_weights: output/picodet_s_416_voc_npu_256_20230404/model_final.pdparamsweights: output/picodet_s_416_voc_npu_256_20230404/model_final.pdparamsfind_unused_parameters: Truekeep_best_weight: Trueuse_ema: Trueepoch: 80snapshot_epoch: 5PicoDet:backbone: LCNetneck: CSPPANhead: PicoHeadV2LCNet:scale: 0.75feature_maps: [3, 4, 5]act: relu6CSPPAN:out_channels: 96use_depthwise: Truenum_csp_blocks: 1num_features: 4act: relu6PicoHeadV2:conv_feat:name: PicoFeatfeat_in: 96feat_out: 96num_convs: 4num_fpn_stride: 4norm_type: bnshare_cls_reg: Trueuse_se: Trueact: relu6feat_in_chan: 96act: relu6LearningRate:base_lr: 0.0008schedulers:- !CosineDecaymax_epochs: 100min_lr_ratio: 0.001last_plateau_epochs: 10- !ExpWarmupepochs: 5worker_num: 6eval_height: &eval_height 256eval_width: &eval_width 256eval_size: &eval_size [*eval_height, *eval_width]TrainReader:sample_transforms:- Decode: {}- Mosaic:prob: 0.6input_dim: [416, 416]degrees: [-10, 10]scale: [0.1, 2.0]shear: [-2, 2]translate: [-0.1, 0.1]enable_mixup: True- AugmentHSV: {is_bgr: False, hgain: 5, sgain: 30, vgain: 30}- RandomFlip: {prob: 0.5}batch_transforms:# - BatchRandomResize: {target_size: [320, 352, 384, 416, 448, 480, 512], random_size: True, random_interp: True, keep_ratio: False}- BatchRandomResize: {target_size: [160, 192, 224, 256, 288, 320, 352], random_size: True, random_interp: True, keep_ratio: False}- NormalizeImage: {mean: [0, 0, 0], std: [1, 1, 1], is_scale: True}- Permute: {}- PadGT: {}batch_size: 80shuffle: truedrop_last: truemosaic_epoch: 70EvalReader:sample_transforms:- Decode: {}- Resize: {interp: 2, target_size: *eval_size, keep_ratio: False}- NormalizeImage: {mean: [0, 0, 0], std: [1, 1, 1], is_scale: True}- Permute: {}batch_transforms:- PadBatch: {pad_to_stride: 32}batch_size: 16shuffle: falseTestReader:inputs_def:image_shape: [1, 3, *eval_height, *eval_width]sample_transforms:- Decode: {}- Resize: {interp: 2, target_size: *eval_size, keep_ratio: False}- NormalizeImage: {mean: [0, 0, 0], std: [1, 1, 1], is_scale: True}- Permute: {}batch_size: 1