Skip to content

Student–Teacher Anomaly Detection with Discriminative Latent Embeddings

Notifications You must be signed in to change notification settings

denguir/student-teacher-anomaly-detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Student-Teacher anomaly detection

This is an implementation of the paper Uninformed Students: Student–Teacher Anomaly Detection with Discriminative Latent Embeddings.

How to use

  • Run the mvtec_dataset.sh script to download and prepare the MVTec dataset in the correct format. This requires about 5GB of disk space.
./mvtec_dataset.sh
  • The data folder should be available now. Each subfolder in data has the name of a category. Let us build a model for the category carpet as an example.

  • (Optional) Run resnet18_training.py script to train resnet18 further on your dataset

cd src
python3 resnet18_training.py --dataset carpet
  • Run teacher_training.py to distil the knowledge of resnet18 on a smaller neural network. This will speed up the processing of images. This neural network, called the Teacher, outputs a 512-dimensional description vector for each patch of size <patch_size> of the image. The supported patch_size values are:
    • size = 17, effective if we are looking for small size anomalies
    • size = 33, effective if we are looking for medium size anomalies
    • size = 65, effective if we are looking for big size anomalies
cd src
python3 teacher_training.py --dataset carpet --patch_size 33 
  • Run students_training.py to train a set of M=3 students against the teacher network. The training of the students is done on an anomaly-free dataset. We expect them to generalize poorly in images containing anomalies
cd src
python students_training.py --dataset carpet --patch_size 33 --n_students 3
  • Run anomaly_detection.py to obtain an anomaly map for each image of the test set. An anomaly map is computed using the variance of Students predictions and the error between Students predictions and Teacher.
cd src
python anomaly_detection.py --dataset carpet --patch_size 33 --n_students 3

Results

result 1 result 2 result 5

And more results are available under /result folder

Performance

roc

References

Original paper

MVTec dataset paper

Fast Dense Feature Extraction

Releases

No releases published

Packages

No packages published