Skip to content

A strong DETR-based detector named Domain Adaptive detection TRansformer (DATR) for unsupervised domain adaptation in object detection.

License

Notifications You must be signed in to change notification settings

h751410234/DATR

Repository files navigation

DATR: Unsupervised Domain Adaptive Detection Transformer with Dataset-Level Adaptation and Prototypical Alignment

By Liang Chen, Jianhong Han and Yupei Wang.

This repository contains the implementation accompanying our paper DATR: Unsupervised Domain Adaptive Detection Transformer with Dataset-Level Adaptation and Prototypical Alignment.

If you find it helpful for your research, please consider citing:

@article{han2024datr,
  title={DATR: Unsupervised Domain Adaptive Detection Transformer with Dataset-Level Adaptation and Prototypical Alignment},
  author={Han, Jianhong and Chen, Liang and Wang, Yupei},
  journal={arXiv preprint arXiv:2405.11765},
  year={2024}
}

Acknowledgment

This implementation is bulit upon DINO and RemoteSensingTeacher.

Installation

Please refer to the instructions here. We leave our system information for reference.

  • OS: Ubuntu 16.04
  • Python: 3.10.9
  • CUDA: 11.8
  • PyTorch: 2.0.1
  • torchvision: 0.15.2

Dataset Preparation

Please construct the datasets following these steps:

  • Download the datasets from their sources.

  • Convert the annotation files into COCO-format annotations.

  • Modify the dataset path setting within the script DAcoco.py

  #---源域
    PATHS_Source = {
        "train": ("",  #train image dir
                  ""), #train coco format json file
        "val": ("",    #val image dir
                ""),   #val coco format json file
    }
    #----目标域
    PATHS_Target = {
        "train": ("",  #train image dir
                  ""), #train coco format json file
        "val": ("",    #val image dir
                ""),   #val coco format json file
    }
  • Add domain adaptation direction within the script init.py. For example:
    if args.dataset_file == 'city':
        return build_city_DA(image_set, args,strong_aug)

Training / Evaluation / Inference

We provide training script as follows. We divide the training process into two stages. The settings for each stage can be found in the config folder.

(1) For the Burn-In stage:

  • Training with single GPU
sh scripts/DINO_train.sh
  • Training with Multi-GPU
sh scripts/DINO_train_dist.sh

(2) For the Teacher-Student Mutual Learning stage, it is necessary to use the optimal model obtained from the first stage of training.

  • Training with single GPU
sh scripts/DINO_train_self_training.sh
  • Training with Multi-GPU
sh scripts/DINO_train_self_training_dist.sh

We provide evaluation script to evaluate pre-trained model.

  • Evaluation Model.
sh scripts/DINO_eval.sh
  • Evaluation EMA Model.
sh scripts/DINO_eval_for_EMAmodel.sh

We provide inference script to visualize detection results. See inference.py for details

  • Inference Model.
python inference.py
  • Inference EMA Model.
python inference_ema_model.py 

Pre-trained models

We provide specific experimental configurations and pre-trained models to facilitate the reproduction of our results. You can learn the details of DATR through the paper, and please cite our papers if the code is useful for your papers. Thank you!

Task mAP50 Config Model
Cityscapes to Foggy Cityscapes 52.8% cfg model
Sim10k to Cityscapes 66.3% cfg model
Cityscapes to BDD100K-daytime 41.9% cfg model

Reference

https://github.com/IDEA-Research/DINO

https://github.com/h751410234/RemoteSensingTeacher

About

A strong DETR-based detector named Domain Adaptive detection TRansformer (DATR) for unsupervised domain adaptation in object detection.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages