[21′ ICCV] Devide and Assemble : Learning Block-wise Memory for Unsupervised Anomaly Detection 핵심 리뷰

This entry is part 11 of 40 in the series Anomaly Detection

내용 요약

Reconstruction based의 새로운 Anomaly detection 방법론을 제안합니다. 입력 이미지를 다양한 사이즈로 나누어 재조립하는 과정을 통해 Reconstruction을 학습합니다. Memory를 구성하여 Normal Pattern을 기억하며 사용합니다.

1. 들어가며

이번 글에서는 2021년 ICCV에 발표된 Divide-and-Assemble: Learning Block-wise Memory for Unsupervised Anomaly Detection 논문을 리뷰합니다. Anomaly Detection에 관한 기본적인 내용은 Anomaly Detection에 관한 모든 것 글을 참고해주세요.

2. 기존 방법의 문제점

기존에도 Reconstruction 방식의 다양한 Anomaly Detection 방법들이 존재했는데요. 애초 생각과는 달리 CNN의 풍부한 표현력 때문에 학습 과정에서 본 적 없는 Anomaly도 잘 Reconstruction 한다는 문제가 있었습니다. 저자들은 이 원인으로 낮은 Down Sampling Ratio를 지목합니다.

그림1. 기존 Reconstruction 방법의 문제점
그림1. 기존 Reconstruction 방법의 문제점

위 그림은 기존 방법들의 Down Sampling Ratio에 따른 Anomay Reconstruction 결과를 보여줍니다. 압축률이 낮을때는 Anomaly를 거의 완벽하게 Reconstruction 하는 모습을 볼 수 있습니다. 반면 동일한 모델이라도 압축률이 높다면 (MemAE 16x) Anomaly를 Reconstruction하지 못하는 모습을 볼 수 있죠.

3. 아이디어

위의 관찰로부터 저자들은 한 가지 핵심 아이디어를 떠올리는데요. 바로 압축률에 따라 Reconstruction 결과가 달라지니 이를 활용하자는 것입니다.

그림2. Devide and Assemble의 기본 아이디어
그림2. Devide and Assemble의 기본 아이디어

위 그림은 저자들의 아이디어를 Toy Example로 표현한 것입니다. 블럭을 나누어 모으는 과정 (Devide and Assemble)을 통해 Reconstruction을 구현하고 있는데요. 조각을 작게 나누면 Anomaly도 Reconstruction 할 수 있는 모습을 볼 수 있습니다. 반면 조각을 크게 나누면 Normal 데이터는 Reconstruction 하지만 Anomaly는 Reconstruction 하지 못하는 모습을 볼 수 있죠.

따라서 저자들은 다양한 사이즈로 이미지를 나누어 사용하자는 아이디어를 제시합니다. 다음 챕터에서 자세히 살펴보겠습니다.

4. 제안 방법

바로 제안 방법을 살펴보겠습니다.

1-1. Encoder & Decoder 

먼저 전체적으로 Adversarial learning 방식을 취하고 있습니다. 전체적인 구조는 아래 그림과 같습니다.

image 57
그림3. Encoder & Decoder 부분

U-Net Encoder & decoder를 Generator로 사용합니다. 이때 Skip connection이 들어가게 되는데요, 이로 인해 Identity mapping이 되어 정상과 불량이 구분되지 않는다는 문제가 발생합니다. 입력 정보를 그대로 Decoder로 전달해주니까요. 따라서 이를 해결하기 위한 Block wise memory module을 추가 구성합니다.

1-2. Block wise memory module

위 그림에서 Encoder의 압축 정보를 Decoder로 전달하는 과정에서 Block wise memory module을 볼 수 있습니다. 이 Block Wise Memory Module은 아래 그림과 같이 구성됩니다.

image 58
그림4. Block Wise Memory Module

이 모듈의 역할은 Prototypical normal pattern을 기록하는 것입니다. 그렇다고 정상 이미지 Feature를 저장한다는 의미는 아니고요. 입력된 이미지 정보 (Query Feature)에 대해 가중 평균(Weighted Average)을 구해주는 역할을 합니다. 다른 말로 표현하면 Attention을 적용했다고 말할 수도 있겠죠. 수식으로 보면 명확한데요. Block Wise Memory Module은 입력 정보에 대해 다음 연산을 수행해줍니다.

그림5. Output Query Feature
그림5. Output Query Feature

Output Query Feature는 메모리 Feature의 가중 평균으로 표현되는 모습을 볼 수 있습니다. 이때의 가중치는 어떻게 구해줄까요? 각 메모리 Feature와 입력 Query Feature와의 Similarity의 Softmax로 구해줍니다. 수식으로는 다음과 같습니다.

attention-weight-계산방식
그림6. attention weight

결론적으로 Memory Module은 입력 Query Feature와의 유사도를 기준으로 가중평균한 Normal Feature 입니다. 학습이 진행되는 과정에서 자연스럽게 가장 대표적인 정상 패턴 (Prototypical Normal Pattern)을 찾아가게 되는거죠.

1-3. Adversarially learned representation

Generator가 있었으니 Discriminator도 있어야 합니다. 위에서 Decoder를 통해 나온 Image에 대해 Real / Fake를 구분하는 Discriminator가 들어가 있습니다. 최종적으로 Train / Test과정을 정리해보면 아래와 같습니다.

image 56
그림7. Adversarially Learned Representation

1-3-1. Train

먼저 Generator가 만들어낸 이미지의 Reconstruction Loss를 계산합니다.

reconstruction-loss
그림8. reconstruction loss

두 번째로 Discriminator가 잘 판단했는지 Adversarial Loss를 계산합니다.

adversarial-loss
그림9. adversarial loss

세 번째로 만들어진 이미지와 원본 이미지가 Feature extractor에 들어갔을 때 같은 Output으로 나오게 하는 Alignment Loss를 계산합니다.

alignment-loss
그림10. alignment loss

최종 Loss는 세 가지 Loss의 조합으로 구성합니다.

1-3-2. Test

Test 단계에서 들어온 Image에 대해 Anomaly score는 다음과 같이 계산합니다.

anomaly-score
그림11. anomaly score
  • R : Reconstruction score
  • L : Alignment score

해석해보면 “Reconstruction과 Alignment가 잘 안 맞을수록 불량 이미지다”라고 할 수 있습니다.

2. 실험 결과

제안한 방법론의 Anomaly detection 데이터셋에 대한 성능을 보겠습니다.

2-1. mvTec

mvtec-성능
그림12. mvtec 실험 결과

비교 방법론들은 다음과 같습니다.

  • SPADE : [arxiv 2020] Sub-Image Anomaly Detection with Deep Pyramid Correspondences
  • MAHA : [ICPR 2020] Modeling the Distribution of Normal Data in Pre-Trained Deep Features for Anomaly Detection
  • FAVAE : [arxiv 2020] Anomaly localization by modeling perceptual features
  • GeoTrans : [NIPS 2018] Deep Anomaly Detection Using Geometric Transformations
  • GANomaly : [ACCV 2018] GANomaly: Semi-Supervised Anomaly Detection via Adversarial Training
  • ARNet / ITAE : [IEEE Transactions on Multimedia 2021] Attribute Restoration Framework for Anomaly Detection
  • AESc : [arxiv 2020] Improved anomaly detection by training an autoencoder with skip connections on images corrupted with stain-shaped noise

mvTec 데이터셋에서 제안한 방법론은 Reconstruction 방식 중 가장 좋은 성능을 냈습니다. 하지만 Feature 비교 방법론과 비교했을 때는 아직 많이 떨어지는 성능을 보였습니다.

2-2. CIFAR10, MNIST

CIFAR10-MNIST-성능
그림13. CIFAR10 / MNIST 실험 결과

비교 방법론들은 다음과 같습니다.

  • VAE : [ICLR 2014] Auto-encoding variational bayes
  • AnoGAN : [IPMI 2017] Unsupervised Anomaly Detection with Generative Adversarial Networks to Guide Marker Discovery
  • ADGAN : [Springer 2018] Image anomaly detection with generative adversarial networks
  • GANomaly : [ACCV 2018] GANomaly: Semi-Supervised Anomaly Detection via Adversarial Training
  • GeoTrans / GEOM : [NIPS 2018] Deep Anomaly Detection Using Geometric Transformations
  • Skip-GANomaly : [IJCNN 2019] Skip-ganomaly: Skip connected and adversarially trained encoder-decoder anomaly detection
  • OCGAN : [ICCV 2019] Ocgan:One-class novelty detection using gans with constrained latent representations
  • MemAE : [ICCV 2019] Memorizing normality to detect anomaly:Memory-augmented deep autoencoder for unsupervised anomaly detection.
  • CAVGA-R : [ECCV 2020] Attention Guided Anomaly Localization in Images
Series Navigation<< [20′ ECCV] Attention Guided Anomaly Localization in Images (CAVGA) 핵심 리뷰[21′ ICCV] Learning Unsupervised Metaformer for Anomaly detection 핵심 리뷰 >>
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
Scroll to Top