Anomaly Detection via Reverse Distillation from One-Class Embedding

Related tags

Documentation RD4AD
Overview

Anomaly Detection via Reverse Distillation from One-Class Embedding

Implementation (Official Code ⭐️ ⭐️ ⭐️ )

  1. Environment

    pytorch == 1.91

    torchvision == 0.10.1

    numpy == 1.20.3

    scipy == 1.7.1

    sklearn == 1.0

    PIL == 8.3.2

  2. Dataset

    You should download MVTec from MVTec AD: MVTec Software. The folder "mvtec" should be unpacked into the code folder.

  3. Train and Test the Model We have write both training and evaluation function in the main.py, execute the following command to see the training and evaluation results.

    python main.py

Reference

@article{deng2022anomaly,    
title={Anomaly Detection via Reverse Distillation from One-Class Embedding},
author={Deng, Hanqiu and Li, Xingyu},
journal={arXiv preprint arXiv:2201.10703},
year={2022}
}
Comments
  • about OCE

    about OCE

    Hi, sir. Thanks for your great job, I have some confuse about OCBE :

    MFF aligns multi-scale features from teacher E and OCE condenses the obtained rich feature to a compact bottleneck code. But, the MMF part can did all things above. Why still use OCE module? Table 5 shows ablation study on Pre, Pre+OCE, Pre+OCE+MFF.
    did you do the ablation study on pre+MFF?

    OCBE module condenses the multi-scale patterns into an extreme low-dimensional space for downstream normal representation reconstruction. Then, the abnormal representations generated by the teacher model are likely to be abandoned by OCBE. why????

    I am looking forward to your reply! Thanks.

    opened by tommying 4
  • How to do your ablation study

    How to do your ablation study

    Dear Author I want to do the ablation study of your network ,but i have some question about it 。 ablation_table if I want to use the single-layer features M1, how should I do the ablation study,like the first pic below or the latter one? ablation1 ablation2

    opened by 22strongestme 3
  • Can this model perform classification?

    Can this model perform classification?

    Hi, first I was deeply impressed by your model, and I have a question

    Is auroc_sp the number of classification?

    Can this model perform classication?

    Thank you for your wonderful work and I look forward to your reply.

    opened by AppleJoker94 2
  • License

    License

    Thanks for releasing the official implementation! I am working on integrating Reverse Distillation model into Anomalib. Can you provide a license for your code?

    opened by ashwinvaidya17 2
  • How to do the experiments of 4.2. One-Class Novelty Detection

    How to do the experiments of 4.2. One-Class Novelty Detection

    Thanks for your great job, I have some questions: 1.the MVTecDataset has about 17 classes data, the code shows every class train and save a model, do you try to train a model can work on all classes data? 2.how to train One-Class Novelty Detection with cifar10 and mnist, just train with one class data, the others for test as anomaly? could you show the code? 3.How to predict a picture and judge whether it is abnormal? inputs = encoder(img) outputs = decoder(bn(inputs))#bn(inputs)) loss = loss_fucntion(inputs, outputs) judge whether it is abnormal with loss? and the the threshold? 4. the Official Code not save the encoder model, the encoder parameter just use the pretrain model and not update?
    torch.save({'bn': bn.state_dict(), 'decoder': decoder.state_dict()}, ckp_path) many thanks

    opened by kenh1991 2
  • RUN ERROE!

    RUN ERROE!

    Traceback (most recent call last): File "/media/pmj/e/code/anomaly_code/RD4AD-main/main.py", line 121, in train(i) File "/media/pmj/e/code/anomaly_code/RD4AD-main/main.py", line 105, in train auroc_px, auroc_sp, aupro_px = evaluation(encoder, bn, decoder, test_dataloader, device) File "/media/pmj/e/code/anomaly_code/RD4AD-main/test.py", line 89, in evaluation anomaly_map[np.newaxis,:,:])) File "/media/pmj/e/code/anomaly_code/RD4AD-main/test.py", line 355, in compute_pro df = pd.DataFrame([], columns=["pro", "fpr", "threshold"]) File "/home/pmj/anaconda3/lib/python3.7/site-packages/pandas/core/frame.py", line 490, in init mgr = init_dict({}, index, columns, dtype=dtype) File "/home/pmj/anaconda3/lib/python3.7/site-packages/pandas/core/internals/construction.py", line 239, in init_dict val = construct_1d_arraylike_from_scalar(np.nan, len(index), nan_dtype) File "/home/pmj/anaconda3/lib/python3.7/site-packages/pandas/core/dtypes/cast.py", line 1449, in construct_1d_arraylike_from_scalar dtype = dtype.dtype AttributeError: type object 'object' has no attribute 'dtype'

    opened by pmj828 1
  • AssertionError: set(masks.flatten()) must be {0, 1}

    AssertionError: set(masks.flatten()) must be {0, 1}

    hello

    assert set(masks.flatten()) == {0, 1}, "set(masks.flatten()) must be {0, 1}" AssertionError: set(masks.flatten()) must be {0, 1}

    This error occurs when testing. how should we solve it? But our image is already a binary map, so this problem should not occur.

    opened by nicebro123 1
  • The relationship ?

    The relationship ?

    I would like to ask why the multi-scale anomaly score map can directly calculate the AUROC with the ground truth. What is the relationship between the anomalies represented by the feature similarity output of the network layer and the anomalies shown by the annotations?

    opened by 995667874 15
Owner
null
Valentine-with-Python - A Python program generates an animation of a heart with cool texts of your loved one

Valentine with Python Valentines with Python is a mini fun project I have coded.

Niraj Tiwari 4 Dec 31, 2022
Materi workshop "Light up your Python!" Himpunan Mahasiswa Sistem Informasi Fakultas Ilmu Komputer Universitas Singaperbangsa Karawang, 4 September 2021 (Online via Zoom).

Workshop Python UNSIKA 2021 Materi workshop "Light up your Python!" Himpunan Mahasiswa Sistem Informasi Fakultas Ilmu Komputer Universitas Singaperban

Eka Putra 20 Mar 24, 2022
DataRisk Detection Learning Resources

DataRisk Detection Learning Resources Data security: Based on the "data-centric security system" position, it generally refers to the entire security

Liao Wenzhe 59 Dec 5, 2022
One Stop Anomaly Shop: Anomaly detection using two-phase approach: (a) pre-labeling using statistics, Natural Language Processing and static rules; (b) anomaly scoring using supervised and unsupervised machine learning.

One Stop Anomaly Shop (OSAS) Quick start guide Step 1: Get/build the docker image Option 1: Use precompiled image (might not reflect latest changes):

Adobe, Inc. 148 Dec 26, 2022
Anomaly Transformer: Time Series Anomaly Detection with Association Discrepancy" (ICLR 2022 Spotlight)

About Code release for Anomaly Transformer: Time Series Anomaly Detection with Association Discrepancy (ICLR 2022 Spotlight)

THUML @ Tsinghua University 221 Dec 31, 2022
Motion detector, Full body detection, Upper body detection, Cat face detection, Smile detection, Face detection (haar cascade), Silverware detection, Face detection (lbp), and Sending email notifications

Security camera running OpenCV for object and motion detection. The camera will send email with image of any objects it detects. It also runs a server that provides web interface with live stream video.

Peace 10 Jun 30, 2021
[IJCAI-2021] A benchmark of data-free knowledge distillation from paper "Contrastive Model Inversion for Data-Free Knowledge Distillation"

DataFree A benchmark of data-free knowledge distillation from paper "Contrastive Model Inversion for Data-Free Knowledge Distillation" Authors: Gongfa

ZJU-VIPA 47 Jan 9, 2023
TF2 implementation of knowledge distillation using the "function matching" hypothesis from the paper Knowledge distillation: A good teacher is patient and consistent by Beyer et al.

FunMatch-Distillation TF2 implementation of knowledge distillation using the "function matching" hypothesis from the paper Knowledge distillation: A g

Sayak Paul 67 Dec 20, 2022
CKD - Collaborative Knowledge Distillation for Heterogeneous Information Network Embedding

Collaborative Knowledge Distillation for Heterogeneous Information Network Embed

zhousheng 9 Dec 5, 2022
Neural building blocks for speaker diarization: speech activity detection, speaker change detection, overlapped speech detection, speaker embedding

⚠️ Checkout develop branch to see what is coming in pyannote.audio 2.0: a much smaller and cleaner codebase Python-first API (the good old pyannote-au

pyannote 2.1k Dec 31, 2022
Neural building blocks for speaker diarization: speech activity detection, speaker change detection, overlapped speech detection, speaker embedding

⚠️ Checkout develop branch to see what is coming in pyannote.audio 2.0: a much smaller and cleaner codebase Python-first API (the good old pyannote-au

pyannote 2.2k Jan 9, 2023
Working demo of the Multi-class and Anomaly classification model using the CLIP feature space

??️ Hindsight AI: Crime Classification With Clip About For Educational Purposes Only This is a recursive neural net trained to classify specific crime

Miles Tweed 2 Jun 5, 2022
Official PyTorch code for WACV 2022 paper "CFLOW-AD: Real-Time Unsupervised Anomaly Detection with Localization via Conditional Normalizing Flows"

CFLOW-AD: Real-Time Unsupervised Anomaly Detection with Localization via Conditional Normalizing Flows WACV 2022 preprint:https://arxiv.org/abs/2107.1

Denis 156 Dec 28, 2022
A Pytorch implement of paper "Anomaly detection in dynamic graphs via transformer" (TADDY).

TADDY: Anomaly detection in dynamic graphs via transformer This repo covers an reference implementation for the paper "Anomaly detection in dynamic gr

Yue Tan 21 Nov 24, 2022
One version package to rule them all, One version package to find them, One version package to bring them all, and in the darkness bind them.

AwesomeVersion One version package to rule them all, One version package to find them, One version package to bring them all, and in the darkness bind

Joakim Sørensen 39 Dec 31, 2022
(JMLR'19) A Python Toolbox for Scalable Outlier Detection (Anomaly Detection)

Python Outlier Detection (PyOD) Deployment & Documentation & Stats Build Status & Coverage & Maintainability & License PyOD is a comprehensive and sca

Yue Zhao 6.6k Jan 3, 2023
Streaming Anomaly Detection Framework in Python (Outlier Detection for Streaming Data)

Python Streaming Anomaly Detection (PySAD) PySAD is an open-source python framework for anomaly detection on streaming multivariate data. Documentatio

Selim Firat Yilmaz 181 Dec 18, 2022
deployment of a hybrid model for automatic weapon detection/ anomaly detection for surveillance applications

Automatic Weapon Detection Deployment of a hybrid model for automatic weapon detection/ anomaly detection for surveillance applications. Loved the pro

Janhavi 4 Mar 4, 2022
A Python Library for Graph Outlier Detection (Anomaly Detection)

PyGOD is a Python library for graph outlier detection (anomaly detection). This exciting yet challenging field has many key applications, e.g., detect

PyGOD Team 757 Jan 4, 2023