Closed song121982 closed 2 years ago
附配置文件:
# runtime
use_gpu: true
log_iter: 10
save_dir: output
snapshot_epoch: 2
# set collate_batch to false because ground-truth info is needed
# on voc dataset and should not collate data in batch when batch size
# is larger than 1.
# datasets
metric: VOC
map_type: 11point
num_classes: 1
TrainDataset:
!VOCDataSet
dataset_dir: dataset/VSvehicle_vehicle6000
anno_path: train.txt
label_list: label_list.txt
data_fields: ['image', 'gt_bbox', 'gt_class', 'difficult']
EvalDataset:
!VOCDataSet
dataset_dir: dataset/VSvehicle_vehicle6000
anno_path: valid.txt
label_list: label_list.txt
data_fields: ['image', 'gt_bbox', 'gt_class', 'difficult']
TestDataset:
!ImageFolder
anno_path: dataset/VSvehicle_vehicle6000/label_list.txt
# optimizer
epoch: 50
LearningRate:
base_lr: 0.0001
schedulers:
- !PiecewiseDecay
gamma: 0.1
milestones:
- 30
- 40
- !LinearWarmup
start_factor: 0.
steps: 2000
OptimizerBuilder:
clip_grad_by_norm: 35.
optimizer:
momentum: 0.9
type: Momentum
regularizer:
factor: 0.0005
type: L2
# ppyolov2_r50vd_dcn
architecture: YOLOv3
#pretrain_weights: output/r34_pre_vehicle/best_model.pdparams
norm_type: sync_bn
use_ema: true
ema_decay: 0.9998
YOLOv3:
backbone: ResNet
neck: PPYOLOFPN
yolo_head: YOLOv3Head
post_process: BBoxPostProcess
ResNet:
depth: 34
variant: d
return_idx: [1, 2, 3]
# dcn_v2_stages: [3]
freeze_at: -1
freeze_norm: false
norm_decay: 0.
PPYOLOFPN:
coord_conv: true
drop_block: false
block_size: 3
keep_prob: 0.9
spp: true
YOLOv3Head:
anchors: [[29, 17], [16, 34], [39, 24],
[20, 47], [34, 40], [47, 50],
[87, 36], [31, 104], [86, 92]]
anchor_masks: [[6, 7, 8], [3, 4, 5], [0, 1, 2]]
loss: YOLOv3Loss
iou_aware: true
iou_aware_factor: 0.4
YOLOv3Loss:
ignore_thresh: 0.6
downsample: [32, 16, 8]
label_smooth: false
scale_x_y: 1.05
iou_loss: IouLoss
iou_aware_loss: IouAwareLoss
IouLoss:
loss_weight: 2.5
loss_square: true
IouAwareLoss:
loss_weight: 1.0
BBoxPostProcess:
decode:
name: YOLOBox
conf_thresh: 0.01
downsample_ratio: 32
clip_bbox: true
scale_x_y: 1.05
nms:
name: MatrixNMS
keep_top_k: 100
score_threshold: 0.01
post_threshold: 0.01
nms_top_k: -1
background_label: -1
# reader
worker_num: 2
TrainReader:
inputs_def:
num_max_boxes: 50
sample_transforms:
- Decode: {}
- Mixup: {alpha: 1.5, beta: 1.5}
- RandomDistort: {}
- RandomExpand: {fill_value: [123.675, 116.28, 103.53]}
- RandomCrop: {}
- RandomFlip: {}
batch_transforms:
- BatchRandomResize: {target_size: [320, 384, 416, 448, 480, 512, 544, 608], random_size: True, random_interp: True, keep_ratio: False}
- NormalizeBox: {}
- PadBox: {num_max_boxes: 50}
- BboxXYXY2XYWH: {}
- NormalizeImage: {mean: [0.485, 0.456, 0.406], std: [0.229, 0.224, 0.225], is_scale: True}
- Permute: {}
- Gt2YoloTarget: {anchor_masks: [[6, 7, 8], [3, 4, 5], [0, 1, 2]],
anchors: [[29, 17], [16, 34], [39, 24],[20, 47], [34, 40], [47, 50],[87, 36], [31, 104], [86, 92]],
downsample_ratios: [32, 16, 8]}
batch_size: 6
shuffle: true
drop_last: true
mixup_epoch: 25000
use_shared_memory: true
EvalReader:
sample_transforms:
- Decode: {}
- Resize: {target_size: [512, 512], keep_ratio: False, interp: 2}
- NormalizeImage: {mean: [0.485, 0.456, 0.406], std: [0.229, 0.224, 0.225], is_scale: True}
- Permute: {}
batch_size: 1
collate_batch: false
TestReader:
inputs_def:
image_shape: [3, 512, 512]
sample_transforms:
- Decode: {}
- Resize: {target_size: [512, 512], keep_ratio: False, interp: 2}
- NormalizeImage: {mean: [0.485, 0.456, 0.406], std: [0.229, 0.224, 0.225], is_scale: True}
- Permute: {}
batch_size: 1
slim配置文件:
pretrain_weights: https://paddledet.bj.bcebos.com/models/pretrained/ResNet34_pretrained.pdparams
slim: QAT
QAT:
quant_config: {
'activation_preprocess_type': 'PACT',
'weight_quantize_type': 'channel_wise_abs_max', 'activation_quantize_type': 'moving_average_abs_max',
'weight_bits': 8, 'activation_bits': 8, 'dtype': 'int8', 'window_size': 10000, 'moving_rate': 0.99,
'quantizable_layer_type': ['Conv2D', 'Linear']}
print_model: False
训练过程没有问题,边训练边评估mAP可以达到80+ 模型导出前,使用训练得到的动态模型,指令
tools/infer.py xxxxxx
可以得到正确的预测结果。但模型导出后 使用导出模型预测:
python deploy/python/infer.py --model_dir=inference_model/ppyolov2_r34vd_dcn_vehicletrain --image_file=demo/03237.jpg --use_gpu=True
你tools/infer.py
预测有结果的命令和导出的全量命令麻烦发一下
还有你说导出了有框但是是乱的的预测结果麻烦也发一下
训练过程没有问题,边训练边评估mAP可以达到80+ 模型导出前,使用训练得到的动态模型,指令
tools/infer.py xxxxxx
可以得到正确的预测结果。 但模型导出后 使用导出模型预测:python deploy/python/infer.py --model_dir=inference_model/ppyolov2_r34vd_dcn_vehicletrain --image_file=demo/03237.jpg --use_gpu=True
你
tools/infer.py
预测有结果的命令和导出的全量命令麻烦发一下 还有你说导出了有框但是是乱的的预测结果麻烦也发一下
python tools/infer.py -c testtest/r34_qat/ppyolov2_r34vd_vehicletrain.yml --slim_config testtest/r34_qat/ppyolov2_r34vd_dcn_vehicletrain.yml --infer_img=demo/Visdrone_Vehicle00416.jpg -o weights=testtest/r34_qat/best_model.pdparams
输出结果正常(这里标签值忘改了):
导出指令:
python tools/export_model.py -c testtest/r34_qat/ppyolov2_r34vd_vehicletrain.yml --slim_config testtest/r34_qat/ppyolov2_r34vd_dcn_vehicletrain.yml -o weights=output/best_model.pdparams
python deploy/python/infer.py --model_dir=testtest/ppyolov2_r34vd_dcn_vehicletrain --image_file=./demo/Visdrone_vehicle_val01348.jpg
print输出:
(paddle) E:\paddle\PaddleDetection-release-2.1>python deploy/python/infer.py --model_dir=testtest/ppyolov2_r
34vd_dcn_vehicletrain --image_file=./demo/Visdrone_vehicle_val01348.jpg
----------- Running Arguments -----------
batch_size: 1
camera_id: -1
cpu_threads: 1
enable_mkldnn: False
image_dir: None
image_file: ./demo/Visdrone_vehicle_val01348.jpg
model_dir: testtest/ppyolov2_r34vd_dcn_vehicletrain
output_dir: output
run_benchmark: False
run_mode: fluid
threshold: 0.5
trt_calib_mode: False
trt_max_shape: 1280
trt_min_shape: 1
trt_opt_shape: 640
use_dynamic_shape: False
use_gpu: False
video_file: None
------------------------------------------
----------- Model Configuration -----------
Model Arch: YOLO
Transform Order:
--transform op: Resize
--transform op: NormalizeImage
--transform op: Permute
--------------------------------------------
e[37m--- Fused 0 subgraphs into layer_norm op.e[0m
------------------ Inference Time Info ----------------------
total_time(ms): 1349.1, img_num: 1
average latency time(ms): 1349.10, QPS: 0.741235
preprocess_time(ms): 22.40, inference_time(ms): 1326.70, postprocess_time(ms): 0.00
结果没有任何预测框生成:
slim_config
,然后使用导出模型预测:
python tools/export_model.py -c testtest/r34_qat/ppyolov2_r34vd_vehicletrain.yml -o weights=testtest/r34_qat/best_model.pdparams
python deploy/python/infer.py --model_dir=output_inference/ppyolov2_r34vd_vehicletrain --image_file=./demo/Visdrone_vehicle_val01348.jpg
输出结果:
@heavengate
麻烦发下配置文件,训练好的模型以及一张测试图片打包发一下,我们在本地测试下
好像模型太大了,发不了。。 @wangxinxin08
可以上传到百度网盘,分享下链接
@wangxinxin08 模型和配置文件链接,谢谢 链接:https://pan.baidu.com/s/1sy0kuXi4nYzz9YiR8U_qoQ?pwd=rk98 提取码:rk98
这个问题解决了吗,我也遇到这样的问题了,可以解答一下吗
这个问题解决了吗,我也遇到这样的问题了,可以解答一下吗
使用ppyolo/yoloV3中r34模型搭配slim量化训练
paddlepaddle2.2 paddledetection2.1 paddleslim2.1
训练过程没有问题,边训练边评估mAP可以达到80+ 模型导出前,使用训练得到的动态模型,指令
tools/infer.py xxxxxx
可以得到正确的预测结果。但模型导出后 使用导出模型预测:
python deploy/python/infer.py --model_dir=inference_model/ppyolov2_r34vd_dcn_vehicletrain --image_file=demo/03237.jpg --use_gpu=True
预测没有任何效果,没有任何预测框生成
后又尝试在导出模型过程中不配置slim文件,即不指定
--slim_config
,导出的部署模型才有预测框,虽然是乱的。这个问题困扰好多天了,一直没人解答,麻烦解答一下