基于PP-PicoDet的钢铁缺陷检测( 三 )


这是控制模型训练的主配置文件位于:///cnet.yml,其中设置的参数会覆盖掉子配置文件中的相关参数 。这也是为什么我们6.1.3子配置文件中基本保留了默认配置而不做修改,原因就在于,在主配置文件内集中修改参数,可以更方便的修改训练参数,避免要修改的参数过于分散 。为缩短实验时间epoch: 30 和: 1
按如下内容修改主配置文件的内容:
_BASE_: ['../datasets/coco_detection.yml','../runtime.yml','_base_/picodet_v2.yml','_base_/optimizer_300e.yml','_base_/picodet_416_reader.yml',]pretrain_weights: https://paddledet.bj.bcebos.com/models/picodet_s_416_coco_lcnet.pdparamsweights: output/picodet_s_416_coco_lcnet/model_finalfind_unused_parameters: Trueuse_ema: trueuse_gpu: trueepoch: 30snapshot_epoch: 1LCNet:scale: 0.75feature_maps: [3, 4, 5]LCPAN:out_channels: 96PicoHeadV2:conv_feat:name: PicoFeatfeat_in: 96feat_out: 96num_convs: 2num_fpn_stride: 4norm_type: bnshare_cls_reg: Trueuse_se: Truefeat_in_chan: 96TrainReader:batch_size: 8LearningRate:base_lr: 0.06schedulers:- !CosineDecaymax_epochs: 300- !LinearWarmupstart_factor: 0.1steps: 300
其中:
6.1.3 默认不修改的yml
【基于PP-PicoDet的钢铁缺陷检测】运行时配置文件 .yml 用于设置运行时的参数,主要包括:
use_gpu:是否使用GPU训练use_xpu:是否使用XPU训练log_iter:显示训练信息的间隔save_dir:模型保存路径snapshot_epoch: 保存模型的间隔# Exporting the model: 与导出模型相关的设置

基于PP-PicoDet的钢铁缺陷检测

文章插图
这里我们暂且保留默认值,不做修改即可 。
模型网络参数 .yml
用于设置模型的网络参数,也包括预训练集的加载,这里为了可以快速开始实际训练,我们也暂时保留默认的参数,不做修改 。
训练优化参数 .yml
主要说明了学习率和优化器的配置 。其中比较重要的参数是训练轮数 epoch 和 学习率。同样,我们暂时不在这里修改,稍后再设置 。
6.2 开始训练
# GPU 单卡训练%cd ~/PaddleDetection!export CUDA_VISIBLE_DEVICES=0# windows和Mac下不需要执行该命令!python tools/train.py -c configs/picodet/picodet_s_416_coco_lcnet.yml --use_vdl=true --vdl_log_dir=vdl_dir/scalar --eval
Average Precision(AP) @[ IoU=0.50:0.95 | area=all | maxDets=100 ] = 0.281Average Precision(AP) @[ IoU=0.50| area=all | maxDets=100 ] = 0.602Average Precision(AP) @[ IoU=0.75| area=all | maxDets=100 ] = 0.213Average Precision(AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.134Average Precision(AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.234Average Precision(AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.390Average Recall(AR) @[ IoU=0.50:0.95 | area=all | maxDets=1 ] = 0.212Average Recall(AR) @[ IoU=0.50:0.95 | area=all | maxDets= 10 ] = 0.442Average Recall(AR) @[ IoU=0.50:0.95 | area=all | maxDets=100 ] = 0.508Average Recall(AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.231Average Recall(AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.438Average Recall(AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.609[12/11 13:39:43] ppdet.engine INFO: Total sample number: 280, averge FPS: 20.09930010448373[12/11 13:39:43] ppdet.engine INFO: Best test bbox ap is 0.281.[12/11 13:39:43] ppdet.utils.checkpoint INFO: Save checkpoint: output/picodet_s_416_coco_lcnet
7. 模型评估
# GPU单卡评估!python tools/eval.py -c configs/picodet/picodet_s_416_coco_lcnet.yml-o weights=output/picodet_s_416_coco_lcnet/model_final.pdparams
Average Precision(AP) @[ IoU=0.50:0.95 | area=all | maxDets=100 ] = 0.281Average Precision(AP) @[ IoU=0.50| area=all | maxDets=100 ] = 0.602Average Precision(AP) @[ IoU=0.75| area=all | maxDets=100 ] = 0.213Average Precision(AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.134Average Precision(AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.234Average Precision(AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.390Average Recall(AR) @[ IoU=0.50:0.95 | area=all | maxDets=1 ] = 0.212Average Recall(AR) @[ IoU=0.50:0.95 | area=all | maxDets= 10 ] = 0.442Average Recall(AR) @[ IoU=0.50:0.95 | area=all | maxDets=100 ] = 0.508Average Recall(AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.231Average Recall(AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.438Average Recall(AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.609[12/11 13:40:43] ppdet.engine INFO: Total sample number: 280, averge FPS: 48.80814227976918