Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

ICCV 2023: CLIPN for Zero-Shot OOD Detection: Teaching CLIP to Say No

License

NotificationsYou must be signed in to change notification settings

xmed-lab/CLIPN

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Updates

  • The codes of CLIPN with hand-crafted prompts are released (./hand-crafted).
  • The codes of CLIPN with learnable prompts are released (./src).
  • Thanks to the valuable suggestions from the reviewers of CVPR 2023 and ICCV 2023, our paper has been significantly improved, allowing it to be published at ICCV 2023.
  • If you are interested in CLIP-based open vocabulary tasks, please feel free to visit our another work!"CLIP Surgery for Better Explainability with Enhancement in Open-Vocabulary Tasks" (github).

⭐ Highlights of CLIPN

  • CLIPN attains SoTA performance in zero-shot OOD detection, all the while inheriting the in-distribution (ID) classification prowess of CLIP.
  • CLIPN offers an approach for unsupervised prompt learning using image-text-paired web-dataset.

🔨 Installation

  • Main python libraries of our experimental environment are shown inrequirements.txt. You can install CLIPN following:
git clone https://github.com/xmed-lab/CLIPN.gitcd CLIPNconda create -n CLIPNconda activate CLIPNpip install -r ./requirements.txt

💻 Prepare Dataset

  • Pre-training Dataset, CC3M.To download CC3M dataset as webdataset, please followimg2dataset.

When you have downloaded CC3M, please re-write your data root into./src/run.sh.

  • OOD detection datasets.
    • ID dataset, ImageNet-1K: The ImageNet-1k dataset (ILSVRC-2012) can be downloadedhere.
    • OOD dataset, iNaturalist, SUN, Places, and Texture. Please follow instruction from these two repositoriesMOS andMCM to download the subsampled datasets where semantically overlapped classes with ImageNet-1k are removed.

When you have downloaded the above datasets, please re-write your data root into./src/tuning_util.py.

🔑 Pre-Train and Evaluate CLIPN

  • Pre-train CLIPN on CC3M.This step is to empower "no" logic within CLIP via the web-dataset.
cd ./srcsh run.sh
  • Zero-Shot Evaluate CLIPN on ImageNet-1K.
    • Metrics and pipeline are defined in./src/zero_shot_infer.py. Here you can find three baseline methods, and our two inference algorithms: CTW and ATD (see Line 91-96).
    • Dataset details are defined in./src/tuning_util.py.
    • Inference models are defined in./src/classification.py, including converting the text encoders into classifiers.
    • You can download the models provided in the table below or pre-trained by yourself. Then re-write the path of your models in the main function of./src/zero_shot_infer.py. Finally, evaluate CLIPN by:
python3 zero_shot_infer.py

📘 Reproduced Results

To ensure the reproducibility of the results, we conducted three repeated experiments under each configuration. The following will exhibit the most recent reproduced results achieved before open-sourcing.

  • ImageNet-1K
MethodsRepeatiNaturalistSUNTexturesPlacesAvgModel/log
AUROCFPR95AUROCFPR95AUROCFPR95AUROCFPR95AUROCFPR95
ViT-B-16
CLIPN-CTW193.1226.3188.4637.6779.1757.1486.1443.33__here
293.4821.0689.7930.3183.3146.4488.2133..85__here
391.7925.8489.7631.3076.7659.2587.6636.58__here
Avg92.8024.4189.3433.0979.7554.2887.3437.9287.3137.42_
CLIPN-ATD195.6521.7393.2229.5190.3542.8991.2536.98__here
296.6716.7194.7723.4192.4634.7393.3929.24__here
396.2918.9094.5524.1589.6145.1293.2330.11__here
Avg96.2019.1194.1825.6990.8140.9192.6232.1193.4529.46_

The performance in this table is better than our paper , because that we add an average learnable "no" prompt (seeLine 600-616 in./src/open_clip/model.py).

📝 Other Tips

There are several important factors that could affect the performance:

  • Class prompt texts. In the inference period, we need to use prompt texts to get the weights of classifier (see./src/prompt/prompt.txt). You can hand on the design of high-performance inference prompts for our CLIPN.
  • The number of learnable "no" tokens. Now I just define the number of learnable "no" tokens as 16. You can vary it to find an optimal value.
  • If you have any ideas to enhance CLIPN or attempt to transfer this idea to other topics, feel free to discuss with me and I am happy to share some ideas with you.

📚 Citation

If you find our paper helps you, please kindly consider citing our paper in your publications.

@inproceedings{wang2023clipn,  title={CLIPNfor Zero-Shot OOD Detection: Teaching CLIP to Say No},  author={Wang, Hualiang and Li, Yi and Yao, Huifeng and Li, Xiaomeng},  booktitle={Proceedings of the IEEE/CVF International Conference on Computer Vision},  pages={1802--1812},  year={2023}}

🍻 Acknowledge

We sincerely appreciate these three highly valuable repositoriesopen_clip,MOS andMCM.

About

ICCV 2023: CLIPN for Zero-Shot OOD Detection: Teaching CLIP to Say No

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp