PaddlePaddle / PaddleDetection

Object Detection toolkit based on PaddlePaddle. It supports object detection, instance segmentation, multiple object tracking and real-time multi-person keypoint detection.
Apache License 2.0
12.6k stars 2.86k forks source link

ppyolo系列的蒸馏配置文件写法 #7207

Closed bittergourd1224 closed 5 months ago

bittergourd1224 commented 1 year ago

问题确认 Search before asking

请提出你的问题 Please ask your question

对于蒸馏的使用,只给出了yolov3的蒸馏配置文件,在configs/slim/distill/yolov3_mobilenet_v1_coco_distill.yml:

_BASE_: [
  '../../yolov3/yolov3_r34_270e_coco.yml',
]

pretrain_weights: https://paddledet.bj.bcebos.com/models/yolov3_r34_270e_coco.pdparams

slim: Distill
distill_loss: DistillYOLOv3Loss

DistillYOLOv3Loss:
  weight: 1000

而我需要用在ppyolo系列模型,从ppyolo_r50vd_dcn模型蒸馏到ppyolo_r18vd模型 为此我对于上面这个蒸馏配置文件做了两处改动:

  1. 将_BASE_替换为configs/ppyolo/ppyolo_r50vd_dcn_xx.yml,即我用自己数据集训练ppyolo_r50vd_dcn模型时的配置文件
  2. 将pretrain_weights替换为output/ppyolo_r50vd_dcn_xx/best_model.pdparams,即我用自己数据集训练的ppyolo_r50vd_dcn模型 保存为configs/slim/distill/ppyolo_r18vd_xx_distill.yml

然后执行蒸馏训练: python3 tools/train.py -c configs/ppyolo/ppyolo_r18vd_xx.yml --slim_config configs/slim/distill/ppyolo_r18vd_xx_distill.yml --eval 但是map只用0.14%,明显存在问题

对比直接训练小模型: python3 tools/train.py -c configs/ppyolo/ppyolo_r18vd_xx.yml map有53.37%,就很正常

这里有两个问题:

  1. 是否是因为没有支持从ppyolo_r50vd_dcn向ppyolo_r18vd蒸馏,才导致蒸馏效果很差?
  2. 在修改蒸馏配置文件为ppyolo系列时,我仍然沿用了DistillYOLOv3Loss,这一处是否需要修改?

感谢!

Sco-cai commented 1 year ago

你好,我遇到相同的问题,请问解决了没

bittergourd1224 commented 1 year ago

你好,我遇到相同的问题,请问解决了没

没有解决也没有人回复。 后续自己训了个yolov3模型,蒸馏就没有问题。ppyolo系列还是有问题。

nemonameless commented 1 year ago

不同模型的蒸馏写法,和本身loss以及蒸馏loss的写法有关,如果不同直接套用大概率是不行的。 PPYOLO v1 v2 baseline目前来看已经不算高了。我们正在进行PPYOLOE+的蒸馏,预计本月中旬发布。

bittergourd1224 commented 1 year ago

不同模型的蒸馏写法,和本身loss以及蒸馏loss的写法有关,如果不同直接套用大概率是不行的。 PPYOLO v1 v2 baseline目前来看已经不算高了。我们正在进行PPYOLOE+的蒸馏,预计本月中旬发布。

感谢,等待发布更新