SlideShare une entreprise Scribd logo
1  sur  29
Télécharger pour lire hors ligne
Smart Production Systems Lab.
구병모
2023.01.06
Anomaly Detection based on Diffusion Model
2023年 冬季 Paper Seminar
INDEX
01 Denoising diffusion probabilistic models
Ho, Jonathan, Ajay Jain, and Pieter Abbeel. (NeruIPS 2020, Citation: 956)
02 AnoDDPM: Anomaly Detection With Denoising Diffusion Probabilistic Models Using Simplex Noise
Cohen, M. J., & Avidan, S. (CVPR 2022, Citation: 8)
3
01 Denoising diffusion probabilistic models
Diffusion?
확산 in 열역학
• 시초: Sohl-Dickstein, Jascha, et al. "Deep unsupervised learning using nonequilibrium thermodynamics." PMLR, 2015. (Citation: 668)
Source: 2022 CVPR Nvidia Tutorial on Denoising Diffusion-based Generative Modeling: Foundations and Applications
4
01 Denoising diffusion probabilistic models
Growing interest in Diffusion
A graduate student who studies late at night
Pixel art Digital art Oil Painting
Source: https://labs.openai.com/
DALL·E 2 has learned the relationship between images and the text used to describe them. It uses a process called
“diffusion”, which starts with a pattern of random dots and gradually alters that pattern towards an image when it
recognizes specific aspects of that image.
5
01 Denoising diffusion probabilistic models
Generative model
▪ VAE
▪ Flow-based Model
▪ GAN
▪ Diffusion based generative model
𝑃𝜃 𝑥 𝑧
Decoder
𝑞𝜃 𝑧 𝑥
Encoder
• 학습된 Decoder network를 통해 latent variable을 특정한 패턴의 분포로 mapping
• Encoder를 모델 구조에 추가해, Latent variable / Encoder / Decoder 모두 학습
𝑝′
𝑥
(𝑥)
𝑝𝑧 𝑧 ~𝑁
𝑝𝑥(𝑥)
Generator Discriminator
• 학습된 Generator를 통해 latent variable을 특정한 패턴의 분포로 mapping
• Discriminator를 모델 구조에 추가해, Generator를 학습
𝑓−1
∘ ⋯ ∘ 𝑓−1
Flow (inverse)
𝑝′
𝑥
(𝑥)
𝑝𝑧 𝑧 ~𝑁
𝑝𝑥(𝑥)
𝑓 ∘ ⋯ ∘ 𝑓
Flow (forward)
• 학습된 Flow model의 Inverse mapping을 통해 latent variable을 특정한 패턴의
분포로 mapping
• 생성에 활용되는 Inverse mapping을 학습하기 위해 Invertible function을 학습
𝑝′
𝑥
(𝑥)
𝑝𝑧 𝑧 ~𝑁
𝑝𝑥(𝑥)
Iterative MC
𝑞(𝑥1|𝑥0) ∘ 𝑞(𝑥2|𝑥1) ∘ ⋯ ∘ 𝑞(𝑥𝑇 = 𝑧|𝑥𝑇−1)
Iterative MC
𝑃𝜃(𝑧1|𝑧0) ∘ 𝑃𝜃(𝑧2|𝑧1) ∘ ⋯ ∘ 𝑃𝜃(𝑧𝑇 = 𝑥|𝑧𝑇−1)
• 학습된 Diffusion model의 조건부 확률 분포 𝑃𝜃(𝑥|𝑧)을 통해 특정한 패턴의 분포 도출
• 생성에 활용되는 조건부 확률 분포 𝑃𝜃(𝑥|𝑧) 을 학습하기 위해 Diffusion process
𝑞 𝑧 𝑥 을 학습
6
01 Denoising diffusion probabilistic models
Generative model
Source: https://lilianweng.github.io/posts/2021-07-11-diffusion-models/
7
01 Denoising diffusion probabilistic models
Diffusion?
▪ Diffusion process (Noising)
▪ Reverse process (Denoising)
𝑞 𝑥1:𝑇 𝑥0 ≔ ς𝑡=1
𝑇
𝑞(𝑥𝑡|𝑥𝑡−1) , 𝑞 𝑥𝑡 𝑥𝑡−1 ≔ 𝑁 𝑥𝑡; 1 − 𝛽𝑡𝑥𝑡−1, 𝛽𝑡𝑰 , 𝑥𝑡 = 1 − 𝛽𝑡𝑥𝑡−1 + 𝛽𝑡𝜖𝑡−1, 𝜖~𝑁(0, 𝐼)
𝑃𝜃(𝑥0:𝑇) ≔ 𝑃(𝑥𝑇) ς𝑡=1
𝑇
𝑃𝜃(𝑥𝑡−1|𝑥𝑡) , 𝑃𝜃 𝑥𝑡−1 𝑥𝑡 ≔ 𝑁(𝑥𝑡−1; 𝝁𝜃 𝑥𝑡, 𝑡 , 𝚺𝜃 𝑥𝑡, 𝑡 )
Fixed
Learned
❖ Diffusion Model
▪ 생성모델의 일종으로, 학습 데이터의 패턴을 생성해내는 것을 목적으로 함
▪ 패턴을 생성해내기 위해서 패턴에 노이즈를 넣어 망가뜨리고, 이를 다시 복원하는 조건부 함수를 학습하는 과정
(Reparameterization trick)
학습 대상
8
01 Denoising diffusion probabilistic models
Diffusion?
❖ Diffusion Loss
Regularization
→ Learning 𝛽𝑡
Reconstruction
Denoising
더 간단하게 만들 수는 없을까? DDPM의 Contribution
9
01 Denoising diffusion probabilistic models
DDPM
❖ Loss Simplification
▪ Remove Regularization Term
Use Fixed 𝛽𝑡
Inductive Bias ↑
(∵ 학습 가능한 부분을 없애고 사용자가 설계한대로 모델을 구성)
10
01 Denoising diffusion probabilistic models
DDPM
❖ Loss Simplification
▪ Remove Regularization Term
Use Fixed 𝛽𝑡
Inductive Bias ↑
(∵ 학습 가능한 부분을 없애고 사용자가 설계한대로 모델을 구성)
11
01 Denoising diffusion probabilistic models
DDPM
❖ Loss Simplification
▪ Denoising loss Modification - #1 𝚺𝜃 𝑥𝑡, 𝑡 의 상수화
𝚺𝜃 𝑥𝑡, 𝑡 = 𝜎𝑡
2
𝑰 (time dependent constants) → t시점까지 누적된 noise
𝜎𝑡
2
= ෨
𝛽𝑡 =
1−ഥ
𝛼𝑡−1
1−ഥ
𝛼𝑡
𝛽𝑡 or 𝜎𝑡
2
= 𝛽𝑡 ( ത
𝛼𝑡 = ς𝑠=1
𝑡
𝛼𝑠, 𝛼𝑡 = 1 − 𝛽𝑡)
𝑃𝜃 𝑥𝑡−1 𝑥𝑡 ≔ 𝑁(𝑥𝑡−1; 𝝁𝜃 𝑥𝑡, 𝑡 , 𝚺𝜃 𝑥𝑡, 𝑡 ) 𝑃𝜃 𝑥𝑡−1 𝑥𝑡 ≔ 𝑁(𝑥𝑡−1; 𝝁𝜃 𝑥𝑡, 𝑡 , 𝜎𝑡
2
𝑰)
학습 대상
12
01 Denoising diffusion probabilistic models
DDPM
❖ Loss Simplification
▪ Denoising loss Modification - #2 𝝁𝜃 𝑥𝑡, 𝑡 를 Denoising matching을 통해 새롭게 정의
𝑞 𝑥𝑡−1 𝑥𝑡, 𝑥0 = 𝑁(𝑥𝑡−1; ෤
𝜇𝑡 𝑥𝑡, 𝑥0 , ෨
𝛽𝑡 ∙ 𝐈)
𝑝𝜃 𝑥𝑡−1 𝑥𝑡 = 𝑁(𝑥𝑡−1; 𝜇𝜃 𝑥𝑡, 𝑡 , ෨
𝛽𝑡 ∙ 𝐈)
& KL Divergence
<Bayes Rule>
13
01 Denoising diffusion probabilistic models
DDPM
❖ Loss Simplification
▪ Denoising loss Modification - #2 𝝁𝜃 𝑥𝑡, 𝑡 를 Denoising matching을 통해 새롭게 정의
𝑥𝑡 𝑥0, 𝜖 = ത
𝛼𝑡𝑥0 + 1 − ത
𝛼𝑡𝜖 for 𝜖~𝑁 0, 𝐈 ( ത
𝛼𝑡 ≔ ς𝑠=1
𝑡
𝛼𝑠 , 𝛼𝑡 = 1 − 𝛽𝑡)
14
01 Denoising diffusion probabilistic models
DDPM
❖ Loss Simplification
▪ Denoising loss Modification - #2 𝝁𝜃 𝑥𝑡, 𝑡 를 Denoising matching을 통해 새롭게 정의
15
01 Denoising diffusion probabilistic models
DDPM
❖ Loss Simplification
▪ Denoising loss Modification - #3 Total Process 수식적으로 복잡, 고려 안 해줘도 큰 성능 차이 X
계수항 제거
16
01 Denoising diffusion probabilistic models
DDPM
❖ Loss Simplification
Regularization
→ Learning 𝛽𝑡
Reconstruction
Denoising
17
01 Denoising diffusion probabilistic models
Experiments
해명
1. noise-to-image에 따른 RMSE
2. noise-to-image에 따른 정보량
3. X축: 정보량 / Y축: RMSE
→ 3번 그래프를 보면 적은 정보량에서 이미 RMSE(왜곡)가 충분히 낮아지는 것을 알 수 있음.
→ Reverse process 초반에 정보량은 적지만 왜곡은 충분히 제거 & 후반에는 거의 보이지
않는 왜곡 (imperceptible distortion)을 줄이는 정보가 존재
• IS(Inception score): 생성된 이미지로부터 분류 Task 수행할 때 얼마나 특정 class로 추정을 잘하는 지에 대한 score (분류 성능 & 전체 class 고르게 생성 → IS ↑ )
• FID(Frechet Inception Distance): 실제 데이터를 참고하여 (정확하게는 데이터 분포를 참고) 평균, 공분산을 비교 / 낮을수록 좋은 지표
• NLL (Negative Log Likelihood): 이미지 픽셀당 옳게 생성했는지를 판단하는 지표 / NLL이 높다면 불확실함 (이미지 픽셀당 평균 확률이 낮음)
18
01 Denoising diffusion probabilistic models
Experiments
⑴
⑵
⑶
⑷
• 계수항은 t가 증가할수록 작아지는 경향 有 → Large t (more noisy) 시점의 Loss 값이 down-weight되는 현상
• 계수항을 제거하여 noise가 더 심한 step에서의 Loss 비중을 높이는 방법 → Denoising에 더 집중 가능
계수항
Source: https://www.youtube.com/watch?v=_JQSMhqXw-4&t=1431s
19
02 Anomaly Detection With Denoising Diffusion Probabilistic Models Using Simplex Noise
Introduction
❖ Background
• 본 연구는 의료 분야 이미지 Anomaly Detection을 목표로 함.
• 생성모델 기반 이상탐지: 정상(Healthy) 이미지만을 복원할 수 있도록 학습 → 이상(Anomalous) 이미지도 정상 이미지처럼 복원하여 탐지
• Diffusion 생성모델 선택 이유: GAN보다 mode coverage가 좋고, VAE보다 higher sample quality
• 기존 방법론의 한계점: ① Too expensive Sampling times ② Gaussian noise → Fail to detect anomalies (너무 좋은 성능)
❖ Contribution
① “Partial diffusion strategy”
② “Multi-scale (multi-octave) Simplex noise”
20
02 Anomaly Detection With Denoising Diffusion Probabilistic Models Using Simplex Noise
Methodology - Simplex Noise ①
❖ Gaussian noise의 한계점
• Natural image는 낮은 빈도의 성분(ex. 이상 region) 이 이미지에 더 많은 기여를 하도록 하는 멱법칙(power law) 분포를 가짐.
• 멱법칙? ≈ 파레토 법칙 → 위의 말을 쉽게 써보면 이미지를 분류하는데 대부분의 부분보다는 낮은 빈도로 보이는 작은 부분들이 효과적임.
• Gaussian noise는 왜 문제? DDPM이 high quality로 복원하기 위해서 낮은 빈도 부분은 noise를 약하게, 높은 빈도 부분은 noise를
강하게 주는 경향 존재
• 따라서, 이미지 상황과 유사하게 멱법칙(power law) 분포를 따르는 noise를 넣어줘야 함.
(80 : 20 Rule)
Gaussian
noise
Simplex
noise
Low Frequency
21
02 Anomaly Detection With Denoising Diffusion Probabilistic Models Using Simplex Noise
Methodology - Simplex Noise ②
❖ Simplex Noise ≈ Perlin noise (펄린 노이즈)
• Ken Perlin이 1980년대 초 영화 ‘트론‘ 제작 중 컴퓨터 효과를 위한 단계적 텍스처를 만들기 위해 개발한 노이즈 함수
• 자연계의 불규칙한 노이즈를 CG로 표현하는 방법이며 프랙탈 합을 이용해서 이상적인 노이즈를 만들어 냄
• Benefit : the corruption is more structured | the denoising process will be able to “repair” those structured anomalies
Octave: 여러 noise 중첩
22
02 Anomaly Detection With Denoising Diffusion Probabilistic Models Using Simplex Noise
Methodology – AnoDDPM
❖ AnoDDPM
• Gaussian & Simplex noise 같이 사용해서 비교 실험
• Simplex noise → Starting frequency = 𝜈 = 2−6
𝑁 = 6 𝛾 = 0.8 (decay)
23
02 Anomaly Detection With Denoising Diffusion Probabilistic Models Using Simplex Noise
Training & Inference (Segmentation)
24
02 Anomaly Detection With Denoising Diffusion Probabilistic Models Using Simplex Noise
Experiment Dataset
❖ Healthy Dataset
• Neurofeedback Skull-Stripped (NFBS) Repository
• Database of 125 T1-weighted anatomical MRI scans that are manually skull-stripped
• Full Skull image: 복잡 But 이상 징후가 다양하게 발생 가능
• Training : Testing = 100 : 25
❖ Anomalous Dataset
• Centre for Clinical Brain Sciences from the University of Edinburgh로 부터 받은 brain tumours dataset
• Database of 22 T1-weighted MRI scans
25
02 Anomaly Detection With Denoising Diffusion Probabilistic Models Using Simplex Noise
Gaussian vs Simplex
• Gaussian diffusion은 확실히 high quality sample은 잘 만듦 BUT 𝜆를 250, 500, 750 늘려갈수록 아예 다른 이미지 생성
𝜆
250
500
750
• 다른 종양을 가진 환자의 뇌를 잘 복원하기 위해 필요한 Release time은 상이함 → 해당 데이터셋에서 일반적으로 250이 optimal
❖ Gaussian noise diffusion ❖ Simplex noise diffusion
26
02 Anomaly Detection With Denoising Diffusion Probabilistic Models Using Simplex Noise
Performance
27
02 Anomaly Detection With Denoising Diffusion Probabilistic Models Using Simplex Noise
Conclusion
❖ Future work
1. Simplex noise의 불균형 때문에 sample quality 가 조금은 떨어지는 경향 → 여러 noise를 연구하여 Customize
2. DDPM은 Markov Chain을 사용, 즉 Stochastic 함 → 한 번 생성하는 것보다는 여러 번 생성해서 평균 낸 이미지로 이상 탐지 수행
3. 3D 이미지 혹은 Color 이미지에도 적용
❖ Conclusion
• 실험에서도 알 수 있듯, not require large datasets → 이상탐지 수행 가능
• Gaussian noise 대신에 Simplex noise를 사용한 점
• 의료 분야 외에 다른 도메인에서도 적용 가능 → ex) MVTec AD
• Full length Markov chain이 필요하지 않은 분야에 적용하면 좋을 것
(image enhancement, semantic segmentation, filtering)
28
Reference
1. Ho, Jonathan, Ajay Jain, and Pieter Abbeel. "Denoising diffusion probabilistic models." Advances in Neural Information Processing
Systems 33 (2020)
2. Wyatt, Julian, et al. "AnoDDPM: Anomaly Detection With Denoising Diffusion Probabilistic Models Using Simplex Noise." Proceedings of
the IEEE/CVF Conference on Computer Vision and Pattern Recognition. 2022.
3. 유튜브 강의 [DSBA 연구실 김정섭 석사과정], https://www.youtube.com/watch?v=_JQSMhqXw-4&t=1431s
4. 유튜브 강의 [PR 409], https://www.youtube.com/watch?v=1j0W_lu55nc
5. 블로그, https://ivdevlog.tistory.com/14
Smart Production Systems Lab.
구병모
2023.01.06
Thank you

Contenu connexe

Tendances

1시간만에 GAN(Generative Adversarial Network) 완전 정복하기
1시간만에 GAN(Generative Adversarial Network) 완전 정복하기1시간만에 GAN(Generative Adversarial Network) 완전 정복하기
1시간만에 GAN(Generative Adversarial Network) 완전 정복하기
NAVER Engineering
 
기본 회전 공식
기본 회전 공식 기본 회전 공식
기본 회전 공식
cancan21st
 
NDC 2014, 피할 수 없는 문자열의 세계
NDC 2014, 피할 수 없는 문자열의 세계NDC 2014, 피할 수 없는 문자열의 세계
NDC 2014, 피할 수 없는 문자열의 세계
tcaesvk
 

Tendances (20)

[기초개념] Recurrent Neural Network (RNN) 소개
[기초개념] Recurrent Neural Network (RNN) 소개[기초개념] Recurrent Neural Network (RNN) 소개
[기초개념] Recurrent Neural Network (RNN) 소개
 
Show, Attend and Tell: Neural Image Caption Generation with Visual Attention
Show, Attend and Tell: Neural Image Caption Generation with Visual AttentionShow, Attend and Tell: Neural Image Caption Generation with Visual Attention
Show, Attend and Tell: Neural Image Caption Generation with Visual Attention
 
Generating Diverse High-Fidelity Images with VQ-VAE-2
Generating Diverse High-Fidelity Images with VQ-VAE-2Generating Diverse High-Fidelity Images with VQ-VAE-2
Generating Diverse High-Fidelity Images with VQ-VAE-2
 
研究の進め方
研究の進め方研究の進め方
研究の進め方
 
OpenCVを用いた画像処理入門
OpenCVを用いた画像処理入門OpenCVを用いた画像処理入門
OpenCVを用いた画像処理入門
 
1시간만에 GAN(Generative Adversarial Network) 완전 정복하기
1시간만에 GAN(Generative Adversarial Network) 완전 정복하기1시간만에 GAN(Generative Adversarial Network) 완전 정복하기
1시간만에 GAN(Generative Adversarial Network) 완전 정복하기
 
충돌 알고리즘(collision detection algorithms)
충돌 알고리즘(collision detection algorithms)충돌 알고리즘(collision detection algorithms)
충돌 알고리즘(collision detection algorithms)
 
Voxel based game_optimazation_relelase
Voxel based game_optimazation_relelaseVoxel based game_optimazation_relelase
Voxel based game_optimazation_relelase
 
Brief intro : Invariance and Equivariance
Brief intro : Invariance and EquivarianceBrief intro : Invariance and Equivariance
Brief intro : Invariance and Equivariance
 
Voxelizaition with GPU
Voxelizaition with GPUVoxelizaition with GPU
Voxelizaition with GPU
 
論文紹介:InternVideo: General Video Foundation Models via Generative and Discrimi...
論文紹介:InternVideo: General Video Foundation Models via Generative and Discrimi...論文紹介:InternVideo: General Video Foundation Models via Generative and Discrimi...
論文紹介:InternVideo: General Video Foundation Models via Generative and Discrimi...
 
기본 회전 공식
기본 회전 공식 기본 회전 공식
기본 회전 공식
 
PR-302: NeRF: Representing Scenes as Neural Radiance Fields for View Synthesis
PR-302: NeRF: Representing Scenes as Neural Radiance Fields for View SynthesisPR-302: NeRF: Representing Scenes as Neural Radiance Fields for View Synthesis
PR-302: NeRF: Representing Scenes as Neural Radiance Fields for View Synthesis
 
NDC 2014, 피할 수 없는 문자열의 세계
NDC 2014, 피할 수 없는 문자열의 세계NDC 2014, 피할 수 없는 문자열의 세계
NDC 2014, 피할 수 없는 문자열의 세계
 
論文紹介:Unsupervised Hierarchical Semantic Segmentation With Multiview Cosegment...
論文紹介:Unsupervised Hierarchical Semantic Segmentation With Multiview Cosegment...論文紹介:Unsupervised Hierarchical Semantic Segmentation With Multiview Cosegment...
論文紹介:Unsupervised Hierarchical Semantic Segmentation With Multiview Cosegment...
 
텐서플로우 기초 이해하기
텐서플로우 기초 이해하기 텐서플로우 기초 이해하기
텐서플로우 기초 이해하기
 
Chapter 7 Regularization for deep learning - 2
Chapter 7 Regularization for deep learning - 2Chapter 7 Regularization for deep learning - 2
Chapter 7 Regularization for deep learning - 2
 
Tutorial on Polynomial Networks at CVPR'22
Tutorial on Polynomial Networks at CVPR'22Tutorial on Polynomial Networks at CVPR'22
Tutorial on Polynomial Networks at CVPR'22
 
[NDC2016] TERA 서버의 Modern C++ 활용기
[NDC2016] TERA 서버의 Modern C++ 활용기[NDC2016] TERA 서버의 Modern C++ 활용기
[NDC2016] TERA 서버의 Modern C++ 활용기
 
PR-214: FlowNet: Learning Optical Flow with Convolutional Networks
PR-214: FlowNet: Learning Optical Flow with Convolutional NetworksPR-214: FlowNet: Learning Optical Flow with Convolutional Networks
PR-214: FlowNet: Learning Optical Flow with Convolutional Networks
 

Similaire à Anomaly Detection based on Diffusion

247 deview 2013 이미지 분석 - 민재식
247 deview 2013 이미지 분석 - 민재식247 deview 2013 이미지 분석 - 민재식
247 deview 2013 이미지 분석 - 민재식
NAVER D2
 

Similaire à Anomaly Detection based on Diffusion (20)

247 deview 2013 이미지 분석 - 민재식
247 deview 2013 이미지 분석 - 민재식247 deview 2013 이미지 분석 - 민재식
247 deview 2013 이미지 분석 - 민재식
 
Crash Course on Graphical models
Crash Course on Graphical modelsCrash Course on Graphical models
Crash Course on Graphical models
 
[신경망기초] 심층신경망개요
[신경망기초] 심층신경망개요[신경망기초] 심층신경망개요
[신경망기초] 심층신경망개요
 
머신러닝의 자연어 처리기술(I)
머신러닝의 자연어 처리기술(I)머신러닝의 자연어 처리기술(I)
머신러닝의 자연어 처리기술(I)
 
Lecture 4: Neural Networks I
Lecture 4: Neural Networks ILecture 4: Neural Networks I
Lecture 4: Neural Networks I
 
[한글] Tutorial: Sparse variational dropout
[한글] Tutorial: Sparse variational dropout[한글] Tutorial: Sparse variational dropout
[한글] Tutorial: Sparse variational dropout
 
Visualizing data using t-SNE
Visualizing data using t-SNEVisualizing data using t-SNE
Visualizing data using t-SNE
 
Deep neural networks cnn rnn_ae_some practical techniques
Deep neural networks cnn rnn_ae_some practical techniquesDeep neural networks cnn rnn_ae_some practical techniques
Deep neural networks cnn rnn_ae_some practical techniques
 
Deep learning overview
Deep learning overviewDeep learning overview
Deep learning overview
 
인공지능, 기계학습 그리고 딥러닝
인공지능, 기계학습 그리고 딥러닝인공지능, 기계학습 그리고 딥러닝
인공지능, 기계학습 그리고 딥러닝
 
03.12 cnn backpropagation
03.12 cnn backpropagation03.12 cnn backpropagation
03.12 cnn backpropagation
 
Anomaly Detection with GANs
Anomaly Detection with GANsAnomaly Detection with GANs
Anomaly Detection with GANs
 
Dense sparse-dense training for dnn and Other Models
Dense sparse-dense training for dnn and Other ModelsDense sparse-dense training for dnn and Other Models
Dense sparse-dense training for dnn and Other Models
 
알기쉬운 Variational autoencoder
알기쉬운 Variational autoencoder알기쉬운 Variational autoencoder
알기쉬운 Variational autoencoder
 
Learning how to explain neural networks: PatternNet and PatternAttribution
Learning how to explain neural networks: PatternNet and PatternAttributionLearning how to explain neural networks: PatternNet and PatternAttribution
Learning how to explain neural networks: PatternNet and PatternAttribution
 
제노블레이도 2 ray marching을사용한 구름 표현
제노블레이도 2 ray marching을사용한 구름 표현제노블레이도 2 ray marching을사용한 구름 표현
제노블레이도 2 ray marching을사용한 구름 표현
 
Dsh data sensitive hashing for high dimensional k-nn search
Dsh  data sensitive hashing for high dimensional k-nn searchDsh  data sensitive hashing for high dimensional k-nn search
Dsh data sensitive hashing for high dimensional k-nn search
 
Variational Auto Encoder, Generative Adversarial Model
Variational Auto Encoder, Generative Adversarial ModelVariational Auto Encoder, Generative Adversarial Model
Variational Auto Encoder, Generative Adversarial Model
 
Data Visualization and t-SNE
Data Visualization and t-SNEData Visualization and t-SNE
Data Visualization and t-SNE
 
[네이버AI해커톤]어떻게 걱정을 멈추고 베이스라인을 사랑하는 법을 배우게 되었는가
[네이버AI해커톤]어떻게 걱정을 멈추고 베이스라인을 사랑하는 법을 배우게 되었는가[네이버AI해커톤]어떻게 걱정을 멈추고 베이스라인을 사랑하는 법을 배우게 되었는가
[네이버AI해커톤]어떻게 걱정을 멈추고 베이스라인을 사랑하는 법을 배우게 되었는가
 

Dernier

Dernier (8)

공학 관점에서 바라본 JMP 머신러닝 최적화
공학 관점에서 바라본 JMP 머신러닝 최적화공학 관점에서 바라본 JMP 머신러닝 최적화
공학 관점에서 바라본 JMP 머신러닝 최적화
 
JMP를 활용한 전자/반도체 산업 Yield Enhancement Methodology
JMP를 활용한 전자/반도체 산업 Yield Enhancement MethodologyJMP를 활용한 전자/반도체 산업 Yield Enhancement Methodology
JMP를 활용한 전자/반도체 산업 Yield Enhancement Methodology
 
JMP가 걸어온 여정, 새로운 도약 JMP 18!
JMP가 걸어온 여정, 새로운 도약 JMP 18!JMP가 걸어온 여정, 새로운 도약 JMP 18!
JMP가 걸어온 여정, 새로운 도약 JMP 18!
 
JMP를 활용한 가속열화 분석 사례
JMP를 활용한 가속열화 분석 사례JMP를 활용한 가속열화 분석 사례
JMP를 활용한 가속열화 분석 사례
 
데이터 분석 문제 해결을 위한 나의 JMP 활용법
데이터 분석 문제 해결을 위한 나의 JMP 활용법데이터 분석 문제 해결을 위한 나의 JMP 활용법
데이터 분석 문제 해결을 위한 나의 JMP 활용법
 
JMP 기능의 확장 및 내재화의 핵심 JMP-Python 소개
JMP 기능의 확장 및 내재화의 핵심 JMP-Python 소개JMP 기능의 확장 및 내재화의 핵심 JMP-Python 소개
JMP 기능의 확장 및 내재화의 핵심 JMP-Python 소개
 
(독서광) 인간이 초대한 대형 참사 - 대형 참사가 일어날 때까지 사람들은 무엇을 하고 있었는가?
(독서광) 인간이 초대한 대형 참사 - 대형 참사가 일어날 때까지 사람들은 무엇을 하고 있었는가?(독서광) 인간이 초대한 대형 참사 - 대형 참사가 일어날 때까지 사람들은 무엇을 하고 있었는가?
(독서광) 인간이 초대한 대형 참사 - 대형 참사가 일어날 때까지 사람들은 무엇을 하고 있었는가?
 
실험 설계의 평가 방법: Custom Design을 중심으로 반응인자 최적화 및 Criteria 해석
실험 설계의 평가 방법: Custom Design을 중심으로 반응인자 최적화 및 Criteria 해석실험 설계의 평가 방법: Custom Design을 중심으로 반응인자 최적화 및 Criteria 해석
실험 설계의 평가 방법: Custom Design을 중심으로 반응인자 최적화 및 Criteria 해석
 

Anomaly Detection based on Diffusion

  • 1. Smart Production Systems Lab. 구병모 2023.01.06 Anomaly Detection based on Diffusion Model 2023年 冬季 Paper Seminar
  • 2. INDEX 01 Denoising diffusion probabilistic models Ho, Jonathan, Ajay Jain, and Pieter Abbeel. (NeruIPS 2020, Citation: 956) 02 AnoDDPM: Anomaly Detection With Denoising Diffusion Probabilistic Models Using Simplex Noise Cohen, M. J., & Avidan, S. (CVPR 2022, Citation: 8)
  • 3. 3 01 Denoising diffusion probabilistic models Diffusion? 확산 in 열역학 • 시초: Sohl-Dickstein, Jascha, et al. "Deep unsupervised learning using nonequilibrium thermodynamics." PMLR, 2015. (Citation: 668) Source: 2022 CVPR Nvidia Tutorial on Denoising Diffusion-based Generative Modeling: Foundations and Applications
  • 4. 4 01 Denoising diffusion probabilistic models Growing interest in Diffusion A graduate student who studies late at night Pixel art Digital art Oil Painting Source: https://labs.openai.com/ DALL·E 2 has learned the relationship between images and the text used to describe them. It uses a process called “diffusion”, which starts with a pattern of random dots and gradually alters that pattern towards an image when it recognizes specific aspects of that image.
  • 5. 5 01 Denoising diffusion probabilistic models Generative model ▪ VAE ▪ Flow-based Model ▪ GAN ▪ Diffusion based generative model 𝑃𝜃 𝑥 𝑧 Decoder 𝑞𝜃 𝑧 𝑥 Encoder • 학습된 Decoder network를 통해 latent variable을 특정한 패턴의 분포로 mapping • Encoder를 모델 구조에 추가해, Latent variable / Encoder / Decoder 모두 학습 𝑝′ 𝑥 (𝑥) 𝑝𝑧 𝑧 ~𝑁 𝑝𝑥(𝑥) Generator Discriminator • 학습된 Generator를 통해 latent variable을 특정한 패턴의 분포로 mapping • Discriminator를 모델 구조에 추가해, Generator를 학습 𝑓−1 ∘ ⋯ ∘ 𝑓−1 Flow (inverse) 𝑝′ 𝑥 (𝑥) 𝑝𝑧 𝑧 ~𝑁 𝑝𝑥(𝑥) 𝑓 ∘ ⋯ ∘ 𝑓 Flow (forward) • 학습된 Flow model의 Inverse mapping을 통해 latent variable을 특정한 패턴의 분포로 mapping • 생성에 활용되는 Inverse mapping을 학습하기 위해 Invertible function을 학습 𝑝′ 𝑥 (𝑥) 𝑝𝑧 𝑧 ~𝑁 𝑝𝑥(𝑥) Iterative MC 𝑞(𝑥1|𝑥0) ∘ 𝑞(𝑥2|𝑥1) ∘ ⋯ ∘ 𝑞(𝑥𝑇 = 𝑧|𝑥𝑇−1) Iterative MC 𝑃𝜃(𝑧1|𝑧0) ∘ 𝑃𝜃(𝑧2|𝑧1) ∘ ⋯ ∘ 𝑃𝜃(𝑧𝑇 = 𝑥|𝑧𝑇−1) • 학습된 Diffusion model의 조건부 확률 분포 𝑃𝜃(𝑥|𝑧)을 통해 특정한 패턴의 분포 도출 • 생성에 활용되는 조건부 확률 분포 𝑃𝜃(𝑥|𝑧) 을 학습하기 위해 Diffusion process 𝑞 𝑧 𝑥 을 학습
  • 6. 6 01 Denoising diffusion probabilistic models Generative model Source: https://lilianweng.github.io/posts/2021-07-11-diffusion-models/
  • 7. 7 01 Denoising diffusion probabilistic models Diffusion? ▪ Diffusion process (Noising) ▪ Reverse process (Denoising) 𝑞 𝑥1:𝑇 𝑥0 ≔ ς𝑡=1 𝑇 𝑞(𝑥𝑡|𝑥𝑡−1) , 𝑞 𝑥𝑡 𝑥𝑡−1 ≔ 𝑁 𝑥𝑡; 1 − 𝛽𝑡𝑥𝑡−1, 𝛽𝑡𝑰 , 𝑥𝑡 = 1 − 𝛽𝑡𝑥𝑡−1 + 𝛽𝑡𝜖𝑡−1, 𝜖~𝑁(0, 𝐼) 𝑃𝜃(𝑥0:𝑇) ≔ 𝑃(𝑥𝑇) ς𝑡=1 𝑇 𝑃𝜃(𝑥𝑡−1|𝑥𝑡) , 𝑃𝜃 𝑥𝑡−1 𝑥𝑡 ≔ 𝑁(𝑥𝑡−1; 𝝁𝜃 𝑥𝑡, 𝑡 , 𝚺𝜃 𝑥𝑡, 𝑡 ) Fixed Learned ❖ Diffusion Model ▪ 생성모델의 일종으로, 학습 데이터의 패턴을 생성해내는 것을 목적으로 함 ▪ 패턴을 생성해내기 위해서 패턴에 노이즈를 넣어 망가뜨리고, 이를 다시 복원하는 조건부 함수를 학습하는 과정 (Reparameterization trick) 학습 대상
  • 8. 8 01 Denoising diffusion probabilistic models Diffusion? ❖ Diffusion Loss Regularization → Learning 𝛽𝑡 Reconstruction Denoising 더 간단하게 만들 수는 없을까? DDPM의 Contribution
  • 9. 9 01 Denoising diffusion probabilistic models DDPM ❖ Loss Simplification ▪ Remove Regularization Term Use Fixed 𝛽𝑡 Inductive Bias ↑ (∵ 학습 가능한 부분을 없애고 사용자가 설계한대로 모델을 구성)
  • 10. 10 01 Denoising diffusion probabilistic models DDPM ❖ Loss Simplification ▪ Remove Regularization Term Use Fixed 𝛽𝑡 Inductive Bias ↑ (∵ 학습 가능한 부분을 없애고 사용자가 설계한대로 모델을 구성)
  • 11. 11 01 Denoising diffusion probabilistic models DDPM ❖ Loss Simplification ▪ Denoising loss Modification - #1 𝚺𝜃 𝑥𝑡, 𝑡 의 상수화 𝚺𝜃 𝑥𝑡, 𝑡 = 𝜎𝑡 2 𝑰 (time dependent constants) → t시점까지 누적된 noise 𝜎𝑡 2 = ෨ 𝛽𝑡 = 1−ഥ 𝛼𝑡−1 1−ഥ 𝛼𝑡 𝛽𝑡 or 𝜎𝑡 2 = 𝛽𝑡 ( ത 𝛼𝑡 = ς𝑠=1 𝑡 𝛼𝑠, 𝛼𝑡 = 1 − 𝛽𝑡) 𝑃𝜃 𝑥𝑡−1 𝑥𝑡 ≔ 𝑁(𝑥𝑡−1; 𝝁𝜃 𝑥𝑡, 𝑡 , 𝚺𝜃 𝑥𝑡, 𝑡 ) 𝑃𝜃 𝑥𝑡−1 𝑥𝑡 ≔ 𝑁(𝑥𝑡−1; 𝝁𝜃 𝑥𝑡, 𝑡 , 𝜎𝑡 2 𝑰) 학습 대상
  • 12. 12 01 Denoising diffusion probabilistic models DDPM ❖ Loss Simplification ▪ Denoising loss Modification - #2 𝝁𝜃 𝑥𝑡, 𝑡 를 Denoising matching을 통해 새롭게 정의 𝑞 𝑥𝑡−1 𝑥𝑡, 𝑥0 = 𝑁(𝑥𝑡−1; ෤ 𝜇𝑡 𝑥𝑡, 𝑥0 , ෨ 𝛽𝑡 ∙ 𝐈) 𝑝𝜃 𝑥𝑡−1 𝑥𝑡 = 𝑁(𝑥𝑡−1; 𝜇𝜃 𝑥𝑡, 𝑡 , ෨ 𝛽𝑡 ∙ 𝐈) & KL Divergence <Bayes Rule>
  • 13. 13 01 Denoising diffusion probabilistic models DDPM ❖ Loss Simplification ▪ Denoising loss Modification - #2 𝝁𝜃 𝑥𝑡, 𝑡 를 Denoising matching을 통해 새롭게 정의 𝑥𝑡 𝑥0, 𝜖 = ത 𝛼𝑡𝑥0 + 1 − ത 𝛼𝑡𝜖 for 𝜖~𝑁 0, 𝐈 ( ത 𝛼𝑡 ≔ ς𝑠=1 𝑡 𝛼𝑠 , 𝛼𝑡 = 1 − 𝛽𝑡)
  • 14. 14 01 Denoising diffusion probabilistic models DDPM ❖ Loss Simplification ▪ Denoising loss Modification - #2 𝝁𝜃 𝑥𝑡, 𝑡 를 Denoising matching을 통해 새롭게 정의
  • 15. 15 01 Denoising diffusion probabilistic models DDPM ❖ Loss Simplification ▪ Denoising loss Modification - #3 Total Process 수식적으로 복잡, 고려 안 해줘도 큰 성능 차이 X 계수항 제거
  • 16. 16 01 Denoising diffusion probabilistic models DDPM ❖ Loss Simplification Regularization → Learning 𝛽𝑡 Reconstruction Denoising
  • 17. 17 01 Denoising diffusion probabilistic models Experiments 해명 1. noise-to-image에 따른 RMSE 2. noise-to-image에 따른 정보량 3. X축: 정보량 / Y축: RMSE → 3번 그래프를 보면 적은 정보량에서 이미 RMSE(왜곡)가 충분히 낮아지는 것을 알 수 있음. → Reverse process 초반에 정보량은 적지만 왜곡은 충분히 제거 & 후반에는 거의 보이지 않는 왜곡 (imperceptible distortion)을 줄이는 정보가 존재 • IS(Inception score): 생성된 이미지로부터 분류 Task 수행할 때 얼마나 특정 class로 추정을 잘하는 지에 대한 score (분류 성능 & 전체 class 고르게 생성 → IS ↑ ) • FID(Frechet Inception Distance): 실제 데이터를 참고하여 (정확하게는 데이터 분포를 참고) 평균, 공분산을 비교 / 낮을수록 좋은 지표 • NLL (Negative Log Likelihood): 이미지 픽셀당 옳게 생성했는지를 판단하는 지표 / NLL이 높다면 불확실함 (이미지 픽셀당 평균 확률이 낮음)
  • 18. 18 01 Denoising diffusion probabilistic models Experiments ⑴ ⑵ ⑶ ⑷ • 계수항은 t가 증가할수록 작아지는 경향 有 → Large t (more noisy) 시점의 Loss 값이 down-weight되는 현상 • 계수항을 제거하여 noise가 더 심한 step에서의 Loss 비중을 높이는 방법 → Denoising에 더 집중 가능 계수항 Source: https://www.youtube.com/watch?v=_JQSMhqXw-4&t=1431s
  • 19. 19 02 Anomaly Detection With Denoising Diffusion Probabilistic Models Using Simplex Noise Introduction ❖ Background • 본 연구는 의료 분야 이미지 Anomaly Detection을 목표로 함. • 생성모델 기반 이상탐지: 정상(Healthy) 이미지만을 복원할 수 있도록 학습 → 이상(Anomalous) 이미지도 정상 이미지처럼 복원하여 탐지 • Diffusion 생성모델 선택 이유: GAN보다 mode coverage가 좋고, VAE보다 higher sample quality • 기존 방법론의 한계점: ① Too expensive Sampling times ② Gaussian noise → Fail to detect anomalies (너무 좋은 성능) ❖ Contribution ① “Partial diffusion strategy” ② “Multi-scale (multi-octave) Simplex noise”
  • 20. 20 02 Anomaly Detection With Denoising Diffusion Probabilistic Models Using Simplex Noise Methodology - Simplex Noise ① ❖ Gaussian noise의 한계점 • Natural image는 낮은 빈도의 성분(ex. 이상 region) 이 이미지에 더 많은 기여를 하도록 하는 멱법칙(power law) 분포를 가짐. • 멱법칙? ≈ 파레토 법칙 → 위의 말을 쉽게 써보면 이미지를 분류하는데 대부분의 부분보다는 낮은 빈도로 보이는 작은 부분들이 효과적임. • Gaussian noise는 왜 문제? DDPM이 high quality로 복원하기 위해서 낮은 빈도 부분은 noise를 약하게, 높은 빈도 부분은 noise를 강하게 주는 경향 존재 • 따라서, 이미지 상황과 유사하게 멱법칙(power law) 분포를 따르는 noise를 넣어줘야 함. (80 : 20 Rule) Gaussian noise Simplex noise Low Frequency
  • 21. 21 02 Anomaly Detection With Denoising Diffusion Probabilistic Models Using Simplex Noise Methodology - Simplex Noise ② ❖ Simplex Noise ≈ Perlin noise (펄린 노이즈) • Ken Perlin이 1980년대 초 영화 ‘트론‘ 제작 중 컴퓨터 효과를 위한 단계적 텍스처를 만들기 위해 개발한 노이즈 함수 • 자연계의 불규칙한 노이즈를 CG로 표현하는 방법이며 프랙탈 합을 이용해서 이상적인 노이즈를 만들어 냄 • Benefit : the corruption is more structured | the denoising process will be able to “repair” those structured anomalies Octave: 여러 noise 중첩
  • 22. 22 02 Anomaly Detection With Denoising Diffusion Probabilistic Models Using Simplex Noise Methodology – AnoDDPM ❖ AnoDDPM • Gaussian & Simplex noise 같이 사용해서 비교 실험 • Simplex noise → Starting frequency = 𝜈 = 2−6 𝑁 = 6 𝛾 = 0.8 (decay)
  • 23. 23 02 Anomaly Detection With Denoising Diffusion Probabilistic Models Using Simplex Noise Training & Inference (Segmentation)
  • 24. 24 02 Anomaly Detection With Denoising Diffusion Probabilistic Models Using Simplex Noise Experiment Dataset ❖ Healthy Dataset • Neurofeedback Skull-Stripped (NFBS) Repository • Database of 125 T1-weighted anatomical MRI scans that are manually skull-stripped • Full Skull image: 복잡 But 이상 징후가 다양하게 발생 가능 • Training : Testing = 100 : 25 ❖ Anomalous Dataset • Centre for Clinical Brain Sciences from the University of Edinburgh로 부터 받은 brain tumours dataset • Database of 22 T1-weighted MRI scans
  • 25. 25 02 Anomaly Detection With Denoising Diffusion Probabilistic Models Using Simplex Noise Gaussian vs Simplex • Gaussian diffusion은 확실히 high quality sample은 잘 만듦 BUT 𝜆를 250, 500, 750 늘려갈수록 아예 다른 이미지 생성 𝜆 250 500 750 • 다른 종양을 가진 환자의 뇌를 잘 복원하기 위해 필요한 Release time은 상이함 → 해당 데이터셋에서 일반적으로 250이 optimal ❖ Gaussian noise diffusion ❖ Simplex noise diffusion
  • 26. 26 02 Anomaly Detection With Denoising Diffusion Probabilistic Models Using Simplex Noise Performance
  • 27. 27 02 Anomaly Detection With Denoising Diffusion Probabilistic Models Using Simplex Noise Conclusion ❖ Future work 1. Simplex noise의 불균형 때문에 sample quality 가 조금은 떨어지는 경향 → 여러 noise를 연구하여 Customize 2. DDPM은 Markov Chain을 사용, 즉 Stochastic 함 → 한 번 생성하는 것보다는 여러 번 생성해서 평균 낸 이미지로 이상 탐지 수행 3. 3D 이미지 혹은 Color 이미지에도 적용 ❖ Conclusion • 실험에서도 알 수 있듯, not require large datasets → 이상탐지 수행 가능 • Gaussian noise 대신에 Simplex noise를 사용한 점 • 의료 분야 외에 다른 도메인에서도 적용 가능 → ex) MVTec AD • Full length Markov chain이 필요하지 않은 분야에 적용하면 좋을 것 (image enhancement, semantic segmentation, filtering)
  • 28. 28 Reference 1. Ho, Jonathan, Ajay Jain, and Pieter Abbeel. "Denoising diffusion probabilistic models." Advances in Neural Information Processing Systems 33 (2020) 2. Wyatt, Julian, et al. "AnoDDPM: Anomaly Detection With Denoising Diffusion Probabilistic Models Using Simplex Noise." Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. 2022. 3. 유튜브 강의 [DSBA 연구실 김정섭 석사과정], https://www.youtube.com/watch?v=_JQSMhqXw-4&t=1431s 4. 유튜브 강의 [PR 409], https://www.youtube.com/watch?v=1j0W_lu55nc 5. 블로그, https://ivdevlog.tistory.com/14
  • 29. Smart Production Systems Lab. 구병모 2023.01.06 Thank you