開始接觸darknet, 就連如何使用它, 都是一頭霧水, 只能copy 別人現成的方法, 但是自己的目錄結構不同於例子, 在不明白命令及參數的含義下, 只能try and error.
在一段時間之後, 比較明白原始作者定義的含義, 也比較能理解 darknet 整體的使用方式. 就此做下記錄, 讓使用者可以很快的進入狀況.
沒親自trace source code, 只以使用過的命令, 做理解的說明, 也加上些曾看到的用法如果有錯請見諒
語法:
Darknet detection [function] [file for define_path.data] [model configuration file.cfg] [weight_file] –xxx option_xxx
Function : train, demo , test , map
train : training 用
demo: inference single file, video file, or camera
test: test a lot of files
map: mean AP calculation
valid: validation images in valid_lst
以字串來決定要執行的功能,
define_path.data : 檔案中定義了數個給sub function 所須的目錄.
內容如下: // (含//) 以後的字是不存在檔案中的, 在此只是用來當註解
classes= 80 // 總共 多少個 物件的class
train = D:/YOLO_DATA/train2014.txt // train 用的檔案list, 每個檔案內一行, 就給出path name 不確定是相對目錄路徑, 或是絕對路徑. 直接使用絕對
#train = E:/MSCOCO/5k.txt
valid = D:/YOLO_DATA/val2014.txt // validation 用的檔案
names = D:\YOLO_DATA/coco.names // classes 定義的數量, 列出class 的名稱, 一個class 一行
backup = backupCOCO // 會將train所產出的weight file 或是固定次數的中間weight 的結果, 放置在這個目錄, 這目錄是相對於 darknet.exe 所在的目錄
eval=coco
configuration file.cfg
定義了training 過程所需的參數 [net]
及定義了 NN-model 的各級內容
-xxx_option argument_string
xxx_option
-dont_show // not show the result
-ext_output // 輸出檢測後的目標坐標
-out_filename // 輸出檢測後的像檔or video file, 同時會畫上找到的矩形及物件名稱
-i id_of_GPU
-gpus 1, 2, 3 // list of gpu
-thresh 0.1 // threshold for inference image, detect
-c 0 // camera id=0, 第0號camera as input
例子:
darknet detector train d:/coco.data d:/yolov4.cfg yolov4_last.weights
使用二個設定檔, 決定train 參數及內容, 從yolov4_last.weights 當作預訓練結果, 續往下做訓練
darknet detector demo d:/coco.data d:/yolov4.cfg myyolov4_last.weights -out_filename result.avi
使用camera 當input 將畫框的結果放到result.avi
darknet.exe detector map d:/coco.data d:/yolov4.cfg myyolov4_last.weights -points 101
計算 mAP, points 101 是指COCO
留言列表