当前位置:网站首页>[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!
边栏推荐
- SAP Fiori 的附件处理(Attachment handling)
- ReBudget:通过运行时重新分配预算的方法,在基于市场的多核资源分配中权衡效率与公平性
- 百度富文本编辑器UEditor 图片宽度100%自适应,手机端
- 为什么 4EVERLAND 是 Web 3.0 的最佳云计算平台
- MySQL之联表查询、常用函数、聚合函数
- 【云驻共创】探秘GaussDB如何助力工商银行打造金融核心数据
- 一百个用户眼中,就有一百个QQ
- Use huggingface to quickly load pre training models and datasets in moment pool cloud
- After 20 years of agitation, the chip production capacity has started from zero to surpass that of the United States, which is another great achievement made in China
- China's chip self-sufficiency rate has increased significantly, resulting in high foreign chip inventories and heavy losses. American chips can be said to have thrown themselves in the foot
猜你喜欢

Understanding service governance in distributed development

自定义mvc项目登录注册和树形菜单

easyui下拉框,增加以及商品的上架,下架

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

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

【知识图谱】实践篇——基于医疗知识图谱的问答系统实践(Part5-完结):信息检索与结果组装

从业务需求出发,开启IDC高效运维之路

Test Driven Development (TDD) online practice room | classes open on September 17

Automatic reply of wechat official account development message
![[OBS] Reprint: what about the serious delay of OBS live broadcast and Caton?](/img/fd/54fcae2bc3f4313e9401c735ef74b8.png)
[OBS] Reprint: what about the serious delay of OBS live broadcast and Caton?
随机推荐
mindoc制作思维导图
免费的低代码开发平台有哪些?
城市燃气安全再拉警钟,如何防患于未“燃”?
企业直播风起:目睹聚焦产品,微赞拥抱生态
QT listview list display component notes
3D semantic segmentation - PVD
[OBS] Reprint: what about the serious delay of OBS live broadcast and Caton?
为什么 4EVERLAND 是 Web 3.0 的最佳云计算平台
【目标检测】YOLOv5跑通VOC2007数据集(修复版)
MySQL linked table query, common functions, aggregate functions
Promise date
[image denoising] image denoising based on bicube interpolation and sparse representation matlab source code
如何安装govendor并打开项目
在华为昇腾Ascend910上复现swin_transformer
[xiao5 chat] check the official account < the service provided by the official account has failed, please wait a moment>
What is the shortcut key for win11 Desktop Switching? Win11 fast desktop switching method
C # simulation lottery
Is it safe to open a securities account in Huatai VIP account
2D 语义分割——DeepLabV3plus 复现
Communication between processes (pipeline details)