Skip to content

💥Make your yolov5 dataset by using labelimg.I hope my work can help you make your yolov5 datasets more quickly.

Notifications You must be signed in to change notification settings

WangRongsheng/make-your-yolov5_dataset

Repository files navigation

Forkers repo roster for @WangRongsheng/make-your-yolov5_dataset Stargazers repo roster for @WangRongsheng/make-your-yolov5_dataset

💥💥💥重大更新💥💥💥:最新版本的全面标注工具集KDAT发布!!!👉前往

数据集标注软件

更多的标注工具你可以去看:深度学习图像标注工具汇总十个最常用深度学习图像/视频数据标注工具百度一下

在这里我选择使用labelImg

数据集大小重置工具:Image_tool.exe 百度网盘下载(提取码:2tmv)

数据集标注

  1. 下载labelImg
  2. 解压,直接打开labelimg.exe
  3. labelImg标注数据

标注完成后即可获得VOC格式(生成.xml文件)的数据

dataset
│
├─Annotations
│      train_29635.xml
│      train_29641.xml
│      train_30090.xml
│	   ...
│
└─JPEGImages
        train_29635.jpg
        train_29641.jpg
        train_30090.jpg
        ...

yolov5数据集制作

0、数据图片重命名

对于rename.bat

命名从01开始,设置
set count=100

命名从0001开始,设置
set count=10000

如果我们想要从038开始排序,可以将第三行代码:
set count=10037

1.voc格式数据集转化yolov5格式数据集

运行voc_to_yoloV5.py【该脚本实现将voc格式的数据转化为yoloV5需要的.txt标注文件,运行该脚本,会在dataset/voc/目录下生成 worktxt/目录(yolo需要的格式)】

运行代码之前,修改里面相关文件路径。

dataset
│
├─Annotations
│      train_29635.xml
│      train_29641.xml
│      train_30090.xml
│	   ...
│
├─JPEGImages
│       train_29635.jpg
│       train_29641.jpg
│       train_30090.jpg
│       ...
│
└─worktxt
       train_29635.txt
       train_29641.txt
       train_30090.txt
 	   ...

2.数据集划分训练、测试、验证

运行voc_split_trainValTest.py【该脚本用于生成voc/目录下的ImageSets/..目录,分割了训练和验证集】

dataset
│
├─Annotations
│      train_29635.xml
│      train_29641.xml
│      train_30090.xml
│	   ...
│
├─ImageSets
│	└─Main
│      train.txt
│      test.txt
│      valid.txt
│      img_train.txt
│      img_test.txt
│      img_valid.txt
│
├─JPEGImages
│       train_29635.jpg
│       train_29641.jpg
│       train_30090.jpg
│       ...
│
└─worktxt
       train_29635.txt
       train_29641.txt
       train_30090.txt
 	   ...

3.重构数据集

运行dataset_cg.py【该脚本将会生成yolov5可以训练的数据布局】

主要进行一个copy或者move的操作:

# 小数据建议:copy 大数据建议:move
for i in range(len(img_txt_cg_train)):
    shutil.copy(fimg+str(img_txt_cg_train[i]),new_dataset_train)
    shutil.copy(flable+str(label_txt_cg_train[i]),new_dataset_trainl)
for j in range(len(img_txt_cg_test)):
    shutil.copy(fimg+str(img_txt_cg_test[j]),new_dataset_test)
    shutil.copy(flable+str(label_txt_cg_test[j]),new_dataset_testl)
for q in range(len(img_txt_cg_valid)):
    shutil.copy(fimg+str(img_txt_cg_valid[q]),new_dataset_valid)
    shutil.copy(flable+str(label_txt_cg_valid[q]),new_dataset_validl)
dataset
│
├─Annotations
│      train_29635.xml
│      train_29641.xml
│      train_30090.xml
│	   ...
│
├─ImageSets
│	└─Main
│      train.txt
│      test.txt
│      valid.txt
│      img_train.txt
│      img_test.txt
│      img_valid.txt
│
├─data
│   ├─train
│   ├─test
│   └─valid
│
├─JPEGImages
│       train_29635.jpg
│       train_29641.jpg
│       train_30090.jpg
│       ...
│
└─worktxt
       train_29635.txt
       train_29641.txt
       train_30090.txt
 	   ...

4.开始利用yolov5训练你的数据

git clone https://github.com/ultralytics/yolov5.git

5.txt格式数据回改成voc格式

修改yolo2voc.py文件中第6,7,8,10行相应内容即可得到VOC数据

参考

Star History

Star History Chart

About

💥Make your yolov5 dataset by using labelimg.I hope my work can help you make your yolov5 datasets more quickly.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published