当前位置:网站首页>[target detection] yolov5 Runtong visdrone data set
[target detection] yolov5 Runtong visdrone data set
2022-07-25 16:47:00 【zstar-_】
background
stay YOLOv5 Official 6.1 In the version , I find Data There are so many in the catalogue 5 Data sets , Including UAV aerial photo data set VisDrone And remote sensing data sets xView, This reflects that the official is also secretly making efforts in small target detection .
This blog will record how to use YOLOv5 Run through VisDrone Data sets .
I have uploaded the data set to the online disk , Readers who need it can download :
https://pan.baidu.com/s/1UNQlZGHZlAZs412tbnpAxg?pwd=8888
Data set structure

The data set is divided into four files :
- VisDrone2019-DET-train: Training set
- VisDrone2019-DET-val: Verification set
- VisDrone2019-DET-test-dev: Test set ( With label )
- VisDrone2019-DET-test-challenge: Test set ( Without a label )
Unlabeled test sets are used for VisDrone2021 The challenge , If you don't participate in the competition, you don't need to use .
Dataset processing
and VOC The dataset is the same ,VisDrone The data annotation of is xml form , You need to convert it into YOLOv5 The required txt Format
In the official offering VisDrone.yaml below , Scripts for data processing have been provided , Make simple modifications based on it .
Create in the root directory visdrone2yolo.py:
from utils.general import download, os, Path
def visdrone2yolo(dir):
from PIL import Image
from tqdm import tqdm
def convert_box(size, box):
# Convert VisDrone box to YOLO xywh box
dw = 1. / size[0]
dh = 1. / size[1]
return (box[0] + box[2] / 2) * dw, (box[1] + box[3] / 2) * dh, box[2] * dw, box[3] * dh
(dir / 'labels').mkdir(parents=True, exist_ok=True) # make labels directory
pbar = tqdm((dir / 'annotations').glob('*.txt'), desc=f'Converting {
dir}')
for f in pbar:
img_size = Image.open((dir / 'images' / f.name).with_suffix('.jpg')).size
lines = []
with open(f, 'r') as file: # read annotation.txt
for row in [x.split(',') for x in file.read().strip().splitlines()]:
if row[4] == '0': # VisDrone 'ignored regions' class 0
continue
cls = int(row[5]) - 1 # Category No -1
box = convert_box(img_size, tuple(map(int, row[:4])))
lines.append(f"{
cls} {
' '.join(f'{
x:.6f}' for x in box)}\n")
with open(str(f).replace(os.sep + 'annotations' + os.sep, os.sep + 'labels' + os.sep), 'w') as fl:
fl.writelines(lines) # write label.txt
dir = Path('D:/Desktop/Work/Dataset/VisDrone') # datasets Under the folder Visdrone2019 Folder Directory
# Convert
for d in 'VisDrone2019-DET-train', 'VisDrone2019-DET-val', 'VisDrone2019-DET-test-dev':
visdrone2yolo(dir / d) # convert VisDrone annotations to YOLO labels
After running , You can see that and... Are generated under each data set images Corresponding labels

Create your own data path file
stay data Create below mydata.yaml( It can also be modified directly VisDrone.yaml)
Type in the following :
train: D:/Dataset/VisDrone/VisDrone2019-DET-train/images # train images (relative to 'path') 6471 images
val: D:/Dataset/VisDrone/VisDrone2019-DET-val/images # val images (relative to 'path') 548 images
test: D:/Dataset/VisDrone/VisDrone2019-DET-test-dev/images # test images (optional) 1610 images
# Classes
nc: 10 # number of classes
names: [ 'pedestrian', 'people', 'bicycle', 'car', 'van', 'truck', 'tricycle', 'awning-tricycle', 'bus', 'motor' ]
notes : Replace the path here with your own path .
Start training
stay train.py in , It is mainly necessary to modify several quantities shown in the red box below .
batch-size and workers The two parameters are flexibly selected according to your computer configuration .
It is worth noting that YOLOv5 5.0 The default size of the input image of version is 640, stay YOLOv5 6.1 In the version , The default size is changed to 960, This also reflects the official strategy to deal with small target detection .
After setting up , Just start training .
Video detection
After model training , function detect.py It can detect pictures or videos .
When using , Mainly modify the first three parameters , Meaning and train.py It's similar to .
in addition , For dense small targets , Data labels and confidence levels generated by default during output may block the target , Affect perception .
You can modify the following hide-labels and hide-conf Two attributes , In this way, labels and confidence levels can be hidden .
Enjoy yourself!
边栏推荐
- [cloud co creation] explore how gaussdb helps ICBC create core financial data
- 博云容器云、DevOps平台斩获可信云“技术最佳实践奖”
- 搜狗批量推送软件-搜狗批量推送工具【2022最新】
- 微信公众号开发之消息的自动回复
- ILSSI认证|六西格玛DMAIC的历程
- What is the shortcut key for win11 Desktop Switching? Win11 fast desktop switching method
- 伦敦银K线图的各种有用形态
- What is chain game system development? How to make chain game system development
- 【知识图谱】实践篇——基于医疗知识图谱的问答系统实践(Part5-完结):信息检索与结果组装
- win10设备管理认不到GTX1080Ti 显示设备的解决办法
猜你喜欢

Paper notes: highly accurate protein structure prediction with alphafold (alphafold 2 & appendix)

Fudan University emba2022 graduation season - graduation does not forget the original intention and glory to embark on the journey again

easyui datagrid控件使用

博云容器云、DevOps平台斩获可信云“技术最佳实践奖”

【目标检测】YOLOv5跑通VisDrone数据集

异常处理机制专题1

基于SqlSugar的开发框架循序渐进介绍(13)-- 基于ElementPlus的上传组件进行封装,便于项目使用

失意的互联网人拼命叩开Web3大门

Mindoc makes mind map

【知识图谱】实践篇——基于医疗知识图谱的问答系统实践(Part4):结合问题分类的问题解析与检索语句生成
随机推荐
【知识图谱】实践篇——基于医疗知识图谱的问答系统实践(Part5-完结):信息检索与结果组装
【目标检测】TPH-YOLOv5:基于transformer的改进yolov5的无人机目标检测
MySQL view
【知识图谱】实践篇——基于医疗知识图谱的问答系统实践(Part4):结合问题分类的问题解析与检索语句生成
[fault diagnosis] bearing fault diagnosis based on Bayesian optimization support vector machine with matlab code
城市燃气安全再拉警钟,如何防患于未“燃”?
7.依赖注入
从业务需求出发,开启IDC高效运维之路
简述redis集群的实现原理
【redis】redis安装
easyui入门
吴恩达逻辑回归2
ReBudget:通过运行时重新分配预算的方法,在基于市场的多核资源分配中权衡效率与公平性
C Music
Birui data joins Alibaba cloud polardb open source database community
Cookie、cookie与session区别
Understanding service governance in distributed development
[OBS] frame loss and frame priority before transmission
【知识图谱】实践篇——基于医疗知识图谱的问答系统实践(Part3):基于规则的问题分类
MySQL视图