履歷軌
      • 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
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners 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
    • 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 Help
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
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners 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
    ###### tags: `2022Q2技術研討`, `detection` # DETR (DEtection TRansformer) ## 簡介 :pushpin: 本篇論文是 FB 首度將 NLP 的 transformer 用在 CV 的 object detection 上,將 object detection 視作一個 direct set prediction problem,並且精簡了很多 object detection 上的額外操作(non-maximum suppression, anchor generation) 的 state-of-art 的目標檢測模型。(2020 年的拍謝XD) [github codes](https://github.com/facebookresearch/detr) ## 與傳統 Faster R-CNN 流程比較 ![](https://i.imgur.com/KLJd7oU.png) - 流程非常的簡潔 ## 模型架構 ### transformer encoder / decoder 架構 ![](https://i.imgur.com/oRGVpCT.png) 1. <font color=red>Backbone</font>: 先跑CNN,然後把最後一層透過Conv1d降維,得到了feature map,然後轉成(d,HW)的shape等下準備餵進transformer 2. <font color=red>Transformer encoder</font>: 然後把1.的output丟到transformer encoder上做multi-head self-attention - transformer只在一開始加了position encoding,TEDR覺得一次不夠,每一個encoder block都給你加好加滿 3. <font color=red>Transformer decoder</font>: 在transformer decoder的部分,使用N個d維的vector來當作object query vector - decoder也給你每層加position encoding,值得一提的是這裡的position encoding是直接用query vector 4. <font color=red>Prediction feed-forward networks (FFNs)</font>: 最後接FFN(feed-forward networks)產生N個prediction,前面有提到這個N會比image object數量還來的大,所以會有一個特殊的class叫做no object,可以把他想成圖片的背景 ![](https://i.imgur.com/Scwj846.png) ### loss function 簡介 :pushpin: bipartite matching (二分匹配) ![](https://i.imgur.com/1iPZbK1.png) - 兩邊 sets 的元素數量都是 N ,所以我們是可以做一個配對的操作,讓左邊的元素都能找到右邊的一個配對元素,每個左邊元素找到的右邊元素都是不同的,也就是一一對應。這樣的組合可以有 N! 種,這個 N 即是模型可以預測的最大數量。 - 透過[匈牙利演算法](https://blog.csdn.net/u014754127/article/details/78086014)來處理 matching problem :pushpin: object detection set prediction loss 符號定義: - y 是 ground truth 的 objects set,$\hat{y} = { \hat{y_i} }^N_{i=1}$ 是 predicts set - 這邊會假設 $N$ 是一個大於 image 所應應有的 object 數量(根據 coco dataset 作者選了 N=100),不過這樣後續匹配的時候就<font color=red>必須對 ground truth 去做 padding 才能湊到 N 組 object</font>,pad 的方式是使用用$\varnothing$(代表沒有 object)來 padding - $y_i$ 是 ground truth 的一組 object,每一個 $y_i$ 包含了 class label 和 bounding box 的四個值: $y_{i}=\left(c_{i}, b_{i}\right)$ (class labels and box coordinates x,y,w,h) - 對於一個 $y_i$,他對應到的 prediction 是 $\hat{y}_{\sigma(i)}$ (用匈牙利演算法) ![](https://i.imgur.com/3KlkPAw.png) - $-\log \hat{p}_{\hat{\sigma}(i)}\left(c_{i}\right)$是<font color=red>希望predict分類分的越準越好</font> - $\hat{p}_{\sigma(i)}\left(c_{i}\right)$是$\sigma (i)$被預測維class $c_i$的機率 - 當分的正確的時候(也就是機率=1)這一項就是0 - $1_{\left\{c\_{i} \neq \varnothing\right\}} \mathcal{L}_{\mathrm{box}}\left(b_{i}, \hat{b}_{\hat{\sigma}}(i)\right)$則是<font color=red>bounding box的重合度匹配</font> - 使用了 L1 loss 和 IOU(單純用 L1 loss 會造成這個loss 過於依賴 bounding box 的大小,所以加上了 IOU) :pushpin: object quries (又稱 prediction slots) - object queries 是可學習的 embedding,與當前輸入影象的內容無關(不由當前影象內容計算得到) ![](https://i.imgur.com/SKL77Ml.jpg) > 每個點都是一個 object,上圖是從 COCO 2017 val set 的所有 object 預測分佈在各 object queries 的情形 > - 綠色的點代表小 bbox > - 紅色的點代表大的 horizontal bbox > - 藍色的點代表大的 vertical bbox - object quries 是隨機初始化,並隨著網路的訓練而更新,可以想成是學習了整個訓練集上的統計資訊 - 在目標檢測中每個 object query 可以看作是一種可學習的動態anchor ## 成效 ![](https://i.imgur.com/J1xylRn.png) ### 特色 - 將目標檢測問題看做 Set Prediction 問題,用二分圖匹配實現 label assignment,準度比加強版的 Faster R-CNN 好 - parallel decoding - less computation (no nms) - anchor free ### 問題 - 收斂速度慢 (在 COCO 基準上,DETR 需要 500 個 epoch 才能收斂,這比 Faster R-CNN 慢了 10 到 20 倍) - 在初始化時transformer中每個query對所有位置給予幾乎相同的權重,這使得網路需要經過長時間的訓練將attention收斂到特定的區域 - 對於小 object 的準確度較低 - 只取 cnn 最後的 layer 看的是比較大物件的 features (Transformer 的編碼器中注意力權重計算的複雜度與畫素個數的平方成正比,所以沒有辦法用高解析度的 feature map) - 同一張圖片太多 object 時,預測力大幅下降 (training data 比較沒有這種 case) ![](https://i.imgur.com/paIOTtI.png) ## 參考資料 https://www.gushiciku.cn/pl/gXi7/zh-tw

    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 Google 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