Home 實作yolov2(YOLO9000)
Post
Cancel

實作yolov2(YOLO9000)

yolov2 詳細說明

https://senliuy.gitbook.io/advanced-deep-learning/chapter1/yolo9000-better-faster-stronger

Darknet-19與YOLOv2

目前Github上的YOLOv2已經被修改過,和論文上的描述並不一樣,必須參考最原始的cfg,而且必須要是voc的版本。
https://github.com/pjreddie/darknet/blob/c6afc7ff1499fbbe64069e1843d7929bd7ae2eaa/cfg/yolo_voc.cfg

論文的第三章Faster提到Darknet-19是一個classification model,他是YOLOv2的基礎。
在Training for detection提到YOLOv2是刪掉Darknet-19的最後一個conv layers(以及他後面的其他layer),並且用3個3 x 3 x 1024 conv layer 最後搭配 1 x 1 x 類別數量的conv layer。

We modify this network for detection by removing the last convolutional layer and instead adding on three 3 × 3 convolutional layers with 1024 filters each followed by a final 1 × 1 convolutional layer with the number of outputs we need for detection.

Darknet源碼註解

region layer的biases就是anchors的值

實作Conv2dBatchLeaky

Conv

activation為linear時沒有做任何事 https://github.com/AlexeyAB/darknet/blob/0faed3e60e52f742bbef43b83f6be51dd30f373e/src/gemm.c#L2337

BatchNormal

問題: 在pytorch有momentum,在darknet有沒有?

Leaky

region layer

Pytorch實作

下面以圖片作為輸入來舉例

  • CONV2D: 輸入的tensor每一個維度所對應的是\((N,C_{in},H,W)\)
    • \(N\): 照片張數,一次一張照片為1
    • \(C_{in}\):照片channel,彩色照片為3
    • \(H\): 照片高度
    • \(W\): 照片寬度

https://kikaben.com/yolo-v2-yolo9000/

參考:
yolov2架構講解(架構圖1x1 conv的地方有錯) https://kikaben.com/yolo-v2-yolo9000/

完整yolov2實作(高參考價值) https://github.com/Tencent/ObjectDetection-OneStageDet
https://zhuanlan.zhihu.com/p/45039781

http://yuenshome.space/timeline/2018-11/yolov2-region-source-code/
https://github.com/tztztztztz/yolov2.pytorch
https://github.com/gwinndr/YOLOv4-Pytorch/tree/master/model/layers

https://github.com/ruiminshen/yolo2-pytorch/blob/master/model/yolo2.py

韓文Darknet介紹 https://jjeamin.github.io/darknet_book/part3_src/batchnorm_layer.html

This post is licensed under CC BY 4.0 by the author.

實作yolov1

Python檢查記憶體用量