機械学習・AI【物体検出】vol.5 :YOLOv3のファンクションと引数のまとめ(私家版)

【物体検出】vol.5 :YOLOv3のファンクションと引数のまとめ(私家版)

YOLOに触れるうちに、様々なコマンドを実行することになりますが、「一体どれだけの機能があるんだろうか?何をオプションとして指定できるのだろうか?」 と知りたくなるかと思います。

ここでは、良く使うコマンドと、Alexeyさんのサイトに載っている、"How to use on the command line"と、cのソースファイル内に書かれているargsを参考に、すべてのfunctionとargsを洗いざらいまとめてみました。
下記の表のうち(カッコ)書きで書かれたものは、当方で動作を確認できていないものです。「これは良く使うよ」というものを太字で表しました。

どうぞご活用下さい。

基本的な書式

./detector {

function説明

train学習
testテスト
demo動画テスト
mapmAP算出
calc_anchors

}

 +

データ定義:例:cfg/coco.data
 + 
ネットワーク設定:例:cfg/yolov3.cfg
 + 
重み:例:yolov3.weights

 +

Args{

-dont_showdont_show(1)
(-show)show
(-letter_box)letter_box
-mapcalc_map
(-points)map_points
(-check_mistakes)check_mistakes
(-show_imgs)show_imgs
(-mjpeg_port)mjpeg_port(8090)
(-json_port)json_port(8070)
-out_filename*out_filenamedata/test/01_out.mp4
-out*outfileresult/result.json
-prefix*prefixresult_v/frame_
-threshthresh0.5
-iou_threshiou_thresh0.75
(-hier)hier_thresh
(-i)gpu_index(0),-1:no_gpu
-ccam_index0
(-s)frame_skip
(-num_of_clusters)num_of_clusters
(-width)width
(-height)height
-ext_outputext_output
-save_labelssave_labels
(-gpus)gpu number
(-clear)



組み合わせ

traintestvaliddemomaparg動作
111-dont_showdont_show
-showshow
11-letter_boxletter_box
1-mapcalc_map
1-pointsmap_points
-check_mistakescheck_mistakes
1-show_imgsshow_imgs
11-mjpeg_portmjpeg_port
1-json_portjson_port
11-out_filename*out_filename
-out*outfile
1-prefix*prefix
11-threshthresh
1-iou_threshiou_thresh
11-hierhier_thresh
-i?
1-ccam_index
1-sframe_skip
-num_of_clustersnum_of_clusters
-widthwidth
-heightheight
11-ext_outputext_output
1-save_labelssave_labels
1-gpusgpu number
1-clear

 

良く使うパターン

学習

-mapオプションで学習時のmAPのグラフを書いてくれます。GPUメモリが少ない場合には落ちるので要注意。

darknet.exe detector train data/originalmodel.data cfg/yolov3-voc_originalmodel.cfg darknet53.conv.74 -map

静止画の検出(一括処理)

処理したい画像のリストを作って、食わせちゃえば一括処理できます。

darknet.exe detector test data/originalmodel.data cfg/yolov3-voc_originalmodel_test.cfg backup/originalmodel/yolov3-voc_originalmodel_last.weights -i 0 -thresh 0.5 -dont_show -ext_output < data/testimage/originalmodel/jpeglist.txt -out data/originalmodel/result.json > data/originalmodel/result.txt

動画の検出をして動画を書き出す

リアルタイムに検出結果をモニタリングしたい場合は、-dont_show 1を削除すればOKです。 

darknet.exe detector demo data/originalmodel.data cfg/yolov3-voc_originalmodel_test.cfg backup/originalmodel/yolov3-voc_originalmodel_last.weights -thresh 0.5 data/testimage/originalmodel/01.mp4 -dont_show 1 -ext_output -out_filename data/testimage/originalmodel/01_out.mp4 -out data/testimage/originalmodel/out.json > data/testimage/originalmodel/01_res.txt

動画の検出をして静止画を書き出す

実は・・・結構凄いんです。

darknet.exe detector demo data/originalmodel.data cfg/yolov3-voc_originalmodel_test.cfg backup/originalmodel/yolov3-voc_originalmodel_last.weights -ext_output data/testimage/originalmodel/01.mp4 -prefix results_v/01/img > results_v/01/result.txt

実は、あまり知られていないオプションだと思いますが・・・(物凄い秘密を言いますよ!)
「 demoモードで-prefixオプションを付けると、検出結果が静止画連番で書き出されます。」

 

評価

各イテレーション毎のmAPをテキストで書き出します。ここから各区分ごとのTP、TFを拾ってExcelでグラフにするといい感じ!。 

darknet.exe detector map data/originalmodel.data cfg/yolov3-voc_originalmodel_test.cfg backup/originalmodel/yolov3-voc_originalmodel_1000.weights -iou_thresh 0.5 -thresh 0.5 > backup/originalmodel/result_1000.txt

 

 ▼この記事を書いたひと

001@2x.png

R&Dセンター
松井 良行

R&Dセンター 室長。コンピュータと共に35年。そしてこれからも!

 

おすすめの関連記事

機械学習・AIの最新記事


お問い合わせ

ご意見・ご質問などお気軽にお問い合わせ下さい。
ナカシャクリエイテブ株式会社

●富士見事務所 TEL : 052-228-8733 FAX : 052-323-3337
〒460-0014 愛知県名古屋市中区富士見町13−22 ファミール富士見711  地図
交通部 R&Dセンター

Email:メールでのお問い合わせ