当前位置:网站首页>手把手教学Yolov7的搭建及实践
手把手教学Yolov7的搭建及实践
2022-07-25 13:47:00 【计算机视觉研究院】
关注并星标
从此不迷路
计算机视觉研究院

公众号ID|ComputerVisionGzq
学习群|扫码在主页获取加入方式
计算机视觉研究院专栏
作者:Edison_G
yolo系列已经成了大家学习工作中常用的目标检测网络,果然,yolov7又来了。听说这个作者是yolov4的,我们就实践下。
01
概述
具体内容可以参考CSDN的he_eeeeeeeeeee,进入主页既可以或更加详细的操作流程。
源码:https://github.com/WongKinYiu/yolov7
论文:https://arxiv.org/abs/2207.02696
Yolov7:最新最快的实时检测框架,最详细分析解释(附源代码)
02
实验

搭建环境,这里直接用conda按照源码requirements.txt安装就行。
数据准备
现成数据(VisDrone)+配置脚本(yolov7.yaml等):
数据集:官方的VisDrone格式和yolov5的不同,要转换一下
制作自己数据集(lableme标注自己图片+labelme转yolo的脚本):
强烈建议用labelme
labelme格式标注完就是一张图对应一个json:

yolo格式是一个图对应一个txt:

我是把转化完的txt和json都同一个文件夹下:

标注软件:
labelme就一个exe文件50m左右,下载地址:8q3m,windows上下载后直接执行,非常方便
labelme转yolov5脚本:
(只写了检测的,labelme的分割、关键点等等脚本有机会写个总的)
import os
import json
import glob
#输入口,就是你图片和json存放的那个文件,输出的txt也在这个文件夹里
labelme_dir=r"C:\Users\ttao\Pictures\my_"
def get_labelme_data(labelme_dir):
with open(labelme_dir) as f:
j=json.load(f)
out_data=[]
img_h =j["imageHeight"]
img_w =j["imageWidth"]
for shape in j["shapes"]:
label=shape["label"]
points=shape["points"]
x,y,x2,y2=points[0][0],points[0][1],points[1][0],points[1][1]
x_c=(x+x2)//2
y_c=(y+y2)//2
w=abs(x-x2)
h=abs(y-y2)
out_data.append([label,x_c,y_c,w,h])
return img_h,img_w,out_data
def rename_Suffix(in_,mode=".txt"):
in_=in_.split('.')
return in_[0]+mode
def make_yolo_data(in_dir):
json_list=glob.glob(os.path.join(in_dir,'*.json'))
for json_ in json_list:
json_path=os.path.join(in_dir,json_)
json_txt=rename_Suffix(json_)
img_h,img_w,labelme_datas=get_labelme_data(json_path)
with open(os.path.join(in_dir,json_txt),'w+') as f:
for labelme_data in labelme_datas:
label=labelme_data[0]
x_c=labelme_data[1]/img_w
y_c=labelme_data[2]/img_h
w=labelme_data[3]/img_w
h=labelme_data[4]/img_h
f.write("{} {} {} {} {}\n".format(label,x_c,y_c,w,h))
f.close()
if __name__ == '__main__':
make_yolo_data(labelme_dir)训练
配置:train.py+数据集配置文件(.yaml)+选择网络的配置文件(默认为yolov7.yaml)
Visdrone数据集
数据集是无人机角度拍摄的,中国各城市的,主要是各种汽车、人等数据集
我具体配置情况如下:

train.py
–cfg 模型选择,这里默认是yolov7
–data 数据格式配置,我这里是自己的VisDrone数据格式,训练yolo的要改,看下面训练自己数据集
–hyp 超参数,先不管
–batch-size 这个yolov7我设高了容易爆,小点
VisDrone.yaml

然后就可以训练了


THE END
转载请联系本公众号获得授权

计算机视觉研究院学习群等你加入!
ABOUT
计算机视觉研究院
计算机视觉研究院主要涉及深度学习领域,主要致力于人脸检测、人脸识别,多目标检测、目标跟踪、图像分割等研究方向。研究院接下来会不断分享最新的论文算法新框架,我们这次改革不同点就是,我们要着重”研究“。之后我们会针对相应领域分享实践过程,让大家真正体会摆脱理论的真实场景,培养爱动手编程爱动脑思考的习惯!
VX:2311123606

边栏推荐
- Gym installation, invocation and registration
- sieve of eratosthenes
- Turn off automatic update when brew executes commands
- Error of Tencent cloud [100007] this env is not enable anonymous login
- Talk about your understanding of hashcode and equals methods?
- 0715RHCSA
- Canal realizes MySQL data synchronization
- redis集群的三种方式
- mujoco_ Py Chinese document
- Okaleido launched the fusion mining mode, which is the only way for Oka to verify the current output
猜你喜欢

Basic knowledge of binary tree

JS Array indexOf includes sort() 冒号排序 快速排序 去重和随机样本 random

LabVIEW的内部错误

0710RHCSA

刷题-洛谷-P1059 明明的随机数

How can information security engineers prepare for the soft exam in the second half of 2022?

【力扣】645.错误的集合

Leetcode1 -- sum of two numbers

运动豪华还是安全豪华?亚洲龙与沃尔沃S60该入手哪款?

Internal error of LabVIEW
随机推荐
Numpy quick start
0716RHCSA
How can information security engineers prepare for the soft exam in the second half of 2022?
并发编程之阻塞队列
Sports luxury or safety luxury? Which type of Asian Dragon and Volvo S60 should we start with?
VIM basic operation summary
音视频技术开发周刊 | 255
DNS resolution error during windows unbutu20 lts apt, WGet installation
Gym安装、调用以及注册
Uncaught SyntaxError: Octal literals are not allowed in strict mode.
Hcip day 10 notes
飞盘局有多快乐?2022年轻人新潮运动报告
0715RHCSA
hcip第十天笔记
Serious [main] org.apache.catalina.util.lifecyclebase Handlesubclassexception initialization component
Peripheral system calls SAP's webapi interface
刷题-洛谷-P1075 质因数分解
刷题-洛谷-P1085 不高兴的津津
领域驱动模型设计与微服务架构落地-模型设计
【Platform IO编译Hifive1-revB】*** [.pio\build\hifive1-revb\src\setupGPIO.o] Error 1的解决办法
