Giter Site home page Giter Site logo

fastflow's Introduction

FastFlow

An unofficial PyTorch implementation of FastFlow: Unsupervised Anomaly Detection and Localization via 2D Normalizing Flows (Jiawei Yu et al.).

We modified some of FrEIA module to output Jacobian determinant which has same shape of the input data, here.

Installation

  1. Clone this repository.
  2. Download MVTecAD dataset from https://www.mvtec.com/company/research/datasets/mvtec-ad and place it in the directory of your choice.
  3. Install python packages on your system with pip install -r requirements.txt.

Versions of our system is listed below.

OS      : Ubuntu 18.04.5
CUDA    : 11.3
cudnn   : 8.2.0.53-1
python  : 3.7.11
FrEIA   : 0.2

Training models

  1. Replace paths (and other configs if needed) in config.py to fit your environment.
mvtec_path = "/path/to/MVtecAD" ## path you placed the dataset.
weight_path = "./weights" ## directory to save fastflow model weights.
result_path = "./results" ## directory to save logs.
  1. Run python main.py.

Evaluation on test dataset runs every validate_per_epoch(in config.py) epochs.

Metrics

Image level AUROC

category bottle cable capsule carpet grid hazelnut leather metul_nut pill screw tile toothbrush transistor wood zipper
impl 1.000 0.919 0.977 1.000 0.998 1.000 1.000 0.998 0.992 0.846 0.999 0.872 0.965 0.987 0.942
paper 1.000 1.000 1.000 1.000 0.997 1.000 1.000 1.000 0.994 0.978 1.000 0.944 0.998 1.000 0.995
diff 0.000 -0.081 -0.023 0.000 0.001 0.000 0.000 -0.002 -0.002 -0.132 -0.001 -0.072 -0.033 -0.013 -0.053

Pixel Level AUROC

category bottle cable capsule carpet grid hazelnut leather metul_nut pill screw tile toothbrush transistor wood zipper
impl 0.983 0.977 0.991 0.995 0.978 0.991 0.995 0.980 0.989 0.992 0.966 0.987 0.944 0.959 0.978
paper 0.977 0.984 0.991 0.994 0.983 0.991 0.995 0.985 0.992 0.994 0.963 0.989 0.973 0.970 0.987
diff 0.006 -0.007 0.000 0.001 -0.005 0.000 0.000 -0.005 -0.003 -0.002 0.003 -0.002 -0.029 -0.011 -0.009

fastflow's People

Contributors

yushi-okunishi avatar jankenshow avatar yushi-okuinishi avatar

Stargazers

EricaFan avatar double997 avatar  avatar zhaofefe avatar  avatar  avatar Shihao avatar xfby avatar  avatar Elvis avatar  avatar ivan avatar  avatar Gerard avatar  avatar  avatar  avatar  avatar

Watchers

3panda avatar  avatar

fastflow's Issues

Custom datasets

Hello, I made an error with custom datasets, how can I solve it?
image

Loss in fastflow

return (squared_error - jacob, squared_error, jacob)

In the paper in the introduction section they describe in the contributions:

"We propose a 2D normalizing flow denoted as FastFlow
for anomaly detection and localization with fully convolutional networks and two-dimensional loss function to
effectively model global and local distribution"

Is there a reason why the loss isn't computed pixelwise prior to mean reduction. Right now you mean reduce both the Z.^2 and J terms separately prior to computing the difference. From the phrasing of the paper, i would have expected this to be written as:

def calc_loss(z,j):
    return torch.sum(0.5*z**-j,(1,2,3))

Obviously I'm guessing since the paper doesn't describe specifics, but just thought I'd check how you arrived at the current form of the loss?

RuntimeError: CUDA out of memory.

When I run it, it raises RuntimeError: CUDA out of memory. Tried to allocate 74.00 MiB (GPU 0; 11.91 GiB total capacity; 10.79 GiB already allocated; 12.94 MiB free; 11.21 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF
I want to know how large the memory of gpu is needed.

Empty auroc images

Hello, after executing the code main.py, multiple files get saved in the results folder. But all the auroc images are empty..why is that? I would be very grateful for someone's help

bottle_auroc
capsule_auroc

How to run train.py

TypeError: init() missing 2 required positional arguments: 'ac' and 'config'

test implementation

Hi, could I use test implementation? I have a problem with save_path. Did you use 500 epochs for training phase based on the paper?

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.