Video test by YOLO trained by my own data

(1)   Data preparation

With the help of LabelImg, I labeled 858 pictures with the feature hand, so I got 858 annotation files. Before I started to label, I renamed all 858 pictures, and the new names are from 0.jpg to 857.jpg. Here is the rename syntax:

1.  # -*- coding:utf8 -*-    
2.      
3.  import os    
4.      
5.  class BatchRename():    
6.      '''    
7.      批量重命名文件夹中的图片文件    
8.      
9.      '''    
10.     def __init__(self):    
11.         self.path = '/home/tec/下载/pictures_yolo/head' #change your directory here    
12.     
13.     def rename(self):    
14.         filelist = os.listdir(self.path)    
15.         total_num = len(filelist)    
16.         i = 858 #change the first Serial number    
17.         for item in filelist:    
18.             if item.endswith('.jpg'):    
19.                 src = os.path.join(os.path.abspath(self.path), item)    
20.                 dst = os.path.join(os.path.abspath(self.path), str(i) + '.jpg')    
21.                 try:    
22.                     os.rename(src, dst)    
23.                     print 'converting %s to %s ...' % (src, dst)    
24.                     i = i + 1    
25.                 except:    
26.                     continue    
27.         print 'total %d to rename & converted %d jpgs' % (total_num, i)    
28.     
29. if __name__ == '__main__':    
30.     demo = BatchRename()    
31.     demo.rename()  

(2)   A problem

    After the data were all set, you can start to train your yolo. At first, no bounding box was predicted,I changed the “learning rate” to 0.0001, problem solved. I think it's because I set the max_batches=500, and yolo didn’t learn enough features. 

(3)   Important parameters

      Ichanged the batch=64, subdivisions=8, set the max_batches=80000.

 (4)   Do not forget to make again

    Since I already installed CUDA, OPENCV(auseful blog to help me install opencv here)and equipped with GPU, I changed three parameters  in the makefile, and make again

 make clean    
 make 

  

  (5) Train

            Now, you canstart to train yolo by the syntax:

1.  ./darknet detector train cfg/voc.data cfg/yolo-voc.cfg darknet19_448.conv.23   
  

    darknet19_448.conv.23  file is the pre-trained weight, you should download it first. Due to the max_batches=80000, it’s a nature thing to cost a few days. Free to pause it anytime,   because you can continue anytime. When you are gonna start again, you can use the trained weight like I do by next syntax:

 ./darknet detector train cfg/voc.data cfg/yolo-voc.cfg backup/yolo-voc_40000.weights    

 

    Change your weight by replacing “yolo-voc_40000.weights”. If the loss are around0.3(the blue oval), and the IOU(the blue square)is bigger than 0.9,it means your model is near completion.

 

 

(6)   Video test

 

 

    Make sure your opencv is functional, and you can test your model by next syntax:

./darknet detector demo cfg/voc.data cfg/yolo-voc.cfg backup/yolo-voc_80000.weights 

   

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值