YOLOv8训练自己的数据集

1. 配置自己的.yaml文件

        当加载这个.yaml文件时,能根据里面的路径找到相应的数据。

# 数据集的根目录
path: D:\edge\YOLO\YOLOv8_Official_Version\ultralytics\cfg\datasets

# 训练数据的目录(.jpg目录)
train: D:\edge\YOLO\YOLOv8_Official_Version\ultralytics\cfg\datasets\images\train

# 验证数据的目录(.jpg目录)
val: D:\edge\YOLO\YOLOv8_Official_Version\ultralytics\cfg\datasets\images\val

# 测试数据的目录(.jpg目录)
test: D:\edge\YOLO\YOLOv8_Official_Version\ultralytics\cfg\datasets\images\test
 
# 类别的数量
nc: 6
 
# class names
names:
  0: ore carrier
  1: passenger ship
  2: container ship
  3: bulk cargo carrier
  4: general cargo ship  
  5: fishing boat

2. 标签数据格式转换  xml格式转换成txt格式

# .xml文件转换成.txt文件

import copy
from lxml.etree import Element, SubElement, tostring, ElementTree
import xml.etree.ElementTree as ET
import pickle
import os
from os import listdir, getcwd
from os.path import join

# 检测目标的类别
classes = ["ore carrier", "passenger ship",
           "container ship", "bulk cargo carrier",
           "general cargo ship", "fishing boat"]

CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))

def convert(size, box):
    dw = 1. / size[0]
    dh = 1. / size[1]
    x = (box[0] + box[1]) / 2.0    # (x_min + x_max) / 2.0
    y = (box[2] + box[3]) / 2.0    # (y_min + y_max) / 2.0
    w = box[1] - box[0]   # x_max - x_min
    h 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值