AIA技術班校友共筆
      • 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
    1
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # 2020 YOLOv4 YOLOv4 提出了 Object detection 中各個問題的分類:Input, Backbone (CNN 架構) , Neck (融合各種 scale 的方式) , Head (如何propose bounding box 的方法 與 loss function) ![](https://i.imgur.com/fvOs1jQ.png) 而 YOLOv4 的架構選擇如下 - Backbone: CSPDarknet53 - Neck: SPP, PAN (PANet) - Head: YOLOv3 以下為網路架構: ![](https://i.imgur.com/CjCLGo4.png) ## Backbone: CSPDarknet53 我們將 CSP 架構套用到 Darknet53 上即是 CSPDarknet53。 什麼是 CSP?CSPNet (Cross-Stage Partial Network) 提出主要是為了解決三個問題: 1. 增強 CNN 的學習能力,能夠在輕量化的同時保持準確性。 2. 降低計算瓶頸 3. 降低內存成本 我們將 CSP 架構套用到 DensNet 上 ![](https://i.imgur.com/GMFSgxk.png) ![](https://i.imgur.com/1fWyjvJ.png) ![](https://i.imgur.com/0uhZyxK.png) 加上 CSP 架構後可以觀察到不僅參數量減少,甚至還會提高準確率。 ![](https://i.imgur.com/jgDR5Ec.png) ## Neck: SPP 圖(a) 是原本 Yolov2 的方式,2D feature map 被弄成 1D 的 feature,所以最後面需要接 fully-connected layers, 圖(b) 則是把他們再接起來,所以後面能繼續接 CNN,為 Yolov3 使用的方式。然後好處是你可以想像成他又多了一層這樣,如下下圖所示 ![](https://i.imgur.com/DgRnyea.png) ![](https://i.imgur.com/XIXXjxK.png) ## Neck: PAN (PANet) 之前有介紹過 FPN,而 PANet 就是 FPN 的進階版。 ![](https://i.imgur.com/wsPHGwM.png) 而 YOLOv4 有更改一個地方,就是將 addition 改成 concatenation ![](https://i.imgur.com/q8dppYk.png) ## Head: YOLOv3 YOLOv3 ## Bag of Freebies & Bag of Specials 論文裡面還分兩類改善方式 - Bag of Freebies (BoF) 是指不增加推論時間又能夠提高模型準確率的方法 - Bag of Specials (BoS) 是指增加一些推論時間但能夠提高模型準確率的方法 而 YOLOv4 用到以下這些技巧: ![](https://i.imgur.com/TlO2OAH.png) ### BoF for backbone - CutMix 混合與修改 label 的操作 ![](https://i.imgur.com/vxvlnKc.png) - Mosaic data augmentation 一張圖片當4 張用,某種程度有增加 minibatch size 的效果 ![](https://i.imgur.com/RwqhpL2.png) - DropBlock regularization 因為圖片是連續的,所以只隨機 dropout 幾個 pixel 是沒什麼用的,要的話就是一整個區域。 ![](https://i.imgur.com/EnUgIKf.png) - Class label smoothing 因為最後面一層是 cross entropy,所以你要讓你的預測接近 1 的話,這個 label 就要 predict 一個很大的數,假設你最後一層的 output 是 [0.1, 0.1, 0.1, 0.1, 6] 做完 cross entropy 變成 [0.002, 0.002, 0.002, 0.002, 0.992],你會發現 6 是 0.1 的 60 倍,這種嚴重的偏差,很容易導致 overfitting,所以解決方式很簡單,把你的 ground truth 如下面的公式改成 [0.02, 0.02, 0.02, 0.02, 0.92],也就是說過度完美的解答是不好的。 ![](https://i.imgur.com/K10knvJ.png) ### BoS for backbone - Cross-Stage Partial connections (CSP) - Mish activation 除了大家熟知的 ReLU 以外,還有 leaky ReLU (<0 時還有一點斜率) 為主流。而 Yolov4 使用 Mish activation 為連續可微的函數,如下圖 ![](https://i.imgur.com/YBS1wN4.png) ![](https://i.imgur.com/J2PWzTD.png) 數據結果證明 Mish 是比較厲害的 ![](https://i.imgur.com/MNUtQsF.png) - Multi-input Weighted Residual Connections (MiWRC) ### BoF for detector - CIoU-loss ![](https://i.imgur.com/ccCND8B.png) **IoU-loss:** IoU-loss 有很明顯的缺點,就是當 Bbox 與 ground truth 無交集時,IoU 為 0,並且不能反映出兩個 box 間的遠近,這樣就失去了梯度方向,也就是說無法優化。因此衍伸出了 GIoU-loss,DIoU-loss 和 CIoU-loss 等 loss,這些 loss 都是在 IoU-loss 的基礎上增加一個懲罰項 $R(𝐵,𝐵^{𝑔𝑡})$ 來改進 loss。 ![](https://i.imgur.com/uIGx3xP.png) **GIoU-loss:** Giou-loss 在 IoU-loss 的基礎上增加一個懲罰項,根據同時包含兩個 box 的最小區域去做計算,當 bbox 的距離越大時,懲罰項將越大。 ![](https://i.imgur.com/u428wLI.png) 這邊可以觀察到兩個 box 離得越遠 loss 越大。 ![](https://i.imgur.com/YNAveZ1.png) 但 GIoU 還是有以下缺點,這些缺點會導致收斂速度變慢: 1.當兩個 box 重疊時, GIoU-loss 會退化成 IoU-loss ,而且值都會一樣 ![](https://i.imgur.com/fWWAt1V.png) 2.當兩個 box 平行或是垂直的時候,會導致 GIoU-loss 的值都會一樣 ![](https://i.imgur.com/wODThTZ.png) **DIoU-loss:** DIoU 比 GIoU 更符合 Bbox 回歸的機制,除了參考 GIoU 的方法外還考慮了兩個 box 的中心距離差,使得收斂變快。 這邊的 c 是使用同時包含兩個 box 的最小區域的對角線去計算。 而 d 是使用兩個 box 中心點間的歐式距離。 ![](https://i.imgur.com/8d3lHAK.png) 下圖可以觀察到,DIoU-loss 隨著中心點不同而改變,克服了第一個缺點。 ![](https://i.imgur.com/LZllwUK.png) 下圖可以觀察到,DIoU-loss 隨著中心點不同而改變,克服了第二個缺點。 ![](https://i.imgur.com/Duz4TWu.png) 而收斂速度方面如下圖所示: ![](https://i.imgur.com/tOrjpKn.png) **CIoU-loss:** 在 DIoU 的基礎下又考慮了長寬比這項因素,懲罰項如下式,其中 𝛼 是權重函數,𝜐 是用來衡量兩個 box 長寬比的相似性。 ![](https://i.imgur.com/4mz5S6B.png) 下圖可以觀察到兩個 box 的長寬比不同 CIoU-loss 也會有所影響。 ![](https://i.imgur.com/z2pMAip.png) - Cross mini-Batch Normalization (CmBN) ![](https://i.imgur.com/Wmwiy5L.png) - DropBlock regularization - Mosaic data augmentation - Self-Adversarial Training (SAT) 這個作者還在開發中,用 adversal (對抗) 來避免 overfit。 作法如下: 1.圖片輸入 model 後,中間會輸出 feature 的值 2.扣掉這些值,也就是沿著 gradient 對圖片做修改 (model 的參數沒有動) 3.然後把修改的圖片再丟進 model 訓練。 e.g. 如果這個 model 只判斷狗的眼睛,就 classify 出他是狗的話,那 SAT 會在步驟二把 狗狗的眼睛的 feature 從圖片中扣掉。這樣 model 就必須學到狗的其他特徵,才可以 classify 出來。 - Cosine annealing scheduler 因為模型應該會收斂,所以我們要用越來越小的 learning rate 才好。會比原本的 schedule 一段時間就降 learning rate 來的好(藍色虛線)。 ![](https://i.imgur.com/fCMluzh.png) ### BoS for detector - Mish activation - SPP-block - SAM-block 對區域做 attention,會生成 HxWx1 的 attention ,哪些區域重要就會被加權起來。 ![](https://i.imgur.com/0mc6z3p.png) - PAN path-aggregation block - DIOU-NMS 是在做 objection detection 時,會 propose 出許多同義的 bounding box。NMS 作法就是有 overlap 到的就 deduplicated。 ![](https://i.imgur.com/iEUrD5Q.png) 當然有可能會錯刪(比如說 confidence 不高且靠得很近),所以 DIOU-NMS 就是再加上距離的 criteria ![](https://i.imgur.com/eMuqdKJ.png) --- ###### tags: `課程共筆`

    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