我正在为自定义数据集训练yolov5模型。我只有一节课。我已将.yaml文件更改为数据,如下所示。
train: /content/yolov5/DataSet/ForYolov5/images/train # train images (relative to 'path') 128 images
val: /content/yolov5/DataSet/ForYolov5/images/test # val images (relative to 'path') 128 images
test: # test images (optional)
# Classes
names:
0: vehicle但这辆车的名字并没有显示在探测器上。只显示“0”。我也尝试了以下格式。但它会抛出错误。
#Classes
nc:1
names:['vehicle']任何帮助都将不胜感激。
发布于 2022-10-15 20:28:04
在创建自定义数据集(我认为您有2个文件夹序列和有效)之后,您也应该使用以下代码自定义YAML文件:
%cat data.yaml
# define number of classes based on YAML
# data.yaml contains the information about number of classes and their labels required for this project
import yaml
with open("data.yaml", 'r') as stream:
num_classes = str(yaml.safe_load(stream)['nc'])
#customize iPython writefile so we can write variables
from IPython.core.magic import register_line_cell_magic
@register_line_cell_magic
def writetemplate(line, cell):
with open(line, 'w') as f:
f.write(cell.format(**globals()))
%%writetemplate /content/dataset/data.yaml
train: /content/dataset/train/images/
val: /content/dataset/valid/images/
nc: 1 #define number of class = 1
names: ['vehicule'] #class label然后,您必须检查架构文件中的类是否已更改:
%cat /content/yolov5/models/yolov5n.yaml
%%writetemplate /content/yolov5/models/yolov5n.yaml
# Parameters
nc: 1 # number of classeshttps://stackoverflow.com/questions/74039714
复制相似问题