Newcomer520 / tf-dagmm

Tensorflow Implementation of dagmm: Deep Autoencoding Gaussian Mixture Model for Unsupervised Anomaly Detection, Zong et al, 2018
56 stars 17 forks source link

tf-dagmm

A tensorflow Implementation of dagmm: Deep Autoencoding Gaussian Mixture Model for Unsupervised Anomaly Detection, Zong et al, 2018. Furthermore, I built the convolutional autoencoder to analyze the data of images instead of fully-connected autoencoder.

Requirement

I've trained the model successfully on the below packages:

Encoded to a vector of higher dimension

The auther encode the input to a vector of a very low dimension(only 1 or 2). This is too small since I am doing the anomaly detection for images with the size 128 x 128. I use a meta dense layer to map the encoded vector into the into the low dimension space. Therefore, I could have a better reconstruction error and a trainable GMM as well.

Note

Train

Pattern

Image configuration needs to be passed through the argument --pattern, a typical setting is like:

OBJECT_J0602 = {
    'main': {'width': 128, 'height': 128, 'region': 'all', 'filters': FILTERS_128, 'scope': 'main', 'reuse': False},
}

For example, if we want to use this configuration, --pattern should be argumented with J0601. Some important settings:

Other settings

Example script:

$ python ./tf-dagmm/train.py --encoded_dims 160 \
                             --latent 6 \
                             --mixtures 7 \
                             --pattern J0601_S \
                             --logdir /home/i-lun/works/smt/j0601/nsg_split \
                             --batch_size 56 \
                             --epoch 1000 \
                             --train_folder /mnt/storage/P8_SMT/Connector/J0601/wuchi/split/train/OK/ \
                             --validation_folder /mnt/storage/P8_SMT/Connector/J0601/wuchi/split/test/OK/

Summary Report

Example script:

python ./WiML4AOI_SMT_SA/dagmm/main.py --logdir /home/i-lun/works/kb/type12567hook1 \
                                       --checkpoint checkpoint-1000 \
                                       --saved_in /home/i-lun/works/kb/reports/type12567hook1 \
                                       --train_folder /mnt/storage/AOI_KB/dataset/clean/type12567hook1/train/OK \
                                       --test_OK_folder /mnt/storage/AOI_KB/dataset/clean/type12567hook1/test/OK \
                                       --test_NG_folder /mnt/storage/AOI_KB/dataset/clean/type12567hook1/test/NG

Issue

I cannot avoid the singularity issue of gmm, even if the penality term mention in the paper is added. Therefore, I added some jitter to the diagonal of the covariance matrix. Not sure it's a good solution or not.

Result

some pictures of results
Alt text Alt text Alt text