Skip to content

Mi-Peng/ActiveTeacher

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Active Teacher for Semi-Supervised Object Detection

This is an official implementation for CVPR2022 paper "Active Teacher for Semi-Supervised Object Detection". It includes the code for Active Teacher on Object Detection task. The performance on COCO, PASCAL VOC, SODA is reported in this repo.

Introduction

The overall of our Active Teacher.

Installation

  • Install detectron2 following the instructions.

  • Install Active Teacher via pip:

python3 -m pip install -e .

Dataset Preparation

Expected dataset structure for COCO detection:

coco/
  annotations/
    instances_{train,val}2017.json
  {train,val}2017/
    # image files that are mentioned in the corresponding json

Expected dataset structure for Pascal VOC:

VOC20{07,12}/
  Annotations/
  ImageSets/
    Main/
      trainval.txt
      test.txt
      # train.txt or val.txt, if you use these splits
  JPEGImages/

Custom dataset

Use Custom Datasets gives a deeper dive on how to use DatasetCatalog and MetadataCatalog, and how to add new datasets to them.

Training (10% label data for example)

Step 0、Generate 5% label data partition

python tools/generate_random_data_partition.py --random-file dataseed/COCO_supervision.txt --random-percent 5.0 --datasets "coco_2017_train,"

Step 1、Train a pick model on 5% random data

mkdir temp
mkdir temp/coco
mkdir results
mkdir results/coco
mkdir dataseed/coco_pick

python tools/train_net.py \
      --num-gpus 8 \
      --config configs/coco/faster_rcnn_R_50_FPN_sup5_run1.yaml \
       SOLVER.IMG_PER_BATCH_LABEL 16 SOLVER.IMG_PER_BATCH_UNLABEL 16 OUTPUT_DIR output/coco/faster_rcnn_R_50_FPN_sup5_run1_16bs

Step 2、Use the trained model from step 1 to get the indicator file of the dataset

python tools/inference_for_active_pick.py \
    --static-file temp/coco/static_by_random5.json \
    --model-weights output/coco/faster_rcnn_R_50_FPN_sup5_run1_16bs/model_best.pth \
    --config configs/coco/faster_rcnn_R_50_FPN_sup5_run1.yaml \

python tools/active_pick_evaluation.py \
    --static-file temp/coco/static_by_random5.json \
    --indicator-file results/coco/5random_maxnorm

Step 3、Use the indictor file from step 2 to generate pick data and merge random data

python tools/generate_pick_merge_random_data_partition.py \
    --random-file dataseed/COCO_supervision.txt \
    --random-percent 5.0 \
    --indicator-file results/coco/5random_maxnorm.txt \
    --pick-percent 5.0 \
    --reverse True \
    --save-file dataseed/coco_pick/pick_maxnorm5+random5.txt

Step 4、Train a model from scratch using the 10% data partition from step 3

python tools/train_net.py \
      --num-gpus 8 \
      --config configs/coco/faster_rcnn_R_50_FPN_sup10_run1.yaml \
       SOLVER.IMG_PER_BATCH_LABEL 16 SOLVER.IMG_PER_BATCH_UNLABEL 16 OUTPUT_DIR output/coco/faster_rcnn_R_50_FPN_sup10_run1_16bs DATALOADER.RANDOM_DATA_SEED_PATH dataseed/coco_pick/pick_maxnorm5+random5.txt

Evaluation

python train_net.py \
      --eval-only \
      --num-gpus 8 \
      --config configs/coco/faster_rcnn_R_50_FPN_sup10_run1.yaml \
       SOLVER.IMG_PER_BATCH_LABEL 16 SOLVER.IMG_PER_BATCH_UNLABEL 16 MODEL.WEIGHTS output/coco/faster_rcnn_R_50_FPN_sup10_run1_16bs/model_final.pth

Results

  • The results on different datasets is shown as below:

For PASCAL VOC, the trainset includes voc07-trainval, voc12-trainval.The model is evaluated on voc07-test.

Models Datasets Labels Supervision(mAP) Ours(mAP)
Res50-FPN COCO 1% 37.63 22.20
2% 24.99
5% 30.07
10% 32.58
20% 35.49
VOC07+12 5% 48.62 41.85
10% 46.77
15% 49.73
SODA 10% 34.52 33.32

Citing Active Teacher

If you find Active Teacher useful in your research, please consider citing:

@InProceedings{ActiveTeacher_2022_CVPR,
	author = {Mi, Peng and Lin, Jianghang and Zhou, Yiyi and Shen, Yunhang and Luo, Gen and Sun, Xiaoshuai and Cao, Liujuan and Fu, Rongrong and Xu, Qiang and Ji, Rongrong},
	title = {Active Teacher for Semi-Supervised Object Detection},
	booktitle = {The IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},
	year = {2022},
}   

License

Active Teacher is released under the Apache 2.0 license.

Acknowledgement

About

Code release for "Active Teacher for Semi-Supervised Object Detection", CVPR2022

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 98.7%
  • Shell 1.3%