CrossTeaching-SSOD
0. Introduction
Official code of "Mitigating the Mutual Error Amplification for Semi-Supervised Object Detection"
This repo includes training SSD300 and training Faster-RCNN-FPN on the Pascal VOC benchmark. The scripts about training SSD300 are based on ssd.pytorch (https://github.com/amdegroot/ssd.pytorch/). The scripts about training Faster-RCNN-FPN are based on the official Detectron2 repo (https://github.com/facebookresearch/detectron2/).
1. Environment
Python = 3.6.8
CUDA Version = 10.1
Pytorch Version = 1.6.0
detectron2 (for Faster-RCNN-FPN)
2. Prepare Dataset
Download and extract the Pascal VOC dataset.
For SSD300, specify the VOC_ROOT
variable in data/voc0712.py
and data/voc07_consistency.py
as /home/username/dataset/VOCdevkit/
For Faster-RCNN-FPN, set the environmental variable in this way: export DETECTRON2_DATASETS=/home/username/dataset/VOCdevkit/
3. Instruction
3.1 Reproduce Table.1
Go into the SSD300 directory, then run the following scripts.
supervised training (VOC 07 labeled, without extra augmentation):
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python3 train_ssd.py --save_interval 12000
self-labeling (VOC 07 labeled + VOC 12 unlabeled, without extra augmentation):
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python3 train_pseudo39.py --resume weights/ssd300_12000.pth --ramp --save_interval 12000
supervised training (VOC 0712 labeled, without extra augmentation):
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python3 train_ssd0712.py --save_interval 12000
supervised training (VOC 07 labeled, with horizontal flip):
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python3 train_csd_sup2.py --save_interval 12000
self-labeling (VOC 07 labeled + VOC 12 unlabeled, with horizontal flip):
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python3 train_csd.py --save_interval 12000
supervised training (VOC 0712 labeled, with horizontal flip):
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python3 train_csd_sup_0712.py --save_interval 12000
supervised training (VOC 07 labeled, with mix-up augmentation):
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python3 train_isd_sup2.py --save_interval 12000
self-labeling (VOC 07 labeled + VOC 12 unlabeled, with mix-up augmentation):
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python3 train_only_isd.py --save_interval 12000
supervised training (VOC 0712 labeled, with mix-up augmentation):
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python3 train_isd_sup_0712.py --save_interval 12000
3.2 Reproduce Table.2
Go into the SSD300 directory, then run the following scripts.
supervised training (VOC 07 labeled, without augmentation):
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python3 train_ssd.py --save_interval 12000
self-labeling (VOC 07 labeled + VOC 12 unlabeled, confidence threshold=0.5):
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python3 train_pseudo39.py --resume weights/ssd300_12000.pth --ramp --save_interval 12000
self-labeling (VOC 07 labeled + VOC 12 unlabeled, confidence threshold=0.8):
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python3 train_pseudo39-0.8.py --resume weights/ssd300_12000.pth --ramp --save_interval 12000
self-labeling (random FP label, confidence threshold=0.5):
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python3 train_pseudo102.py --resume weights/ssd300_12000.pth --ramp --save_interval 12000
self-labeling (use only TP, confidence threshold=0.5):
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python3 train_pseudo36.py --resume weights/ssd300_12000.pth --ramp --save_interval 12000
self-labeling (use only TP, confidence threshold=0.8):
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python3 train_pseudo36-0.8.py --resume weights/ssd300_12000.pth --ramp --save_interval 12000
self-labeling (use true label, confidence threshold=0.5):
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python3 train_pseudo32.py --resume weights/ssd300_12000.pth --ramp --save_interval 12000
Go into the detectron2 directory.
supervised training (VOC 07 labeled, go into VOC07-sup-bs16):
python3 train_net.py --num-gpus 8 --config configs/voc/voc07_voc12.yaml
self-labeling (VOC 07 labeled + VOC 12 unlabeled, go into VOC07-sup-VOC12-unsup-self-teaching-0.7):
python3 train_net.py --resume --num-gpus 8 --config configs/voc/voc07_voc12.yaml MODEL.WEIGHTS output/model_0005999.pth SOLVER.CHECKPOINT_PERIOD 18000
self-labeling (random FP label, go into VOC07-sup-VOC12-unsup-self-teaching-0.7-random-wrong):
python3 train_net.py --resume --num-gpus 8 --config configs/voc/voc07_voc12.yaml MODEL.WEIGHTS output/model_0005999.pth SOLVER.CHECKPOINT_PERIOD 18000
self-labeling (use true label, go into VOC07-sup-VOC12-unsup-self-teaching-0.7-only-correct):
python3 train_net.py --resume --num-gpus 8 --config configs/voc/voc07_voc12.yaml MODEL.WEIGHTS output/model_0005999.pth SOLVER.CHECKPOINT_PERIOD 18000
3.3 Reproduce Table.3
Go into the SSD300 directory, then run the following scripts.
cross teaching
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python3 train_pseudo137.py --resume weights/ssd300_12000.pth --resume2 weights/default/ssd300_12000.2.pth --save_interval 12000 --ramp --ema_rate 0.99 --ema_step 10
cross teaching + mix-up augmentation
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python3 train_pseudo151.py --resume weights/ssd300_12000.pth --resume2 weights/default/ssd300_12000.2.pth --save_interval 12000 --ramp --ema_rate 0.99 --ema_step 10
Go into the detectron2/VOC07-sup-VOC12-unsup-cross-teaching directory.
cross teaching
python3 train_net.py --resume --num-gpus 8 --config configs/voc/voc07_voc12.yaml MODEL.WEIGHTS output/model_0005999.pth SOLVER.CHECKPOINT_PERIOD 18000