• Stars
    star
    117
  • Rank 301,828 (Top 6 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created over 2 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

source code for CVPR'22 paper "Unknown-Aware Object Detection: Learning What You Don’t Know from Videos in the Wild"

STUD

This is the source code accompanying the paper Unknown-Aware Object Detection:Learning What You Don’t Know from Videos in the Wild paper by Xuefeng Du, Xin Wang, Gabriel Gozum and Yixuan Li

The codebase is based heavily from CycleConf and Detectron2.

Ads

Checkout our

  • ICLR'22 work VOS on object detection in still images and classification networks.
  • NeurIPS'22 work SIREN on OOD detection for detection transformers.
  • ICLR'23 work NPOS on non-parametric outlier synthesis.
  • NeurIPS'23 work DREAM-OOD on outlier generation in the pixel space (by diffusion models) if you are interested!

Installation

Environment

  • CUDA 10.2
  • Python >= 3.7
  • Pytorch >= 1.6
  • THe Detectron2 version matches Pytorch and CUDA versions.

Dependencies

  1. Create a virtual env.
  • python3 -m pip install --user virtualenv
  • python3 -m venv stud
  • source stud/bin/activate
  1. Install dependencies.
  • pip install -r requirements.txt

  • Install Pytorch 1.9

pip3 install torch torchvision

Check out the previous Pytorch versions here.

  • Install Detectron2 Build Detectron2 from Source (gcc & g++ >= 5.4) python -m pip install 'git+https://github.com/facebookresearch/detectron2.git'

Or, you can install Pre-built detectron2 (example for CUDA 10.2, Pytorch 1.9)

python -m pip install detectron2 -f \ https://dl.fbaipublicfiles.com/detectron2/wheels/cu102/torch1.9/index.html

More details can be found here.

Data Preparation

BDD100K

  1. Download the BDD100K MOT 2020 dataset (MOT 2020 Images and MOT 2020 Labels) and the detection labels (Detection 2020 Labels) here and the detailed description is available here. Put the BDD100K data under datasets/ in this repo. After downloading the data, the folder structure should be like below:
β”œβ”€β”€ datasets
β”‚Β Β  β”œβ”€β”€ bdd100k
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ images
β”‚Β Β  β”‚Β Β  β”‚Β Β   └── track
β”‚Β Β  β”‚Β Β  β”‚Β Β    Β Β  β”œβ”€β”€ train
β”‚Β Β  β”‚Β Β  β”‚Β Β    Β Β  β”œβ”€β”€ val
β”‚Β Β  β”‚   β”‚Β Β    Β   └── test
β”‚   β”‚   └── labels
β”‚Β Β  β”‚Β Β   Β Β   β”œβ”€β”€ box_track_20
β”‚Β Β  β”‚Β Β   Β Β   β”‚Β Β  β”œβ”€β”€ train
β”‚Β Β  β”‚Β Β       β”‚   └── val
β”‚   β”‚    Β Β   └── det_20
β”‚Β Β  β”‚Β Β  Β  Β    Β Β  β”œβ”€β”€ det_train.json
β”‚Β Β  β”‚Β Β           └── det_val.json
β”‚Β Β  β”œβ”€β”€ waymo

Convert the labels of the MOT 2020 data (train & val sets) into COCO format by running:

python3 datasets/bdd100k2coco.py -i datasets/bdd100k/labels/box_track_20/val/ -o datasets/bdd100k/labels/track/bdd100k_mot_val_coco.json -m track
python3 datasets/bdd100k2coco.py -i datasets/bdd100k/labels/box_track_20/train/ -o datasets/bdd100k/labels/track/bdd100k_mot_train_coco.json -m track

COCO

Download COCO2017 dataset from the official website.

Download the OOD dataset (json file) when the in-distribution dataset is Youtube-VIS from here.

Download the OOD dataset (json file) when the in-distribution dataset is BDD100k from here.

Put the two processed OOD json files to ./anntoations

The COCO dataset folder should have the following structure:

 └── datasets
     └── coco2017
         β”œβ”€β”€ annotations
            β”œβ”€β”€ xxx (the original json files)
            β”œβ”€β”€ instances_val2017_ood_wrt_bdd.json
            └── instances_val2017_ood_wrt_vis.json
         β”œβ”€β”€ train2017
         └── val2017

Youtube-VIS

Download the dataset from the official website.

Preprocess the dataset to generate the training and validation splits by running:

python datasets/convert_vis_val.py

The Youtube-VIS dataset folder should have the following structure:

 └── datasets
    └── vis
      └── train
        └── JPEGImages
        β”œβ”€β”€ instances_train.json
        └── instances_val.json

nuImages

Download the dataset from the official website.

Convert the dataset by running:

python datasets/convert_nu.py
python datasets/convert_nu_ood.py

The nuImages dataset folder should have the following structure:

 └── datasets
    └── nuscence
      └── v1.0-mini
      β”œβ”€β”€ v1.0-test
      β”œβ”€β”€ v1.0-val
      β”œβ”€β”€ v1.0-train
      β”œβ”€β”€ samples
      β”œβ”€β”€ semantic_masks
      β”œβ”€β”€ calibrated
      β”œβ”€β”€ nuimages_v1.0-val.json
      └── nu_ood.json

Before training, modify the dataset address in the ./src/data/builtin.py according to your local dataset address.

Training

Vanilla with BDD100K as the in-distribution dataset

python -m tools.train_net --config-file ./configs/BDD100k/R50_FPN_all.yaml --num-gpus 4

Vanilla with Youtube-VIS as the in-distribution dataset

python -m tools.train_net --config-file ./configs/VIS/R50_FPN_all.yaml --num-gpus 4

STUD on ResNet (BDD as ID data)

python -m tools.train_net --config-file ./configs/BDD100k/stud_resnet.yaml --num-gpus 4

STUD on RegNet (BDD as ID data)

python -m tools.train_net --config-file ./configs/BDD100k/stud_regnet.yaml --num-gpus 4

Download the pretrained backbone for RegNetX from here.

Pretrained models

The pretrained models for BDD100K can be downloaded from vanilla and STUD-ResNet and STUD-RegNet.

The pretrained models for Youtube-VIS can be downloaded from vanilla and STUD-ResNet and STUD-RegNet.

Evaluation

Evalutation with the in-distribution dataset to be BDD100K

Firstly run on the in-distribution dataset:

python -m tools.train_net --config-file ./configs/BDD100k/stud_resnet.yaml --num-gpus 4 --eval-only MODEL.WEIGHTS address/model_final.pth

where "address" is specified in the corresponding yaml file.

Then run on the OOD dataset (COCO):

python -m tools.train_net --config-file ./configs/BDD100k/stud_resnet_ood_coco.yaml --num-gpus 4 --eval-only MODEL.WEIGHTS address/model_final.pth

Obtain the metrics using:

python bdd_coco.py --energy 1 --model xxx

Here "--model" means the name of the directory that contains the checkpoint file. Evaluation on nuImages is similar.

Citation

If you found any part of this code is useful in your research, please consider citing our paper:

  @article{du2022stud,
      title={Unknown-Aware Object Detection: Learning What You Don’t Know from Videos in the Wild}, 
      author={Du, Xuefeng and Wang, Xin and Gozum, Gabriel and Li, Yixuan},
      journal={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
      year={2022}
}

More Repositories

1

vos

source code for ICLR'22 paper "VOS: Learning What You Don’t Know by Virtual Outlier Synthesis"
Python
306
star
2

knn-ood

Code for ICML 2022 paper "Out-of-distribution Detection with Deep Nearest Neighbors"
Python
171
star
3

large_scale_ood

MOS: Towards Scaling Out-of-distribution Detection for Large Semantic Space
Python
83
star
4

MCM

PyTorch implementation of MCM (Delving into out-of-distribution detection with vision-language representations), NeurIPS 2022
Python
65
star
5

dream-ood

source code for NeurIPS'23 paper "Dream the Impossible: Outlier Imagination with Diffusion Models"
Python
59
star
6

gradnorm_ood

On the Importance of Gradients for Detecting Distributional Shifts in the Wild
Python
52
star
7

npos

source code for ICLR'23 paper "Non-parametric Outlier Synthesis"
Python
51
star
8

react

Code for NeurIPS 2021 paper "ReAct: Out-of-distribution Detection With Rectified Activations"
Python
50
star
9

dice

Code for ECCV 2022 paper "DICE: Leveraging Sparsification for Out-of-Distribution Detection"
Python
39
star
10

opencon

Code for TMLR 2023 paper "OpenCon: Open-world Contrastive Learning"
Python
34
star
11

MOOD

Code for CVPR2021 paper: MOOD: Multi-level Out-of-distribution Detection
Python
33
star
12

siren

source code for NeurIPS'22 paper "SIREN: Shaping Representations for Detecting Out-of-Distribution Objects"
Python
32
star
13

multi-label-ood

Python
31
star
14

cider

PyTorch implementation of CIDER (How to exploit hyperspherical embeddings for out-of-distribution detection), ICLR 2023
Python
25
star
15

poem

PyTorch implementation of POEM (Out-of-distribution detection with posterior sampling), ICML 2022
Python
23
star
16

Spurious_OOD

Python
21
star
17

vit-spurious-robustness

Python
20
star
18

picle

Official code for ICML 2024 paper on Persona In-Context Learning (PICLe)
Python
20
star
19

NSCL

Code for ICML 2023 paper "When and How Does Known Class Help Discover Unknown Ones? Provable Understandings Through Spectral Analysis"
Python
13
star
20

sal

source code for ICLR'24 paper "How does unlabeled data provably help OOD detection?"
Python
10
star
21

sorl

Code for NeurIPS 2023 paper "A Graph-Theoretic Framework for Understanding Open-World Semi-Supervised Learning"
Python
7
star
22

scone

Python
7
star
23

hypo

Python
6
star
24

id_label

source code for ICML'24 paper "When and how does in-distribution label help out-of-distribution detection?"
Python
4
star
25

PG-DRO

Official Implementation of AAAI 2023 paper "Distributionally Robust Optimization with Probabilistic Groups"
Python
4
star
26

haloscope

source code for NeurIPS'24 paper "HaloScope: Harnessing Unlabeled LLM Generations for Hallucination Detection"
3
star