PaddleDetection
dataset
coco
faster_rcnn_dcn_r50_fpn_1x.yml
类别+1(背景)
max_iters: 120000
use_gpu: true
snapshot_iter: 10000
log_iter: 1
save_dir: output
pretrain_weights: https://paddlemodels.bj.bcebos.com/object_detection/faster_rcnn_dcn_r50_fpn_1x.tar
metric: COCO
weights: output/faster_rcnn_dcn_r50_fpn_1x/model_final
num_classes: 4
BBoxHead:
head: TwoFCHead
nms:
keep_top_k: 15
nms_threshold: 0.4
score_threshold: 0.05
LearningRate:
base_lr: 0.005
schedulers:
- !PiecewiseDecay
gamma: 0.1
milestones: [80000, 100000]
READER: ‘faster_fpn_reader.yml’
TrainReader:
batch_size: 1
faster_rcnn_dcn_r50_fpn_1x.yml
TrainReader:
inputs_def:
fields: [‘image’, ‘im_info’, ‘im_id’, ‘gt_bbox’, ‘gt_class’, ‘is_crowd’]
dataset:
!COCODataSet
image_dir: imgs
anno_path: annotations/train.json
dataset_dir: /data/yjl/dapeng
batch_size: 1
shuffle: true
drop_empty: false
worker_num: 2
use_process: false
EvalReader:
inputs_def:
fields: [‘image’, ‘im_info’, ‘im_id’, ‘im_shape’]
# for voc
#fields: [‘image’, ‘im_info’, ‘im_id’, ‘im_shape’, ‘gt_bbox’, ‘gt_class’, ‘is_difficult’]
dataset:
!COCODataSet
image_dir: imgs
anno_path: annotations/valid.json
dataset_dir: /data/yjl/dapeng
batch_size: 1
shuffle: false
drop_empty: false
worker_num: 2
TestReader:
inputs_def:
# set image_shape if needed
fields: [‘image’, ‘im_info’, ‘im_id’, ‘im_shape’]
dataset:
!ImageFolder
anno_path: /data/yjl/dapeng/annotations/valid.json
voc
ppyolo.yml
类别数不加背景
architecture: YOLOv3
use_gpu: true
max_iters: 130000
log_iter: 20
save_dir: output
snapshot_iter: 10000
metric: VOC
pretrain_weights: https://paddlemodels.bj.bcebos.com/object_detection/ppyolo.pdparams
weights: output/ppyolo/model_final
num_classes: 1
use_fine_grained_loss: true
use_ema: true
ema_decay: 0.9998
LearningRate:
base_lr: 0.002
schedulers:
- !PiecewiseDecay
gamma: 0.1
milestones:
- 120000
- 125000
ppyolo_reader.yml
TrainReader:
inputs_def:
fields: [‘image’, ‘gt_bbox’, ‘gt_class’, ‘gt_score’]
num_max_boxes: 50
dataset:
!VOCDataSet
anno_path: train.txt
dataset_dir: /data/yjl/dapeng
with_background: false
use_default_label: false
batch_size: 6
shuffle: true
mixup_epoch: 200
drop_last: true
worker_num: 8
bufsize: 4
use_process: true
EvalReader:
inputs_def:
fields: [‘image’, ‘im_size’, ‘im_id’, ‘gt_bbox’, ‘gt_class’, ‘is_difficult’]
num_max_boxes: 50
dataset:
!VOCDataSet
anno_path: valid.txt
dataset_dir: /data/yjl/dapeng
with_background: false
use_default_label: false
batch_size: 1
drop_empty: false
worker_num: 8
bufsize: 4
TestReader:
inputs_def:
fields: [‘image’, ‘im_size’, ‘im_id’, ‘gt_bbox’, ‘gt_class’, ‘is_difficult’]
num_max_boxes: 50
dataset:
!VOCDataSet
anno_path: valid.txt
dataset_dir: /data/yjl/dapeng
with_background: false
use_default_label: false
batch_size: 1
drop_empty: false
worker_num: 8
bufsize: 4
Train
nohup python -m paddle.distributed.launch --selected_gpus 2,3 tools/train.py -c ppyolo.yml --eval -o use_gpu=true --use_vdl=True --vdl_log_dir=vdl_dir/scalar -r output/ppyolo/90000 &
export CUDA_VISIBLE_DEVICES=2
python tools/train.py -c faster_rcnn_dcn_r50_fpn_1x.yml --eval -o use_gpu=true
Eval
CUDA_VISIBLE_DEVICES=0 python tools/eval.py -c ppyolo.yml -o use_gpu=true weights=output/ppyolo/90000
Infer
python tools/infer.py -c mask_rcnn_r50_fpn_1x.yml --infer_dir val --output_dir val_result -o weights=output/mask_rcnn_r50_fpn_1x/90000
Export
python tools/export_model.py -c faster_rcnn_dcn_r50_fpn_1x.yml \
--output_dir=./inference_model \
-o weights=output/faster_rcnn_dcn_r50_fpn_1x/model_final
python deploy/python/infer.py --model_dir=/path/to/models --image_file=/path/to/image
--use_gpu=(False/True) --output_dir=./re
自定义
CUDA_VISIBLE_DEVICES=2 python infer.py --model_dir=./inference_model/ppyolo --image_file=./e_ps --use_gpu=True --GPU_id=2
注:CUDA_VISIBLE_DEVICES 与GPU_id 指定的设备一致 查看调用模型的显存消耗
PaddleClas
train
python -m paddle.distributed.launch --selected_gpus="0" tools/train.py \
-c ../ neu.yaml \ #配置文件路径
-o pretrained_model=./ResNet50_vd_pretrained #预训练模型存放路径
-o use_gpu=True
# 恢复训练
python tools/train.py \
-c configs/quick_start/MobileNetV3_large_x1_0_finetune.yaml \
-o checkpoints="./output/MobileNetV3_large_x1_0/5/ppcls" \
-o last_epoch=5 \
-o use_gpu=True
eval
python -m paddle.distributed.launch --selected_gpus="0" tools/eval.py \
-c .. /eval.yaml \ #配置文件路径
-o pretrained_model=output/ResNet50_vd/best_model/ppcls #评估模型路径
export infer
python tools/export_model.py \
--model='ResNet50_vd' \ #模型名称
--pretrained_model=output/ResNet50_vd/best_model/ppcls \ #需要转换的模型路径
--output_path=./inference #输出的预测模型保存路径
python tools/infer/predict.py --use_gpu=1 -m cls_infer_model/model -p cls_infer_model/params -i 1.jpg --use_tensorrt=False