Caffe-SSD 訓(xùn)練自己的數(shù)據(jù)集教程

SSD Train Own Data Tutorial

This tutorial written by Jin Tian, Master in Tsinghua University, if you have any question about this post, contact me via wechat: jintianiloveu. Repost is also welcomed, but please remain this copyright info, enjoy :)

Prepare

從我的github中獲取kitti-ssd源代碼,注意斯议,我將ssd訓(xùn)練和生成數(shù)據(jù)的代碼和原始的ssd代碼分離了剩膘,你只需要把原始ssdclone下來編譯即可,我們訓(xùn)練數(shù)據(jù)集只需要調(diào)用它廓潜,以后的操作都和它沒有關(guān)系了。

Part A Data Orginization

Before we get started, I have say that SSD original source code data orginization is really a mess. If you want train your own data you don't know where to go. But now, I am going change it, reshape it to a simple and clear way. you just clone source code and make it, the rest thing is all about my code, using my code you can sperate caffe-ssd source code from your dataset folder in a more clear way

Part B Get Your Images And Labels

First of all, get your images and labels, I assume that you have 7000 images and same count labels in txt format, orginize them in 2 folder, called Images which contains all images, and Labels which contains all labels. And, most important at all is that, every single image must have same name mapped label txt file, means if you have a image 0001.jpg you must labeled it in 0001.txt. And all txt files must in this format:

class_index xmin ymin xmax ymax

It's simple enough! In my way, I place all images inside ~/data/MyDataset/Images and all my labels in ~/data/MyDataset/Labels, hopefully please do not change Images and Labels folder name, we gonna use it.

Part C Create Your Work Folder

Seperate from caffe-ssd source code directory, you can create a invidual folder named MyDataset, our all work will compelet in this folder. OK, clone my kitti-ssd into your's anywhere you like. you can change this folder name as you like(example. face-ssd). Here inside we got this things:

data
models
train_ssd_kitti.py

ok, next we are going work with data first, because we have to generate lmdb file first.

Part D Create lmdb Database

OK, in this step, we are going put all data into lmdb database., this will generate a lmdb folder inside ~/data/MyDataset folder which contains KITTI_trainval and KITTI_test data.

cd data
bash create_list.sh
bash create_data.sh

Done! now you get trainval.txt test.txt and test_name_size.txt
But you have to get your labelmap_dataset.prototxt, here is suggestion:

if you have 5 classed named the 6th class in name background

item {
  name: "none_of_the_above"
  label: 6
  display_name: "background"
}

And later in train_ssd.py you gonna change two value : num_classes and background_index_id.

Part E Get VGG Pretrain Model and Start Train SSD

Download VGG pretrain model and place into models/VGGNet , the everything was done! Just a little change in train_ssd_kitti.py you can train ssd ready! Here is something you have to change:

sys.path.insert(0, "/home/chenqi-didi/Documents/work/caffe/python")
data_root_dir = "/home/chenqi-didi/data/"
caffe_root = "/home/chenqi-didi/Documents/work/caffe"
train_data = data_root_dir + "KITTI/lmdb/KITTI_trainval_lmdb"
# The database file for testing data. Created by data/KITTI/create_data.sh
test_data = data_root_dir + "KITTI/lmdb/KITTI_test_lmdb"
model_name = "VGG_KITTI_{}".format(job_name)

# Directory which stores the model .prototxt file.
save_dir = "models/VGGNet/KITTI/{}".format(job_name)
# Directory which stores the snapshot of models.
snapshot_dir = "models/VGGNet/KITTI/{}".format(job_name)
# Directory which stores the job script and log file.
job_dir = "jobs/VGGNet/KITTI/{}".format(job_name)
# Directory which stores the detection results.
output_result_dir = "{}/data/KITTI/results/{}/Main".format(os.environ['HOME'], job_name)
label_map_file = "{}/data/labelmap_kitti.prototxt".format(current_dir)

# Defining which GPUs to use.
gpus = "0,1"

Find above code change all KITTI into your dataset name, save it and you are ready to go!

python train_ssd_kitti.py

Finally, For Test Result

got your image path in data, for example data/test2.jpg and then change ssd_detection.py file path, then run:

python ssd_detection.py

Here is the result:


image
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市澜躺,隨后出現(xiàn)的幾起案子桩蓉,更是在濱河造成了極大的恐慌淋纲,老刑警劉巖,帶你破解...
    沈念sama閱讀 216,470評論 6 501
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件院究,死亡現(xiàn)場離奇詭異洽瞬,居然都是意外死亡,警方通過查閱死者的電腦和手機业汰,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,393評論 3 392
  • 文/潘曉璐 我一進店門伙窃,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人样漆,你說我怎么就攤上這事为障。” “怎么了?”我有些...
    開封第一講書人閱讀 162,577評論 0 353
  • 文/不壞的土叔 我叫張陵鳍怨,是天一觀的道長呻右。 經(jīng)常有香客問我,道長鞋喇,這世上最難降的妖魔是什么声滥? 我笑而不...
    開封第一講書人閱讀 58,176評論 1 292
  • 正文 為了忘掉前任,我火速辦了婚禮侦香,結(jié)果婚禮上落塑,老公的妹妹穿的比我還像新娘。我一直安慰自己罐韩,他們只是感情好芜赌,可當(dāng)我...
    茶點故事閱讀 67,189評論 6 388
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著伴逸,像睡著了一般缠沈。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上错蝴,一...
    開封第一講書人閱讀 51,155評論 1 299
  • 那天洲愤,我揣著相機與錄音,去河邊找鬼顷锰。 笑死柬赐,一個胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的官紫。 我是一名探鬼主播肛宋,決...
    沈念sama閱讀 40,041評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼束世!你這毒婦竟也來了酝陈?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 38,903評論 0 274
  • 序言:老撾萬榮一對情侶失蹤毁涉,失蹤者是張志新(化名)和其女友劉穎沉帮,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體贫堰,經(jīng)...
    沈念sama閱讀 45,319評論 1 310
  • 正文 獨居荒郊野嶺守林人離奇死亡穆壕,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,539評論 2 332
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了其屏。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片喇勋。...
    茶點故事閱讀 39,703評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖偎行,靈堂內(nèi)的尸體忽然破棺而出川背,到底是詐尸還是另有隱情贰拿,我是刑警寧澤,帶...
    沈念sama閱讀 35,417評論 5 343
  • 正文 年R本政府宣布渗常,位于F島的核電站,受9級特大地震影響汗盘,放射性物質(zhì)發(fā)生泄漏皱碘。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 41,013評論 3 325
  • 文/蒙蒙 一隐孽、第九天 我趴在偏房一處隱蔽的房頂上張望癌椿。 院中可真熱鬧,春花似錦菱阵、人聲如沸踢俄。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,664評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽都办。三九已至,卻和暖如春虑稼,著一層夾襖步出監(jiān)牢的瞬間琳钉,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 32,818評論 1 269
  • 我被黑心中介騙來泰國打工蛛倦, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留歌懒,地道東北人。 一個月前我還...
    沈念sama閱讀 47,711評論 2 368
  • 正文 我出身青樓溯壶,卻偏偏與公主長得像及皂,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子且改,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 44,601評論 2 353

推薦閱讀更多精彩內(nèi)容

  • PLEASE READ THE FOLLOWING APPLE DEVELOPER PROGRAM LICENSE...
    念念不忘的閱讀 13,470評論 5 6
  • **2014真題Directions:Read the following text. Choose the be...
    又是夜半驚坐起閱讀 9,475評論 0 23
  • ARP欺騙是局域網(wǎng)攻擊的老套路了验烧,通過ARP欺騙加抓包的方法基本可以監(jiān)聽一切局域網(wǎng)內(nèi)的非加密流量,這里介紹一個不需...
    Hydrogen_閱讀 4,869評論 0 6
  • 開課啦又跛!開課啦噪窘!開課啦! 微信營銷是網(wǎng)絡(luò)經(jīng)濟時代企業(yè)或個人營銷模式的一種效扫。是伴隨著微信的火熱而興起...
    他叫徐樂閱讀 963評論 0 0
  • 原來過了十八歲以后就再也沒有夏天了倔监。 只有如約而至的七月。八月和九月菌仁。 夏天是短褲蟬鳴和一陣暴雨后少年滿懷的心事浩习。...
    ButIcare閱讀 244評論 0 0