win10下YOLOV4训练自己的数据日志


前言

基于win10系统,环境配置在上一篇博客。使用的是darknet下的YOLOv4。


一、使用vs2019生成darknet.exe

1.下载yolov4

https://github.com/AlexeyAB/darknet
保存至D:\opencv,并命名为darknet

2.复制opencv的dll文件

将D:\opencv\opencv\build\x64\vc15\bin下的opencv_ffmpeg340_64.dllopencv_world340.dll复制到
D:\opencv\darknet\build\darknet\x64

3.vs2019项目配置

修改darknet.vcxproj,打开x64下的文件,将10.0改为10.1,因为我自己用的CUDA版本是10.1.
打开vs2019,打开项目或解决方案,darknet.sln
在这里插入图片描述
1项目属性配置:
选择release和x64
在这里插入图片描述
2对darknet右键->属性 注意同样选release和x64,同时检查注意检查Windows SDK版本和平台工具
在这里插入图片描述3修改vc++中的包含目录和库目录和链接器
包含目录添加:

D:\opencv\opencv\build\include
D:\opencv\opencv\build\include\opencv 
D:\opencv\opencv\build\include\opencv2

库目录添加:

D:\opencv\opencv\build\x64\vc15\lib

链接器->输入->添加依赖项:

D:\opencv\opencv\build\x64\vc15\lib\opencv_world410.lib

在这里插入图片描述
在这里插入图片描述

4.拷贝CUDA文件

将第一个文件夹下的文件拷贝到第二个文件夹下:

D:\CUDA\VisualStudioIntegration\extras\visual_studio_integration\MSBuildExtensions
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\BuildCustomizations

懒得放自己的,反正已经放了。

5.点击生成方案或者重新生成方案

生成darknet.exe则vs编译成功。
参考地址

二、权重文件

1.下载yolov4.weights以及yolov4.conv.137

下载地址
密码:0sti
放置于darknet的x64文件夹下
完成之后可测试图片:

darknet.exe detector test cfg\coco.data cfg\yolov4.cfg yolov4.weights data\dog.jpg

三、制作自己的数据集

1.下载数据集
visdrone2019数据集
2.整理数据集
将数据集配置为voc格式
在这里插入图片描述
其中annotations中放置的是voc格式的xml文件。(生成)
imagesets下有main文件,放置train.txt,test.txt,val.txt三个txt文件,内容为图片序号。(生成)
JPEGimages放置原jpg文件(需按序号排列)
labels放置yolo格式的txt文件(生成)
3.数据集格式转换
(1)JPEGImages和Annotations按顺序重命名
rename.py

import os
class ImageRename():
    def __init__(self):
        self.path = 'D:/opencv/darknet/build/darknet/x64/VOCdevkit/VOC2017/JEPGImages' #需要将图片命名的文件夹路径
    def rename(self):
        filelist = os.listdir(self.path)
        totalnum = len(filelist)
        i = 1
        for item in filelist:
            if item.endswith('.jpg'):
                src = os.path.join(os.path.abspath(self.path),item)
                dst = os.path.join(os.path.abspath(
                    self.path),format(str(i),'0>5s') + '.jpg') #4为位数,如0001.
                os.rename(src,dst)
                i = i + 1
if __name__ == '__main__':
    newname = ImageRename()
    newname.rename()

(2)将visdrone的txt文件转为voc的xml文件
main.py

import os
from PIL import Image
root_dir = "D:/opencv/darknet/build/darknet/x64/VOCdevkit/VOC2017/"
annotations_dir = root_dir+"Annotations_voc/"
image_dir = root_dir + "JEPGImages/"
xml_dir = root_dir+"labels/"
class_name = ['ignored regions','pedestrian','people','bicycle','car','van','truck','tricycle','awning-tricycle','bus','motor','others']
#因为使用visdrone数据集,所以这里不改
for filename in os.listdir(annotations_dir):
    fin = open(annotations_dir+filename, 'r')
    image_name = filename.split('.')[0]
    img = Image.open(image_dir+image_name+".jpg")
    xml_name = xml_dir
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值