陳致希
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    這篇論文介紹了一個名為PaDiM(Patch Distribution Modeling)的新框架,用於在單類學習設置下同時檢測和定位圖像中的異常。PaDiM使用預訓練的卷積神經網絡(CNN)進行Patch嵌入,並利用多元高斯分佈對正常類別進行概率表示。它還利用CNN不同語義層之間的相關性來更好地定位異常。 異常檢測是正常類和異常類的二元分類,然而我們不太可能用supervised learning 來訓練這個模型,因為我們所能得到的異常樣本量極少,而異常示例可能有意想不到的模式,因此在異常檢測當中我們常常是用one-class來執行, 也就是說訓練的資料及只有正常的樣本,在測試時,與正常的樣本不一樣視為異常。 雖然已經有人提出一些異常定位和監測任務 in one-class learning,像是deep neural network training or KNN,但是他們都有各自麻煩的地方,像是KNN的算法會隨著資料及變大,計算量也以線性的方式增加,因此他們提出了 Patch distribution modeling 來提高可擴展性。 #### PaDiM PaDiM使用預訓練的卷積神經網絡(CNN)來進行embedding extracting並且有以下兩個特性 1.每個patch 都由多元的高斯分佈來描述 2.PaDiM 考慮了pretrain CNN 不同語意層之間的相關性 利用PaDiM我們在測試時的時間和空間的複雜度都很低,且與數據及的訓練規模無關 #### related work anomaly detection and localization method 可以被分為兩種, 一種是reconstructed based method 另一種是embedding similarity-based methods reconstructed based method: 基於重構的方法被廣泛用於異常檢測和定位。 自編碼器(AE) 變異自編碼器(VAE)或生成對抗網路(GAN) 只用在重建正常的訓練影像。 因此,我們可以發現異常圖像,因為它們和重建的影像長的不一樣。 在影像層面,最簡單的方法是將重建誤差作為異常得分,但來自latent space、intermediate activations或discriminator的額外資訊有助於更好地識別異常影像。 然而,為了定位異常點,基於重建的方法可以將像素重建誤差作為異常點得分或結構相似性。 另外,異常圖也可以由latent space產生的visual attention map。 雖然基於重構的方法非常直觀且可解釋,但由於AE有時也會對異常影像產生良好的重構結果,因此其性能受到限制 ### reconstructed based method 基於嵌入相似性的方法使用深度神經網路提取描述整幅影像的有意義向量,用於異常檢測或用於異常定位的影像patch. 不過,基於嵌入相似性的方法只進行異常檢測,雖然結果很好 ,但缺乏可解釋性,因為無法知道異常影像的哪一部分導致了高異常分數。 在這種情況下,異常得分就是測試影像的embedding向量與代表訓練資料集正常性的參考向量之間的距離。 normal reference可以是包含常態影像嵌入的N-sphere的中心,也可以是高斯分佈的參數或整個normal embedding 向量集。 SPADE採用了最後一種方法,據報告,它在異常定位方面取得了最佳效果。 不過,它在測試時有一組正常embedding向量上運行KNN演算法,因此推理複雜度與資料集的規模成線性關係。 這可能會阻礙該方法的工業應用。 **PaDiM產生用於異常定位的patch嵌入,與上述方法類似。不過,PaDiM 中的正常類別是透過一組高斯分佈來描述的,這些高斯分佈也對所用預訓練CNN模型的語義水平之間的相關性進行建模。我們選擇ResNet、Wide-ResNet和EfficientNet作為預訓練網路。得益於這種建模方法,PaDiM 的性能優於目前最先進的方法。此外,他的時間複雜度很低,而且與預測階段的訓練資料集大小無關。 ** ## PATCH DISTRIBUTION MODELING A. Embedding extraction 經過pre-trained的CNN能夠為異常偵測輸出相關特徵。 因此,我們選擇只使用預先訓練的CNN來產生Patch embedding vector,以避免繁瑣的神經網路優化。 PaDiM 中的patch 嵌入過程類似SPADE ,如圖2所示。 在訓練階段,正常影像的每個patch都與預訓練CNN活化圖中的空間對應活化向量相關聯。 然後,將不同層的激活向量連接起來,就能得到包含不同語意層次和解析度資訊的嵌入向量,從而對細粒度和全局語境進行編碼。 由於激活圖的分辨率低於輸出圖像的分辨率,因此許多像素具有相同的嵌入,然後形成在原始圖像分辨率下沒有重疊的像素patch. 因此,輸入圖像可以被劃分為(i,j)∈[1,W]×[1,H] 位置的網格,其中W × H 是用於產生嵌入的最大活化圖的解析度。 ![image](https://hackmd.io/_uploads/Sks5ZpmG0.png) 但是產生的patch嵌入向量可能包含冗餘訊息,因此我們對縮小其大小的可能性進行了研究。我們注意到,隨機選擇幾個維度比經典的主成分分析(PCA)演算法更有效。 B. Learning of the normality ![截圖 2024-05-05 凌晨12.07.24](https://hackmd.io/_uploads/Byw8a0XzC.png) 其中,正則化項 ϵ I 使樣本相關矩陣 ∑ i j full rank並invertible。最後,如圖2所示,每個可能的patch位置都與高斯參數矩陣的多元高斯分佈相關聯。 使用mahalanobis distance 將測試影像中位於 (i,j) 位置的斑塊打分數。 M x i j 可以解釋為測試patch嵌入 x i j 與學習分佈 N ( μ i j , ∑ i j )之間的距離,其中 M x i j 的計算方法如下 ![截圖 2024-05-05 凌晨12.23.12](https://hackmd.io/_uploads/BJvbb1VGA.png) 此圖中的高分表示異常區域。整個影像的最終異常得分是異常圖M的最大值 ### 實驗總結 數據集構建: 對於 MVTec AD 使用了 (-10,+10) 的隨機旋轉和隨機裁剪來進行訓練和測試集 模型使用: 試了 ResNet18, Wide ResNet-50-2 和 EfficientNet-B5. 對於 ResNet 系的,選取來前三個block?作為嵌入向量. 對於 EfficientNet-B5,取來7,20,26層作為嵌入向量. ![image](https://hackmd.io/_uploads/Hy8o8J4fC.png) 從結果可以看出,當特徵層結合使用時(Layer 1+2+3)以及使用更進階的模型(PaDiM-R18)時,通常可以得到更好的檢測效果。這可能是因為結合多層特徵可以捕捉到更多的信息,從而提高異常檢測的精度 降維度方法: 兩個結論: 1.隨機選取比PCA好 2.隨機選取200維減到100維度似乎影響不大 anomaly detection 是 one-class ,主要的挑戰如下:正常與異常行為之間的界限不明確、不同的領域對異常的確切定義不同、數據含有噪聲、異常行為的數據較難以蒐集(樣本量極少、在訓練時會有嚴重 imbalanced data 的問題) 以及正常行為並不是一成不變,會有不斷發展變化的 pattern。 潛空間(Latent Space)也被稱為潛特徵空間或嵌入空間,是一組元素在流形內的嵌入,相似的元素在潛空間內的距離較小。潛空間中的位置由一組潛變量定義,這些潛變量產生於元素間的相似性。 大多數情況下,潛空間的維度都要設定得低於數據點特徵空間的維度,意味著潛空間的構建實際上是降維,也可看作是數據壓縮的一種形式。[1]潛空間通常通過機器學習進行擬合,然後可被用作機器學習模型的特徵空間,包括分類器等監督預測器。 在這句話中的 "resolution" 通常指的是激活圖(activation map)的細節程度或清晰度,它是由神經網絡中特定層產生的。在機器學習和特別是在深度學習中,激活圖用於捕捉輸入數據(如圖像)中的特徵。"Resolution" 這個詞在這裡指的是這些激活圖的空間尺寸,也就是其寬度和高度的像素數量。高分辨率的激活圖能夠捕捉更細微的特徵,但同時也需要更多的計算資源。 visual attention map? normal reference gaussian parameter 常態分佈又稱高斯分佈 PaDiM是一種基於影像Patch的演算法。 它依賴於預先訓練好的CNN功能提取器。 將影像分解為多個面片,並使用不同的特徵提取層從每個面片中提取嵌入。 將不同層次的活化向量串聯起來,得到包含不同語意層次和解析度資訊的嵌入向量。 這有助於對細粒度和全局上下文進行編碼。 然而,由於產生的嵌入向量可能攜帶冗餘訊息,因此使用隨機選擇來降低維數。 在整個訓練批次中,為每個面片嵌入產生一個多元高斯分佈。 因此,對於訓練影像集的每個面片,我們有不同的多元高斯分佈。 這些高斯分佈表示為高斯參數矩陣。 在推理過程中,使用馬氏距離對測試影像的每個面片位置進行評分。 它使用訓練期間為面片計算的協方差矩陣的逆矩陣。 馬氏距離矩陣形成了異常圖,分數越高表示異常區域。

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully