Giter VIP home page Giter VIP logo

crossrectify-ssod's Introduction

CrossRectify-SSOD

0. Introduction

Official code of "CrossRectify: Leveraging Disagreement for Semi-supervised Object Detection".

This repo includes training SSD300 on Pascal VOC, training Faster-RCNN-FPN on Pascal VOC, and training Faster-RCNN-FPN on MS-COCO.

The scripts about training SSD300 are based on ssd.pytorch, contained in SSD300.

The scripts about training Faster-RCNN-FPN on Pascal VOC are based on the official Detectron2 (v0.4) repo, contained in detectron2.

The scripts about training Faster-RCNN-FPN on MS-COCO are based on the official MMDetection (v2.17.0) repo, contained in mmdetection.

1. Environment

Python = 3.6.8

CUDA Version = 10.1

Pytorch Version = 1.6.0

detectron2 = 0.4 (training Faster-RCNN-FPN on Pascal VOC)

mmdetection = 2.17.0 (training Faster-RCNN-FPN on MS-COCO)

2. Prepare Dataset

Download and extract the Pascal VOC dataset.

For training SSD300 on Pascal VOC, go into the SSD300 subdirectory and specify the VOC_ROOT variable in data/voc0712.py and data/voc07_consistency.py as /path/to/dataset/VOCdevkit/

For training Faster-RCNN-FPN on Pascal VOC, go into the detectron2 subdirectory and set the environmental variable in this way: export DETECTRON2_DATASETS=/path/to/dataset/VOCdevkit/

Download and extract the MS-COCO dataset.

For training Faster-RCNN-FPN on MS-COCO, go into the mmdetection subdirectory and follow the instructions here.

3. Instructions

3.1 Reproduce Table. 1

Go into the SSD300 subdirectory, then run the following scripts to train detectors.

  • fully-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

  • fully-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

  • fully-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

  • fully-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

  • fully-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

  • fully-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

To eval the trained SSD300 on the Pascal VOC test set, run the following script:

  • CUDA_VISIBLE_DEVICES=0 python3 eval.py --trained_model /path/to/trained/detector/ckpt.pth

3.2 Reproduce Table. 2

Go into the SSD300 subdirectory, then run the following scripts.

  • fully-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, 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 (VOC 07 labeled + VOC 12 unlabeled, confidence threshold increasing from 0.5 to 0.8): CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python3 train_pseudo39-0.5-to-0.8.py --resume weights/ssd300_12000.pth --ramp --save_interval 12000

  • self-labeling (VOC 07 labeled + VOC 12 unlabeled, confidence threshold=0.5, use TP and discard FP): 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 (VOC 07 labeled + VOC 12 unlabeled, confidence threshold=0.5, use TP and random labeled FP, 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 (VOC 07 labeled + VOC 12 unlabeled, confidence threshold=0.5, use GT labels for TP and FP, 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

To eval the trained SSD300 on the Pascal VOC test set, run the following script:

  • CUDA_VISIBLE_DEVICES=0 python3 eval.py --trained_model /path/to/trained/detector/ckpt.pth

3.3 Reproduce Table.3

Go into the SSD300 subdirectory, then run the following scripts.

  • CrossRectify (VOC 07 labeled + VOC 12 unlabeled, confidence threshold=0.5): 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

  • CrossRectify + mix-up augmentation (VOC 07 labeled + VOC 12 unlabeled, confidence threshold=0.5): 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

To eval the trained SSD300 on the Pascal VOC test set, run the following script:

  • CUDA_VISIBLE_DEVICES=0 python3 eval.py --trained_model /path/to/trained/detector/ckpt.pth

Go into the detectron2 subdirectory, then run the following script.

  • CrossRectify (VOC 07 labeled + VOC 12 unlabeled, confidence threshold=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 36000

To eval the trained Faster-RCNN-FPN on the Pascal VOC test set, run the following script:

  • python3 train_net.py --eval-only --num-gpus 8 --config configs/voc/voc07_voc12.yaml MODEL.WEIGHTS /path/to/trained/detector/ckpt.pth

3.4 Reproduce Table.4

Go into the mmdetection subdirectory, then run the following script.

  • CrossRectify (VOC 07 labeled + VOC 12 unlabeled, confidence threshold=0.9): bash tools/dist_train_partially.sh semi 1 10 8

To eval the trained Faster-RCNN-FPN on the MS-COCO test set, run the following script:

  • bash tools/dist_test.sh work_dirs/soft_teacher_faster_rcnn_r50_caffe_fpn_coco_180k/10/1/soft_teacher_faster_rcnn_r50_caffe_fpn_coco_180k.py work_dirs/soft_teacher_faster_rcnn_r50_caffe_fpn_coco_180k/10/1/iter_180000.pth 8 --eval bbox

Citation

If you find this work useful, please consider citing our paper. We provide a BibTeX entry of our paper below:

@article{CrossRectify,
  title={CrossRectify: Leveraging disagreement for semi-supervised object detection},
  author={Ma, Chengcheng and Pan, Xingjia and Ye, Qixiang and Tang, Fan and Dong, Weiming and Xu, Changsheng},
  journal={Pattern Recognition},
  volume={137},
  pages={109280},
  year={2023},
  publisher={Elsevier}
}

Contact

Feel free to contact [[email protected]] if you have any questions about our paper or codes.

crossrectify-ssod's People

Contributors

machengcheng2016 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

crossrectify-ssod's Issues

Missing ssd.py / train_pseudo137.py / train_pseudo151.py?

Hi! Various train_* files include from ssd import build_ssd, but ssd.py is missing in this repo.

Is it a typo? Should it be instead from csd import build_ssd_con? Or are some files from ssd.pytorch missing in this repo?

What is the difference between csd.py and isd.py?

Also, train_pseudo137.py and train_pseudo151.py mentioned at https://github.com/machengcheng2016/CrossTeaching-SSOD#33-reproduce-table3 are missing from the repo...

Thanks!

训练一个轮次就停止

使用“CUDA_VISIBLE_DEVICES=3 python3 train_ssd.py --save_interval 12000”训练时,只训练了一轮就停止,也没报错,请问是啥原因?结果显示如下:
@yunxuan01:~/CrossRectify-SSOD/SSD300$ CUDA_VISIBLE_DEVICES=0,3 python3 train_ssd.py
Loading base network...
Initializing weights...
random seed is set as 123
Loading the dataset...
Training SSD on: VOC300
Using the specified args:
Namespace(basenet='vgg16_reducedfc.pth', batch_size=4, cuda=True, dataset='VOC300', dataset_root='/CrossRectify-SSOD/Data/voc/VOCdevkit', gamma=0.1, lr=0.001, momentum=0.9, num_workers=4, resume=None, save_folder='weights/', save_interval=12000, seed=123, sup_aug_type='default', weight_decay=0.0005)
iter 0 || loss: 30.9676, loss_c: 27.1707, loss_l: 3.7969, super_len: 1

ValueError: Cannot match one checkpoint key to multiple keys in the model.

您好,我在使用detectron2进行cross-training时,没有使用resume,直接从头训练,会报错“ValueError: Cannot match one checkpoint key to multiple keys in the model.”
请问cross-training必须resume,您运行命令中的output/model_0005999.pth是怎么得到的呢,期待您的回复

datasets

Where can I download your dataset

Comparison with SoftTeacher on COCO 1%

Is it fair to copmare CT's Table 4 result 18.15 ± 0.13 with SoftTeacher's Table 3 result 20.46 ± 0.39.

Are hparams / valsets / training settings similar?

In this comparison it seems that SoftTeacher is more accurate than CT, but your Appendix D suggests otherwise.

Is CT better than SoftTeacher on 10% but worse on 1%?

Looking forward to your comments about CT vs SoftTeacher . Thank you!

File does not exist

Love this work! But when I try to reproduce the results of Table 4, an error occurred which says FileNotFoundError: file "/opt/tiger/app/CrossRectify-SSOD-main/mmdetection/thirdparty/mmdetection/configs/_base_/models/faster_rcnn_r50_fpn_double.py" does not exist, I assume you forgot to upload this file?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.