本文主要是介绍AIStudio PaddleDetection Picodet 增量训练自己数据,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1 拷贝PaddleDetection
https://gitee.com/paddlepaddle/PaddleDetection.git
2 安装依赖
pip install -r requirements.txt
3 Vott制作自己的数据,导出VOC格式
4 修改配置文件
configs/picodet/picodet_s_320_coco_lcnet.yml
_BASE_: ['../datasets/voc.yml', -->指定voc格式数据配置'../runtime.yml','_base_/picodet_v2.yml','_base_/optimizer_300e.yml','_base_/picodet_320_reader.yml',
]
use_gpu: false
pretrain_weights: /xxx/xxx -->指定训练好的权重文件
weights: output/picodet_s_320_coco_lcnet/best_model/best_model
find_unused_parameters: True
use_ema: true
epoch: 300
snapshot_epoch: 10LCNet: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: 64LearningRate:base_lr: 0.32schedulers:- !CosineDecaymax_epochs: 300- !LinearWarmupstart_factor: 0.1steps: 300
configs/datasets/voc.yml
metric: VOC
map_type: 11point
num_classes: 1TrainDataset:!VOCDataSetdataset_dir: /opt/code/ys7/cmd/pic/voc-PascalVOC-exportanno_path: ImageSets/Main/person_train.txtlabel_list: pascal_label_map.pbtxtdata_fields: ['image', 'gt_bbox','gt_class']EvalDataset:!VOCDataSetdataset_dir: dataset/vocanno_path: ImageSets/Main/person_val.txtlabel_list: pascal_label_map.pbtxtdata_fields: ['image', 'gt_bbox','gt_class']TestDataset:!ImageFolderanno_path: dataset/voc/label_list.txt
4 修改数据Loader
ppdet/data/source/voc.py
with open(anno_path, 'r') as fr:while True:line = fr.readline()if not line:breakimg_file, xml_file = [os.path.join(image_dir, x) \for x in line.strip().split()[:2]]
修改为:
with open(anno_path, 'r') as fr:while True:line = fr.readline()if not line:breakl = line.strip().split()[0]img_file = os.path.join(image_dir+"JPEGImages/", l)xml_file = os.path.join(image_dir+"Annotations/", l).replace(".jpeg",".xml")
5 执行训练
python tools/train.py -c configs/picodet/picodet_s_320_coco_lcnet.yml
6 转换推理模型
python tools/export_model.py -c configs/picodet/picodet_s_320_coco_lcnet.yml --output_dir=./picodet_320
7 转换移动版推理模型
/opt/code/Paddle-Lite/build.opt/lite/api/opt --model_dir=picodet_320/picodet_s_320_coco_lcnet --valid_targets=arm --optimize_out_type=naive_buffer --optimize_out=picodet_320_lite
这篇关于AIStudio PaddleDetection Picodet 增量训练自己数据的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!