Anomaly Detection via Reverse Distillation from One-Class Embedding

Related tags

Admin Panels 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 0
  • 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
'Rethinking Knowledge Distillation via Cross-Entropy' and 'ViTKD: Practical Guidelines for ViT feature knowledge distillation'

Knowledge Distillation for Image Classification This repository includes official implementation for the following papers: NKD and tf-NKD: Rethinking

Mesopotamia 60 Nov 10, 2022
Joint Multi-Person Body Detection and Orientation Estimation via One Unified Embedding

JointBDOE Code for my paper Joint Multi-Person Body Detection and Orientation Estimation via One Unified Embedding submitted to ICASSP 2023 Abstract:

Huayi Zhou 4 Nov 17, 2022
[NeurIPS 2022] A Unified Model for Multi-class Anomaly Detection

UniAD Official PyTorch Implementation of A Unified Model for Multi-class Anomaly Detection, Accepted by NeurIPS 2022. 1. Quick Start 1.1 MVTec-AD Crea

You Zhiyuan 70 Nov 19, 2022
Unsupervised Face Morphing Attack Detection via Self-paced Anomaly Detection

SPL-MAD: Unsupervised Face Morphing Attack Detection via Self-paced Anomaly Detection Note This is the official repository of the paper: Unsupervised

null 5 Aug 15, 2022
Predict a CLIP image embedding from its text embedding using a diffusion prior.

Conditioned Prior (WIP) Weights and code by @nousr Predict a CLIP image embedding from its text embedding using a diffusion prior. This code is part o

LAION AI 6 Nov 17, 2022
Spatial region-related embedding and Cell type-related embedding of spatial transcriptomics.

SECE Spatial region-related embedding and Cell type-related embedding of spatial transcriptomics. Spatially resolved transcriptomics sequencing (ST-se

null 1 Sep 20, 2022
An official implementation of "Decomposed Knowledge Distillation for Class-incremental Semantic Segmentation" (NeurIPS 2022) in PyTorch.

Decomposed Knowledge Distillation for Class-Incremental Semantic Segmentation This is an official implementation of the paper "Decomposed Knowledge Di

CV Lab @ Yonsei University 20 Nov 26, 2022
Anomaly detection framework using multiple detection techniques and voting mechanism.

Real-time IoT robust anomaly detection framework With rapid digitalization of the economy, we experience exponential growth of real time data being pr

Jakub Augustin 3 Oct 12, 2022
[ECCV2022] KD-SCFNet: Towards More Accurate and Efficient Salient Object Detection via Knowledge Distillation

KD-SCFNet KD-SCFNet: Towards More Accurate and Efficient Salient Object Detection via Knowledge Distillation Jin Zhang, Qiuwei Liang, Yanjiao Shi Euro

ZhangJin 18 Aug 9, 2022
Code for NAACL2022 main conference paper "One Reference Is Not Enough: Diverse Distillation with Reference Selection for Non-Autoregressive Translation"

One Reference Is Not Enough: Diverse Distillation with Reference Selection for Non-Autoregressive Translation This repository contains the source code

ICTNLP 4 Jul 17, 2022
This repo is the official megengine implementation of the ECCV2022 paper: Efficient One Pass Self-distillation with Zipf's Label Smoothing.

This repo is the official megengine implementation of the ECCV2022 paper: Efficient One Pass Self-distillation with Zipf's Label Smoothing. The pytorc

MEGVII Research 20 Nov 10, 2022
PyTorch code for the paper Class-incremental Novel Class Discovery (ECCV 2022)

Class-incremental Novel Class Discovery (ECCV2022) This Github repository presents the PyTorch implementation for the paper Class-incremental Novel Cl

Mingxuan 41 Nov 17, 2022
PyTorch code for the paper Class-incremental Novel Class Discovery (ECCV 2022)

Class-incremental Novel Class Discovery (ECCV2022) Class-incremental Novel Class Discovery (ECCV2022) Subhankar Roy, Mingxuan Liu, Zhun Zhong, Nicu Se

Mingxuan 17 Jul 19, 2022
This is a possible solution to reverse the sha256 hash, but not an efficient one

Description This python script is a possible solution to reverse the SHA256 hash value! But there is a headache of huge time complexity. So we need a

M S K 1 Jul 8, 2022
Official Implementation for the "An Empirical Investigation of 3D Anomaly Detection and Segmentation" paper.

An Empirical Investigation of 3D Anomaly Detection and Segmentation Project | Paper Official PyTorch Implementation for the "An Empirical Investigatio

Eliahu Horwitz 53 Nov 28, 2022
PyTorch implementation of the paper: Dual-Distribution Discrepancy for Anomaly Detection in Chest X-Rays (MICCAI 2022)

DDAD (MICCAI 2022) This is the PyTorch implementation of our paper: Dual-Distribution Discrepancy for Anomaly Detection in Chest X-Rays Yu Cai, Hao Ch

Yu Cai 38 Oct 24, 2022
[TMM 2022] Self-Supervised Masking for Unsupervised Anomaly Detection and Localization

Self-Supervised Masking for Unsupervised Anomaly Detection and Localization This is an implementation of “Self-Supervised Masking for Unsupervised Ano

null 9 Sep 30, 2022
MTAD: Tools and Benchmark for Multivariate Time Series Anomaly Detection

MTAD: Tools and Benchmark for Multivariate Time Series Anomaly Detection This repository is a Multivariate Time Series Anomaly Detection toolkit named

OpsPAI 20 Nov 11, 2022