head

HEtero-Assists Distillation for Heterogeneous Object Detectors

https://github.com/lutingwang/head

Science Score: 54.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: arxiv.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (6.8%) to scientific vocabulary
Last synced: 6 months ago · JSON representation ·

Repository

HEtero-Assists Distillation for Heterogeneous Object Detectors

Basic Info
  • Host: GitHub
  • Owner: LutingWang
  • License: apache-2.0
  • Language: Python
  • Default Branch: refactor
  • Size: 25.1 MB
Statistics
  • Stars: 10
  • Watchers: 1
  • Forks: 0
  • Open Issues: 3
  • Releases: 0
Created over 3 years ago · Last pushed over 2 years ago
Metadata Files
Readme License Citation

README.md

HEtero-Assists Distillation (ECCV 2022)

text _/ _/ _/_/_/_/ _/_/ _/_/_/ _/ _/ _/ _/ _/ _/ _/ _/_/_/_/ _/_/_/ _/_/_/_/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/_/_/_/ _/ _/ _/_/_/

This repository is the official implementation of "HEtero-Assists Distillation for Heterogeneous Object Detectors".

lint wakatime

Preparation

Download the MS-COCO dataset to data/coco.

Download MMDetection pretrained models to pretrained/mmdetection

bash mkdir -p pretrained/mmdetection wget -P pretrained/mmdetection https://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_mstrain_3x_coco/faster_rcnn_r50_fpn_mstrain_3x_coco_20210524_110822-e10bd31c.pth wget -P pretrained/mmdetection https://download.openmmlab.com/mmdetection/v2.0/third_party/mobilenet_v2_batch256_imagenet-ff34753d.pth wget -P pretrained/mmdetection https://download.openmmlab.com/mmdetection/v2.0/retinanet/retinanet_r50_fpn_mstrain_3x_coco/retinanet_r50_fpn_mstrain_3x_coco_20210718_220633-88476508.pth

Download torchvision pretrained models to pretrained/torchvision

bash mkdir -p ~/.cache/torch/hub/checkpoints ln -s ~/.cache/torch/hub/checkpoints pretrained/torchvision wget -P pretrained/torchvision https://download.pytorch.org/models/resnet18-f37072fd.pth wget -P pretrained/torchvision https://download.pytorch.org/models/resnet50-0676ba61.pth

The directory tree should be like this

text HEAD ├── data │ └── coco -> ~/Developer/datasets/coco │ ├── annotations │ │ ├── instances_train2017.json │ │ └── instances_val2017.json │ ├── train2017 │ │ └── ... │ └── val2017 │ └── ... ├── pretrained │ ├── mmdetection │ │ ├── faster_rcnn_r50_fpn_mstrain_3x_coco_20210524_110822-e10bd31c.pth │ │ ├── mobilenet_v2_batch256_imagenet-ff34753d.pth │ │ └── retinanet_r50_fpn_mstrain_3x_coco_20210718_220633-88476508.pth │ └── torchvision -> ~/.cache/torch/hub/checkpoints │ ├── resnet18-f37072fd.pth │ └── resnet50-0676ba61.pth └── ...

Installation

Create a conda environment and activate it.

bash conda create -n HEAD python=3.8 conda activate HEAD

Install MMDetection following the official instructions. For example,

bash pip install torch==1.9.1+cu102 torchvision==0.10.1+cu102 -f https://download.pytorch.org/whl/torch_stable.html pip install -U openmim mim install mmcv_full==1.4.6 pip install mmdet==2.20

Install todd.

bash pip install todd_ai==0.2.3a9 -i https://pypi.org/simple

Note that the requirements.txt is not intended for users. Please follow the above instructions.

Training

bash python tools/train.py configs/head/head_retina_faster_r18_fpn_mstrain_1x_coco.py --work-dir work_dirs/debug --seed 3407

For distributed training

bash bash tools/dist_train.sh configs/head/head_retina_faster_r18_fpn_mstrain_1x_coco.py 8 --work-dir work_dirs/debug --seed 3407

Results

All logs and checkpoints can be found in the Google Drive.

Baseline

| Method | Student | Teacher | mAP | Config | Comment | | :-: | :-: | :-: | :-: | :-: | :-: | | FitNet | R18 RetinaNet | R50 RetinaNet | $35.6$ | fitnet_retina | with weight transfer |

HEAD

Teachers and students are all trained with multi-scale, for 3x and 1x schedulers respectively.

| Student | Teacher | Assist | AKD | CKD | mAP | Config | | :-: | :-: | :-: | :-: | :-: | :-: | - | | R18 RetinaNet | | | | | $31.7$ | refer to mmdetection | | R18 RetinaNet | R50 Faster R-CNN | $\checkmark$ | | | $33.4$ | retinafasterr18 | | R18 RetinaNet | R50 Faster R-CNN | $\checkmark$ | $\checkmark$ | | $35.7$ | HEADdagretinafasterr18 | | R18 RetinaNet | R50 Faster R-CNN | $\checkmark$ | $\checkmark$ | $\checkmark$ | $36.1$ | HEADretinafaster_r18 | | MNv2 RetinaNet | | | | | $27.8$ | retinanet_mnv2 | | MNv2 RetinaNet | R50 Faster R-CNN | $\checkmark$ | | | $28.9$ | retinafastermnv2 | | MNv2 RetinaNet | R50 Faster R-CNN | $\checkmark$ | $\checkmark$ | | $32.2$ | HEADdagretinafastermnv2 | | MNv2 RetinaNet | R50 Faster R-CNN | $\checkmark$ | $\checkmark$ | $\checkmark$ | $33.1$ | HEADretinafaster_mnv2 |

TF-HEAD

Coming soon...

Developer Guides

Setup

bash pip install https://download.pytorch.org/whl/cpu/torch-1.9.1-cp38-none-macosx_11_0_arm64.whl pip install https://download.pytorch.org/whl/cpu/torchvision-0.10.0-cp38-cp38-macosx_11_0_arm64.whl pip install -e ./../mmcv pip install mmdet==2.20

bash pip install commitizen pip install -U pre-commit pre-commit install pre-commit install -t commit-msg

TODO

  • complete distributed train/test guide
  • more configs
  • etc.

Owner

  • Name: Luting Wang
  • Login: LutingWang
  • Kind: user
  • Location: Xicheng District, Beijing, China
  • Company: Beihang University (BUAA)

Citation (CITATION.cff)

cff-version: 1.2.0
title: >-
  HEAD: HEtero-Assists Distillation for Heterogeneous
  Object Detectors
message: Please cite this project using these metadata.
type: software
authors:
  - given-names: Luting
    family-names: Wang
    email: wangluting@buaa.edu.cn
    orcid: 'https://orcid.org/0000-0001-8317-226X'
    affiliation: Beihang University
  - given-names: Xiaojie
    family-names: Li
    email: lixiaojie@senseauto.com
    affiliation: SenseTime
  - given-names: Yue
    family-names: Liao
    email: liaoyue.ai@gmail.com
    affiliation: Beihang University
  - given-names: Zeren
    family-names: Jiang
    email: zeren.jiang99@gmail.com
    affiliation: ETH Zurich
  - given-names: Jianlong
    email: jlwu1992@sdu.edu.cn
    affiliation: Shandong University
    family-names: Wu
  - given-names: Fei
    email: wangfei91@mail.ustc.edu.cn
    affiliation: University of Science and Technology of China
    family-names: Wang
  - given-names: Chen
    email: qianchen@sensetime.com
    affiliation: SenseTime
    family-names: Qian
  - given-names: Si
    email: liusi@buaa.edu.cn
    affiliation: Beihang University
    family-names: Liu
identifiers:
  - type: doi
    value: 10.48550/arXiv.2207.05345
    description: arXiv
repository-code: 'https://github.com/LutingWang/HEAD'
abstract: >-
  Conventional knowledge distillation (KD) methods
  for object detection mainly concentrate on
  homogeneous teacher-student detectors. However, the
  design of a lightweight detector for deployment is
  often significantly different from a high-capacity
  detector. Thus, we investigate KD among
  heterogeneous teacher-student pairs for a wide
  application. We observe that the core difficulty
  for heterogeneous KD (hetero-KD) is the significant
  semantic gap between the backbone features of
  heterogeneous detectors due to the different
  optimization manners. Conventional homogeneous KD
  (homo-KD) methods suffer from such a gap and are
  hard to directly obtain satisfactory performance
  for hetero-KD. In this paper, we propose the
  HEtero-Assists Distillation (HEAD) framework,
  leveraging heterogeneous detection heads as
  assistants to guide the optimization of the student
  detector to reduce this gap. In HEAD, the assistant
  is an additional detection head with the
  architecture homogeneous to the teacher head
  attached to the student backbone. Thus, a hetero-KD
  is transformed into a homo-KD, allowing efficient
  knowledge transfer from the teacher to the student.
  Moreover, we extend HEAD into a Teacher-Free HEAD
  (TF-HEAD) framework when a well-trained teacher
  detector is unavailable. Our method has achieved
  significant improvement compared to current
  detection KD methods. For example, on the MS-COCO
  dataset, TF-HEAD helps R18 RetinaNet achieve 33.9
  mAP (+2.2), while HEAD further pushes the limit to
  36.2 mAP (+4.5).
keywords:
  - Knowledge Distillation
  - Object Detection
  - Heterogeneous
license: Apache-2.0

GitHub Events

Total
Last Year

Dependencies

.github/workflows/lint.yaml actions
  • actions/checkout master composite
  • actions/setup-python master composite
requirements.txt pypi
  • mmdet ==2.20
pyproject.toml pypi