Code for paper entitled "Improving Novelty Detection using the Reconstructions of Nearest Neighbours"

Related tags

Deep Learning NLN
Overview

NLN: Nearest-Latent-Neighbours

A repository containing the implementation of the paper entitled Improving Novelty Detection using the Reconstructions of Nearest Neighbours

Installation

Install conda environment by:

    conda create --name nln python=3.7

Run conda environment by:

    conda activate nln

Install dependancies by running:

    pip install -r dependancies

Additionally for training on a GPU run:

    conda install -c anaconda tensorflow-gpu=2.2.0

Replication of results in paper

Run the following to replicate the results for MNIST, CIFAR-10, Fashion-MNIST and MVTec-AD respectively

    sh experiments/run_mnist.sh
    sh experiments/run_cifar.sh
    sh experiments/run_fmnist.sh
    sh experiments/run_mvtec.sh

Or to execute all experiments sequentially the following script can be run:

    sh experiments/run_all.sh

MVTec-AD usage

You will need to download the MVTec anomaly detection dataset and specify the its path using -mvtec_path command line option.

Training

Run the following:

    python main.py -anomaly_class <0,1,2,3,4,5,6,7,8,9,bottle,cable,...> \
                   -percentage_anomaly <float> \
                   -limit <int> \
                   -epochs <int> \
                   -latent_dim <int> \
                   -data <MNIST,FASHION_MNIST,CIFAR10,MVTEC> \
                   -mvtec_path <str>\
                   -neighbors <int(s)> \
                   -algorithm <knn> \
		   -patches <True, False> \
		   -crop <True, False> \
		   -rotate <True, False> \
		   -patch_x <int> \    
		   -patch_y <int> \    
		   -patch_x_stride <int> \    
		   -patch_y_stride <int> \    
		   -crop_x <int> \    
		   -crop_y <int> \    

Reporting Results

Run the following given the correctly generated results files:

    python report.py -data <MNIST,CIFAR10,FASHION_MNIST,MVTEC> -seed <filepath-seed>

Licensing

Source code of NLN is licensed under the MIT License.

Comments
  • Refactor Code

    Refactor Code

    General

    Issue documenting post submission code refactoring.

    • [x] Merge branches on gpu-01 and gpu-02
    • [x] ~~Join together mvtec_metrics and nln_metrics so that the nearest neighbour search isn't done twice~~
      • Left separate as its easier to follow
    • [x] Add /reporting/segmentation.py to be automatically generated after training model
    • [x] Add /reporting/residuals.py to be automatically generated after training model
    • [x] Remove unused architectures from /architecture
    • [x] neval.py needs to be integrated into training pipeline for mvtec data
    • [x] Make cmd argument for MVTec data directory path
    opened by mesarcik 1
  • Models failing to converge

    Models failing to converge

    Description

    A number of models are failing to converge, this issue documents this problem.

    AE

    • [x] zipper

    VAE

    • [x] wood
    • [x] zipper

    AAE

    • [x] wood
    • [x] zipper

    AE-con

    • [x] carpet
    • [x] cable
    • [x] pill
    • [x] screw
    • [x] tile
    • [x] toothbrush
    • [x] wood
    • [x] zipper

    AE-res

    • [x] capsule (working version on gpu-01)
    • [x] hazelnut
    • [x] leather
    • [X] toothbrush
    • [x] wood
    • [x] zipper
    opened by mesarcik 0
  • Model_loader changes and comments added

    Model_loader changes and comments added

    • In model_loader.py the load_model() function was removed as it is not used and was written for an earlier version of the software
    • Docstrings added where necessary
    opened by mesarcik 0
  • AE error restored by procesing training data

    AE error restored by procesing training data

    • Added process() to data.py
    • Uses sklearn.MinMaxScaler on a per image basis to scale the images between 0 and 1
    • Seems to fix the bug with the AE error exploding
    opened by mesarcik 0
  • tf.abs was replaced with np.abs, sklearn dependancies updated

    tf.abs was replaced with np.abs, sklearn dependancies updated

    • tf.abs was resulting in tf.nans so it was replaced with np
    • sklearn doesn't automatically install 0.23.2 so updated it in the dependancies.
    • It all seems to be working now on das5
    opened by mesarcik 0
Owner
Michael (Misha) Mesarcik
Electrical and Computer Engineer
Michael (Misha) Mesarcik
This is the official source code for SLATE. We provide the code for the model, the training code, and a dataset loader for the 3D Shapes dataset. This code is implemented in Pytorch.

SLATE This is the official source code for SLATE. We provide the code for the model, the training code and a dataset loader for the 3D Shapes dataset.

Gautam Singh 66 Dec 26, 2022
Code for paper ECCV 2020 paper: Who Left the Dogs Out? 3D Animal Reconstruction with Expectation Maximization in the Loop.

Who Left the Dogs Out? Evaluation and demo code for our ECCV 2020 paper: Who Left the Dogs Out? 3D Animal Reconstruction with Expectation Maximization

Benjamin Biggs 29 Dec 28, 2022
TensorFlow code for the neural network presented in the paper: "Structural Language Models of Code" (ICML'2020)

SLM: Structural Language Models of Code This is an official implementation of the model described in: "Structural Language Models of Code" [PDF] To ap

null 73 Nov 6, 2022
Code for the prototype tool in our paper "CoProtector: Protect Open-Source Code against Unauthorized Training Usage with Data Poisoning".

CoProtector Code for the prototype tool in our paper "CoProtector: Protect Open-Source Code against Unauthorized Training Usage with Data Poisoning".

Zhensu Sun 1 Oct 26, 2021
Code to use Augmented Shapiro Wilks Stopping, as well as code for the paper "Statistically Signifigant Stopping of Neural Network Training"

This codebase is being actively maintained, please create and issue if you have issues using it Basics All data files are included under losses and ea

J K Terry 32 Nov 9, 2021
Code for our method RePRI for Few-Shot Segmentation. Paper at http://arxiv.org/abs/2012.06166

Region Proportion Regularized Inference (RePRI) for Few-Shot Segmentation In this repo, we provide the code for our paper : "Few-Shot Segmentation Wit

Malik Boudiaf 138 Dec 12, 2022
Code for ACM MM 2020 paper "NOH-NMS: Improving Pedestrian Detection by Nearby Objects Hallucination"

NOH-NMS: Improving Pedestrian Detection by Nearby Objects Hallucination The offical implementation for the "NOH-NMS: Improving Pedestrian Detection by

Tencent YouTu Research 64 Nov 11, 2022
Official TensorFlow code for the forthcoming paper

~ Efficient-CapsNet ~ Are you tired of over inflated and overused convolutional neural networks? You're right! It's time for CAPSULES :)

Vittorio Mazzia 203 Jan 8, 2023
This is the code for the paper "Contrastive Clustering" (AAAI 2021)

Contrastive Clustering (CC) This is the code for the paper "Contrastive Clustering" (AAAI 2021) Dependency python>=3.7 pytorch>=1.6.0 torchvision>=0.8

Yunfan Li 210 Dec 30, 2022
Code for the paper Learning the Predictability of the Future

Learning the Predictability of the Future Code from the paper Learning the Predictability of the Future. Website of the project in hyperfuture.cs.colu

Computer Vision Lab at Columbia University 139 Nov 18, 2022
PyTorch code for the paper: FeatMatch: Feature-Based Augmentation for Semi-Supervised Learning

FeatMatch: Feature-Based Augmentation for Semi-Supervised Learning This is the PyTorch implementation of our paper: FeatMatch: Feature-Based Augmentat

null 43 Nov 19, 2022
Code for the paper A Theoretical Analysis of the Repetition Problem in Text Generation

A Theoretical Analysis of the Repetition Problem in Text Generation This repository share the code for the paper "A Theoretical Analysis of the Repeti

Zihao Fu 37 Nov 21, 2022
Code for our ICASSP 2021 paper: SA-Net: Shuffle Attention for Deep Convolutional Neural Networks

SA-Net: Shuffle Attention for Deep Convolutional Neural Networks (paper) By Qing-Long Zhang and Yu-Bin Yang [State Key Laboratory for Novel Software T

Qing-Long Zhang 199 Jan 8, 2023
Open source repository for the code accompanying the paper 'Non-Rigid Neural Radiance Fields Reconstruction and Novel View Synthesis of a Deforming Scene from Monocular Video'.

Non-Rigid Neural Radiance Fields This is the official repository for the project "Non-Rigid Neural Radiance Fields: Reconstruction and Novel View Synt

Facebook Research 296 Dec 29, 2022
Code for the Shortformer model, from the paper by Ofir Press, Noah A. Smith and Mike Lewis.

Shortformer This repository contains the code and the final checkpoint of the Shortformer model. This file explains how to run our experiments on the

Ofir Press 138 Apr 15, 2022
PyTorch code for ICLR 2021 paper Unbiased Teacher for Semi-Supervised Object Detection

Unbiased Teacher for Semi-Supervised Object Detection This is the PyTorch implementation of our paper: Unbiased Teacher for Semi-Supervised Object Detection

Facebook Research 366 Dec 28, 2022
Official code for paper "Optimization for Oriented Object Detection via Representation Invariance Loss".

Optimization for Oriented Object Detection via Representation Invariance Loss By Qi Ming, Zhiqiang Zhou, Lingjuan Miao, Xue Yang, and Yunpeng Dong. Th

ming71 56 Nov 28, 2022
Code for our CVPR 2021 paper "MetaCam+DSCE"

Joint Noise-Tolerant Learning and Meta Camera Shift Adaptation for Unsupervised Person Re-Identification (CVPR'21) Introduction Code for our CVPR 2021

FlyingRoastDuck 59 Oct 31, 2022
Code for our CVPR2021 paper coordinate attention

Coordinate Attention for Efficient Mobile Network Design (preprint) This repository is a PyTorch implementation of our coordinate attention (will appe

Qibin (Andrew) Hou 726 Jan 5, 2023