Official PyTorch implementation of "Universal Novelty Detection Through Adaptive Contrastive Learning" (CVPR 2024) by Hossein Mirzaei, Mojtaba Nafez, Mohammad Jafari, Mohammad Bagher Soltani, Jafar Habibi, Mohammad Sabokrou, and MohammadHossein Rohban.
- torchlars == 0.1.2
Dataset Download Link:
To train our models, run this command:
python train.py --model $model --epochs $epochs --eval_steps $eval_steps --normal_class $normal_class --normal_data_count $normal_data_count --image_size $image_size --dataset $dataset --batch_size $batch_size --outlier_dataset $outlier_dataset
-
The option
--normal_class
denotes the in-distribution for one-class training. -
For multi-class training, set
--outlier_dataset
as the OOD target dataset, and --dataset will be the determined ID dataset.
Note: The
config.json
file specifies the probability of each negative transformation used during training. This probability distribution is determined by the AutoAugOOD module inAutoAugOOD.ipynb
individually for each dataset and each normal class.
We provide the checkpoint of the Unode pre-trained model. Download the checkpoint from the following link:
To evaluate our model, run this command:
python ./eval.py --normal_class $normal_class --image_size $image_size --dataset $dataset --model $model --print_score --ood_samples 10 --resize_factor 0.54 --resize_fix --load_path $load_path
-
The option
--normal_class
denotes the in-distribution for one-class training. -
For multi-class training, set
--outlier_dataset
as the OOD target dataset, and --dataset will be the determined ID dataset. -
The resize_factor & resize fix option fix the cropping size of RandomResizedCrop().
Google Colab notebook as an example of training and evaluation.
@InProceedings{Mirzaei_2024_CVPR,
author = {Mirzaei, Hossein and Nafez, Mojtaba and Jafari, Mohammad and Soltani, Mohammad Bagher and Azizmalayeri, Mohammad and Habibi, Jafar and Sabokrou, Mohammad and Rohban, Mohammad Hossein},
title = {Universal Novelty Detection Through Adaptive Contrastive Learning},
booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
month = {June},
year = {2024},
pages = {22914-22923}
}