【深度學習】darknet訓練分類
阿新 • • 發佈:2019-03-28
首先感謝
AlexeyAB
大神的darknet
版本
-
下載編譯就不說了簡單說下訓練。
-
首先在目錄找到cfg/darknet19.cfg
[net] # Training #batch=128 #subdivisions=2 # Testing batch=1 subdivisions=1 height=256 width=256 min_crop=128 max_crop=448 channels=3 momentum=0.9 decay=0.0005 burn_in=1000 learning_rate=0.1 policy=poly power=4 max_batches=800000 angle=7 hue=.1 saturation=.75 exposure=.75 aspect=.75 [convolutional] batch_normalize=1 filters=32 size=3 stride=1 pad=1 activation=leaky [maxpool] size=2 stride=2 [convolutional] batch_normalize=1 filters=64 size=3 stride=1 pad=1 activation=leaky [maxpool] size=2 stride=2 [convolutional] batch_normalize=1 filters=128 size=3 stride=1 pad=1 activation=leaky [convolutional] batch_normalize=1 filters=64 size=1 stride=1 pad=1 activation=leaky [convolutional] batch_normalize=1 filters=128 size=3 stride=1 pad=1 activation=leaky [maxpool] size=2 stride=2 [convolutional] batch_normalize=1 filters=256 size=3 stride=1 pad=1 activation=leaky [convolutional] batch_normalize=1 filters=128 size=1 stride=1 pad=1 activation=leaky [convolutional] batch_normalize=1 filters=256 size=3 stride=1 pad=1 activation=leaky [maxpool] size=2 stride=2 [convolutional] batch_normalize=1 filters=512 size=3 stride=1 pad=1 activation=leaky [convolutional] batch_normalize=1 filters=256 size=1 stride=1 pad=1 activation=leaky [convolutional] batch_normalize=1 filters=512 size=3 stride=1 pad=1 activation=leaky [convolutional] batch_normalize=1 filters=256 size=1 stride=1 pad=1 activation=leaky [convolutional] batch_normalize=1 filters=512 size=3 stride=1 pad=1 activation=leaky [maxpool] size=2 stride=2 [convolutional] batch_normalize=1 filters=1024 size=3 stride=1 pad=1 activation=leaky [convolutional] batch_normalize=1 filters=512 size=1 stride=1 pad=1 activation=leaky [convolutional] batch_normalize=1 filters=1024 size=3 stride=1 pad=1 activation=leaky [convolutional] batch_normalize=1 filters=512 size=1 stride=1 pad=1 activation=leaky [convolutional] batch_normalize=1 filters=1024 size=3 stride=1 pad=1 activation=leaky [convolutional] filters=1000 size=1 stride=1 pad=1 activation=linear [avgpool] [softmax] groups=1
-
樣本就是 類別_隨機數.png 也可以 隨機數_類別.png
-
網上很多人部落格說什麼不要在路徑出現多個或者無類別的單詞,很多人照貓畫虎不解其意實際上我們開啟原始碼根據錯誤定位到這個函式
void fill_truth(char *path, char **labels, int k, float *truth) { int i; memset(truth, 0, k*sizeof(float)); int count = 0; for(i = 0; i < k; ++i){ if(strstr(path, labels[i])){ truth[i] = 1; ++count; //printf("%s %s %d\n", path, labels[i], i); } } if(count != 1 && (k != 1 || count != 0)) printf("Too many or too few labels: %d, %s\n", count, path); }
-
路徑和類別strstr判斷的 所以我們可以知道只要路徑上只需要一個類別字元就可以了。甚至可以每個樣本放在每個資料夾也是可以的
-
編譯的時候會有些小問題,這個版本的darknet貌似為了rpc 加了一些c++的程式碼可以把那幾個cpp刪掉依賴也註釋就行了實際上用不到的
-
搞定這個就可以愉快的訓練了,有作者提供的darknet系列分類網路或者res系列的就可以訓練分類器了。
-
具體配置網上一大堆,盤他