GithubHelp home page GithubHelp logo

xlinsplunk / anomalyclip Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zqhang/anomalyclip

0.0 0.0 0.0 56.5 MB

Official implementation for AnomalyCLIP (ICLR 2024)

Shell 1.86% Python 98.14%

anomalyclip's Introduction

AnomalyCLIP

[ICLR 24] AnomalyCLIP: Object-agnostic Prompt Learning for Zero-shot Anomaly Detection

by Qihang Zhou*, Guansong Pang*, Yu Tian, Shibo He, Jiming Chen.

Updates

  • 03.19.2024: Code has been released !!!

Introduction

Zero-shot anomaly detection (ZSAD) requires detection models trained using auxiliary data to detect anomalies without any training sample in a target dataset. It is a crucial task when training data is not accessible due to various concerns, e.g., data privacy, yet it is challenging since the models need to generalize to anomalies across different domains where the appearance of foreground objects, abnormal regions, and background features, such as defects/tumors on different products/organs, can vary significantly. Recently large pre-trained vision-language models (VLMs), such as CLIP, have demonstrated strong zero-shot recognition ability in various vision tasks, including anomaly detection. However, their ZSAD performance is weak since the VLMs focus more on modeling the class semantics of the foreground objects rather than the abnormality/normality in the images. In this paper we introduce a novel approach, namely AnomalyCLIP, to adapt CLIP for accurate ZSAD across different domains. The key insight of AnomalyCLIP is to learn object-agnostic text prompts that capture generic normality and abnormality in an image regardless of its foreground objects. This allows our model to focus on the abnormal image regions rather than the object semantics, enabling generalized normality and abnormality recognition on diverse types of objects. Large-scale experiments on 17 real-world anomaly detection datasets show that AnomalyCLIP achieves superior zero-shot performance of detecting and segmenting anomalies in datasets of highly diverse class semantics from various defect inspection and medical imaging domains. All experiments are conducted in PyTorch-2.0.0 with a single NVIDIA RTX 3090 24GB.

Overview of AnomalyCLIP

overview

Analysis of different text prompt templates

analysis

How to Run

Prepare your dataset

Download the dataset below:

Generate the dataset JSON

cd generate_dataset_json
python mvtec.py

Select the corresponding script and run it (we provide all scripts for datasets that AnomalyCLIP reported). The generated JSON stores all the information that AnomalyCLIP needs.

Run AnomalyCLIP

  • Quick start (use the pre-trained weights)
bash test.sh
  • Train your own weights
bash train.sh

Main results

Industrial dataset

industrial

Medical dataset

medical

Visualization

hazelnut

capusle

skin

brain

We provide the reproduction of WinCLIP here

BibTex Citation

If you find this paper and repository useful, please cite our paper.

@inproceedings{
zhou2024anomalyclip,
title={Anomaly{CLIP}: Object-agnostic Prompt Learning for Zero-shot Anomaly Detection},
author={Qihang Zhou and Guansong Pang and Yu Tian and Shibo He and Jiming Chen},
booktitle={The Twelfth International Conference on Learning Representations},
year={2024},
url={https://openreview.net/forum?id=buC4E91xZE}
}

anomalyclip's People

Contributors

zqhang avatar tianyu0207 avatar

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.