cuteboyqq / skip-GANOMALY-Pytorch

GANomaly, Skip-Ganomaly, Skip-CBAM-GANomaly, pytorch, CIFAR10, MNIST
7 stars 0 forks source link

skip-GANomaly-Pytorch-CIFAR10-MNIST-CUSTOM

(Back to menu)

Use skip-connection to skip Encoder layer to Decoder layer by concatenation, the framework is based on gamonaly. Impement skip-ganomaly and skip-attention-ganomaly, here use CBAM attention before skip Encoder layer to Decoder

updated

(Back to menu)

  1. Able to train CIFAR10, MNIST datasets [2023-01-23 updated]

Generator + Discriminator model

Table of contents

Requirement

pip install -r requirements.txt

implement

(Back to top)

  1. Encoder-Decoder use Unet

umodel.py

below image is the whole network of GANomaly with the "skip connection" skill at the begining of Encoder-Decoder part

Ganomaly

Unet-Network

(Back to top)

below image is the detail of Encoder-Decoder with "skip connection" skill

unetwork.py

Unet

Unet-CBAM-Network

(Back to top)

SAnetwork.py

below image is similar to the Unet-Network, just do CBAM before skip connect to the Decoder layer

CBAM

Train-on-custom-dataset

(Back to top)

Custom Dataset
├── test
│   ├── 0.normal
│   │   └── normal_tst_img_0.png
│   │   └── normal_tst_img_1.png
│   │   ...
│   │   └── normal_tst_img_n.png
│   ├── 1.abnormal
│   │   └── abnormal_tst_img_0.png
│   │   └── abnormal_tst_img_1.png
│   │   ...
│   │   └── abnormal_tst_img_m.png
├── train
│   ├── 0.normal
│   │   └── normal_tst_img_0.png
│   │   └── normal_tst_img_1.png
│   │   ...
│   │   └── normal_tst_img_t.png

Train

(Back to top)

python train.py --img-dir "[train dataset dir] or cifar10 or mnist" 
                  --batch-size 64 
                  --img-size 32 
                  --epoch 20 
                  --model "ganomaly or skip-ganomaly or skip-attention-ganomly" 
                  --abnormal-class "airplane" 

Test

(Back to top)

python test.py --nomal-dir "[test normal dataset dir]" 
               --abnormal-dir "[test abnormal dataset dir]" 
               --view-img 
               --img-size 32

Reference

(Back to top)

GANomaly: Semi-Supervised Anomaly Detection via Adversarial Training

https://arxiv.org/abs/1805.06725

Skip-GANomaly: Skip Connected and Adversarially Trained Encoder-Decoder Anomaly Detection

https://arxiv.org/pdf/1901.08954.pdf

CBAM: Convolutional Block Attention Module

https://arxiv.org/abs/1807.06521

SAGAN: SKIP-ATTENTION GAN FOR ANOMALY DETECTION

http://personal.ee.surrey.ac.uk/Personal/W.Wang/papers/LiuLZHW_ICIP_2021.pdf