Skip to content

AdneneBoumessouer/BRICKS-Anomaly-Detection

Repository files navigation

Warning: This project is currently still in progress...

Unsupervised Anomaly Detection

This project proposes an end-to-end framework for unsupervised Anomaly Detection and Localization in images based on Convolutional Auto-Encoders.

Method Overview

The proposed method employs a thresholded pixel-wise difference between reconstructed image and input image to localize anomaly. The threshold is determined by using a subset of anomalous-free training images, i.e validation images, to determine a classification threshold to use at test-time.

It is inspired to by the papers MVTec AD — A Comprehensive Real-World Dataset for Unsupervised Anomaly Detection and Improving Unsupervised Defect Segmentation by Applying Structural Similarity to Autoencoders. The method is devided in 3 steps: training, validating and testing.

Models

There is a total of 5 models based on the Convolutional Auto-Encoder (CAE) architecture implemented in this project:

NOTE:

mvtecCAE, baselineCAE and inceptionCAE are comparable in performance.

WARNING:

resnetCAE and skipCAE, are still being tested, as they are prone to overfitting, which translates in the case of convolutional auto-encoders by copying its inputs without filtering out the defective regions.

Prerequisites

Dependencies

The main libraries used in this project with their corresponding versions are listed below:

  • tensorflow == 2.1.0
  • ktrain == 0.21.3
  • scikit-image == 0.16.2
  • scikit-learn == 0.23.2

For more information, refer to requirement.txt.

Installation

Before installing dependencies, we highly recommend setting up a virtual anvironment (e.g., anaconda environment).

  1. Make sure pip is up-to-date with: pip install -U pip
  2. Install TensorFlow 2 if it is not already installed (e.g., pip install tensorflow==2.1).
  3. Install ktrain: pip install ktrain
  4. Install scikit-image: pip install scikit-image
  5. Install scikit-learn: pip install scikit-learn

The above should be all you need on Linux systems and cloud computing environments like Google Colab and AWS EC2. If you are using ktrain on a Windows computer, you can follow the more detailed instructions provided here that include some extra steps.

Directory Structure using your own dataset

To train with your own dataset, you need to have a comparable directory structure. For example:

├── class1
│   ├── test
│   │   ├── good
│   │   ├── defect_type_1
│   │   ├── defect_type_2
│   │   └── ...
│   │── train
│   │   └── good
│   └── val
│       └── good
├── class2
│   ├── test
│   │   ├── good
│   │   ├── defect_type_1
│   │   ├── defect_type_2
│   │   └── ...
│   │── train
│   │   └── good
│   └── val
│       └── good
...

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages