Ubuntu 18.04 Yolov4 AlexeyAB source version train your data and test

3 篇文章 0 订阅
1 篇文章 0 订阅

Yolov4

source code:https://github.com/AlexeyAB/darknet
paper source:https://arxiv.org/pdf/2004.10934.pdf

As everyone need knows : README.MD file,
This file has told you each steps how to run this source code.
I have test the yolov3 version but i forget to write down the method of using .
Maybe one day i will compelete this blog: Not compelete

130image 2classes

Environment needed(Requirements):

  1. Cmake>=3.12
  2. CUDA=10.0 or above
  3. opencv>=2.4
  4. cudnn>7.0
  5. GPU with CC >= 3.0
    My Env: Ubuntu 18.04 CUDA 10.0 Cudnn7.5 opencv3.2
    If you wanna know how to set up the CUDA and Cudnn you can see my blog: CUDA10.0+Cudnn7.5 install
    Opencv how to setup by source code and setup the contrib you can see my blog :
    setup opencv by source code
    setup opencv by python pip

How to use this Yolov4:

Tips: each times you wanna to make the source code :you should do make clean first.
Tips: if you wanna to change you env you can change the a file in the root:Makefile you will see the cuda cudnn opencv and so on setting. you can set the cuda =1 or opencv=1

------------ You have Cuda +Cudnn:

  1. If you have Cuda and Cudnn in the above requirments : ( TIPS: Don’t know below this version can work out )
  2. In your root dir ,open the Makefilethis file ,use this commandsudo vim Makefile
    and you can see the cuda cudnn and others ,you should set the value =1 F.E. cuda = 1.
  3. And use the command make
  4. And can use the command make cleanto clean the make file .

-------------You have opencv(cpu):

  1. If you have Opencv=1 in the above requirments : ( TIPS: Opencv version>=2.4)
  2. In your root dir ,open the Makefilethis file ,use this commandsudo vim Makefile and edit the line with opencv set the value 1.
  3. and then use the command make

-------------You only have cpu:

warning:if you only have cpu ,better to only use not to train . cuz that if you train will use so long time and will be harm to your cpu.

  1. First set your all value = 0 in the file with name of Makefile
  2. And use the commandmake

--------------Use the demo:

Just use the command ./darknet detect cfg/yolov4.cfg yolov4.weights data/dog.jpg

How to train or set data:

  1. You should using command template./darknet detector train data/obj.data yolov3-tiny-obj.cfg yolov3-tiny.conv.15

Set your data :

  1. Use the tool Labelmg,this using method is very easy ,you can find easily .

F.e. website: https://blog.csdn.net/learning_tortosie/article/details/80947301

You can follow steps , it’s useful.

  1. And when you set your data you should using is VOCdevkit
  2. In the Yolov3 ,there are a voclabel.py file to set the image the mark matrix is using the xmin,ymin,xmax,ymax,classes behind the path of image . But in the Yolov4 there are voclabel.py in the scripts file and this python willl create a new “.txt” and this mark Matrix using another way to mark F.e. <object-class> <x_center> <y_center> <width> <height> , this Matrix can using to tell the classes.
  3. So you need to edit the voclabel,py the classes you should change to your own classses
  4. Creat the cfg file in the file (copy yolov4-custom.cfg) --name of “cfg” you can use name yolo-obj.cfg
  5. And edit the the cfg:
  • change line batch to [batch=64]
  • change line subdivisions to [subdivisions=16]
  • change line max_batches to (classes*2000 but not less than number of training images, and not less than 6000), f.e. [max_batches=6000]
  • change line steps to 80% and 90% of max_batches, f.e. [steps=4800,5400]
  • set network size width=416 height=416 or any value multiple of 32
  • change line classes=80 to your number of objects in each of 3 [yolo]-layers
  • change [filters=255] to filters=(classes + 5)x3 in the 3 [convolutional] before each [yolo] layer, keep in mind that it only has to be the last [convolutional] before each of the [yolo] layers.
    *(TIPS: you should edit the line before each of the yolo layers)
  • create classes names in the file build\darknet\x64\data\
  1. By using the step 2 and step 3 you will get the new file in the VOCdevkit/VOC2007/labels/ in this file you will see the .txt file is Matrix
  2. you can use the 2007_train.txt to set in the obj.data
  3. the train command is ./darknet detector train data/obj.data /home/fox/yolo4/darknet-master/darknet-master/build/darknet/x64/data/yolo-obj.cfg /home/fox/yolo4/darknet-master/darknet-master/data/yolov4.conv.137

TIPS: you need to download the weights in firstly!!!
yolov4-conv.137 :download

My test result:(2 classes: plate car):
在这里插入图片描述

Thanks:

code:https://github.com/AlexeyAB/darknet

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值