当前位置:网站首页>Learning experience sharing 3: yolov5 training data set path index
Learning experience sharing 3: yolov5 training data set path index
2022-07-28 22:49:00 【Artificial Intelligence Algorithm Research Institute】
ask topic : There are many new students YOLOv5 Friends of algorithms , I don't know how to better train with my own data set , Use the official default method , Improve the project or run other projects , You need to duplicate the entire dataset into the new project , It's OK that the data set is small , However, if the data set is too large, it will cause greater data redundancy . Update my method today , Projects and datasets can be separated , This can be more flexible .
Fang Law :
First generate train.txt,val.txt,test.txt
# -*- codeing = utf-8 -*-
# @Time : 2021/9/30 10:21
# @Auther : zqk
# @File : voc_labelhrsc.py
# @Software: PyCharm
import xml.etree.ElementTree as ET
import os
from os import getcwd
sets = ['train', 'val', 'test']
classes = ["airplane","airport","baseballfield","basketballcourt","bridge","chimney","dam","expresswayservicearea",
"expresswaytollstation","golfcourse","groundtrackfield","harbor","overpass","ship","stadium","storagetank",
"tenniscourt","trainstation","vehicle","windmill"] # Change to your own category
abs_path = os.getcwd()
print(abs_path)
def convert(size, box):
dw = 1. / (size[0])
dh = 1. / (size[1])
x = (box[0] + box[1]) / 2.0 - 1
y = (box[2] + box[3]) / 2.0 - 1
w = box[1] - box[0]
h = box[3] - box[2]
x = x * dw
w = w * dw
y = y * dh
h = h * dh
return x, y, w, h
def convert_annotation(image_id):
in_file = open('ZQK_data/Annotations/%s.xml' % (image_id), encoding='UTF-8')
out_file = open('ZQK_data/labels/%s.txt' % (image_id), 'w')
tree = ET.parse(in_file)
root = tree.getroot()
size = root.find('size')
w = int(size.find('width').text)
h = int(size.find('height').text)
for obj in root.iter('object'):
difficult = obj.find('difficult').text
cls = obj.find('name').text
if cls not in classes or int(difficult) == 1:
continue
cls_id = classes.index(cls)
xmlbox = obj.find('bndbox')
b = (float(xmlbox.find('xmin').text), float(xmlbox.find('xmax').text), float(xmlbox.find('ymin').text),
float(xmlbox.find('ymax').text))
b1, b2, b3, b4 = b
# Mark out of bounds correction
if b2 > w:
b2 = w
if b4 > h:
b4 = h
b = (b1, b2, b3, b4)
bb = convert((w, h), b)
out_file.write(str(cls_id) + " " + " ".join([str(a) for a in bb]) + '\n')
wd = getcwd()
for image_set in sets:
# if not os.path.exists(''):
# os.makedirs('data/labels/')
image_ids = open('RSOD/ImageSets/Main/%s.txt' % (image_set)).read().strip().split()
list_file = open('RSOD/ImageSets/%s.txt' % (image_set), 'w')
for image_id in image_ids:
list_file.write(abs_path + '/RSOD/JPEGImages/%s.jpg\n' % (image_id))
# convert_annotation(image_id)
list_file.close()
then , Create data data.yaml file , Index to the corresponding generated txt below .
train: D:\AI\widerperson\labels\train2021\ImageSets\train.txt # 80 Remote sensing ship
val: D:\AI\widerperson\labels\train2021\ImageSets\val.txt # 8 Remote sensing ship
test: D:\AI\widerperson\labels\train2021\ImageSets\test.txtLast , I hope I can powder each other , Be a friend , Learn and communicate together .
边栏推荐
- PaddleNLP基于ERNIR3.0文本分类以CAIL2018-SMALL数据集罪名预测任务为例【多标签】
- PC side special effects - animation function
- B站713故障后的多活容灾建设|TakinTalks大咖分享
- 775. 倒排单词
- Paper reading: deep forest / deep forest /gcforest
- 递归和迭代
- Summary of the problem that MathType formula does not correspond in word
- How to install and use PHP library neo4j
- Evaluation index of anomaly detection: rocauc et al. [tips]
- hp proliant dl380从U盘启动按哪个键
猜你喜欢

What to do after mathematical modeling gets the competition problem and some ("crooked ways") tips - must see before the competition
![Mspba [anomaly detection: representation_based]](/img/95/1f7390ec024a2865acb9e9a41100b1.png)
Mspba [anomaly detection: representation_based]

c语言实现字符串逆序排列

Qt+ffmpeg environment construction

Baidu map usage

Torch.fft.fft 2. () error reporting problem solution

How to delete and remove the first row of elements in PHP two-dimensional array

JVM——自定义类加载器
![Paddlenlp is based on ernir3.0 text classification. Take the crime prediction task of cail2018-small dataset as an example [multiple tags]](/img/87/d943cc1e8169bb670414fbf7a322c5.jpg)
Paddlenlp is based on ernir3.0 text classification. Take the crime prediction task of cail2018-small dataset as an example [multiple tags]
![Ocr-gan [anomaly detection: Reconstruction Based]](/img/16/62d962288c192b3df2fdb518d7127e.gif)
Ocr-gan [anomaly detection: Reconstruction Based]
随机推荐
Multi activity disaster recovery construction after 713 failure of station B | takintalks share
Using PCL to batch display PCD point cloud data flow
php二维数组如何删除去除第一行元素
Use the picture name to label the picture [tips]
DIP-VBTV: Color Image Restoration Model Combining Deep Image Prior and Vector Bundle Total Variation
职场pua但有道理
Paper reading vision gnn: an image is worth graph of nodes
Using nodejs to operate MySQL
Concise history of graphic technology
How to delete and remove the first row of elements in PHP two-dimensional array
Quadruped robot | gem (elevation map) + fast_ Deployment records of Leo (odometry) environment
JSON file to PNG image (batch conversion / image naming / migration / pixel value change) [tips]
[get mobile information] - get mobile information through ADB command
The blueprint of flask complements openpyxl
HP ProLiant DL380 boot from USB flash drive, press which key
轮子六:QSerialPort 串口数据 收发
PHP库neo4j怎么安装及使用
Memseg [anomaly detection: embedded based]
winform跳转第二个窗体案例
Image is referred in multiple repositories