开始使用

目标检测数据集概览

训练稳健且准确的目标检测模型需要全面的数据集。本指南介绍了多种与 Ultralytics YOLO 模型兼容的数据集格式,并深入讲解其结构、用法以及不同格式之间的转换方法。

支持的数据集格式#

Ultralytics YOLO 格式#

Ultralytics YOLO 格式是一种数据集配置格式,可用于定义数据集根目录、训练/验证/测试图像目录的相对路径或包含图像路径的 *.txt 文件,以及类别名称字典。示例如下:

ultralytics/cfg/datasets/coco8.yaml
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license

# COCO8 dataset (first 8 images from COCO train2017) by Ultralytics
# Documentation: https://docs.ultralytics.com/datasets/detect/coco8
# Example usage: yolo train data=coco8.yaml
# parent
# ├── ultralytics
# └── datasets
#     └── coco8 ← downloads here (1 MB)

# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: coco8 # dataset root dir
train: images/train # train images (relative to 'path') 4 images
val: images/val # val images (relative to 'path') 4 images
test: # test images (optional)

# Classes
names:
  0: person
  1: bicycle
  2: car
  3: motorcycle
  4: airplane
  5: bus
  6: train
  7: truck
  8: boat
  9: traffic light
  10: fire hydrant
  11: stop sign
  12: parking meter
  13: bench
  14: bird
  15: cat
  16: dog
  17: horse
  18: sheep
  19: cow
  20: elephant
  21: bear
  22: zebra
  23: giraffe
  24: backpack
  25: umbrella
  26: handbag
  27: tie
  28: suitcase
  29: frisbee
  30: skis
  31: snowboard
  32: sports ball
  33: kite
  34: baseball bat
  35: baseball glove
  36: skateboard
  37: surfboard
  38: tennis racket
  39: bottle
  40: wine glass
  41: cup
  42: fork
  43: knife
  44: spoon
  45: bowl
  46: banana
  47: apple
  48: sandwich
  49: orange
  50: broccoli
  51: carrot
  52: hot dog
  53: pizza
  54: donut
  55: cake
  56: chair
  57: couch
  58: potted plant
  59: bed
  60: dining table
  61: toilet
  62: tv
  63: laptop
  64: mouse
  65: remote
  66: keyboard
  67: cell phone
  68: microwave
  69: oven
  70: toaster
  71: sink
  72: refrigerator
  73: book
  74: clock
  75: vase
  76: scissors
  77: teddy bear
  78: hair drier
  79: toothbrush

# Download script/URL (optional)
download: https://github.com/ultralytics/assets/releases/download/v0.0.0/coco8.zip

train、val 和 test 均接受目录、图像文件、目录或图像文件列表,或 UTF-8 *.txt 文件;该文件每行列出一个图像路径(以 ./ 开头的路径将相对于 *.txt 文件解析)。使用 *.txt 文件可以基于目录的子集进行训练、跳过未标注的图像,或将来自多个来源的图像合并到一个数据集划分中。

将图像路径写入 `*.txt` 文件
path: datasets/coco8 # dataset root
train: train.txt # a directory, an image, a list e.g. [images/a, images/b], or a *.txt file
val: val.txt
names:
  0: person

(可选)colors 为每个类别指定显示颜色,颜色以带引号的 "#rrggbb" 字符串表示,并按类别 ID 索引,例如 colors: ["#042aff", "#ff0000"]。训练和导出的模型会在预测结果中保留这些颜色;未指定颜色的类别则使用默认调色板。NDJSON 数据集记录也可以包含相同的 colors 字段。

此格式的标签应导出为 YOLO 格式,每张图像对应一个 *.txt 文件。如果图像中没有对象,则无需创建 *.txt 文件。*.txt 文件应按 class x_center y_center width height 格式编写,每个对象占一行。边界框坐标必须采用归一化 xywh格式(范围为 0 到 1)。如果边界框的坐标以像素为单位,则应将 x_center 和 width 除以图像宽度,将 y_center 和 height 除以图像高度。坐标以查看器显示的图像为准,即应用 EXIF 方向后的图像;Ultralytics 读取的每张图像都是如此。类别编号应从 0 开始。

YOLO labeled image with bounding boxes on persons and tie

上图对应的标签文件包含 2 个人(类别 0)和 1 条领带(类别 27):

YOLO format label file with normalized coordinates

使用 Ultralytics YOLO 格式时,请按照下方的 COCO8 数据集示例组织训练集和验证集中的图像及标签。

YOLO dataset directory structure with train and val folders

使用示例#

以下介绍如何使用 YOLO 格式的数据集训练模型:

示例
from ultralytics import YOLO

# 加载模型
model = YOLO("yolo26n.pt")  # 加载预训练模型(推荐用于训练)

# 训练模型
results = model.train(data="coco8.yaml", epochs=100, imgsz=640)

Ultralytics NDJSON 格式#

NDJSON(按行分隔的 JSON)格式提供了另一种为 Ultralytics YOLO 模型定义数据集的方式。此格式将数据集元数据和标注存储在一个文件中,每行包含一个独立的 JSON 对象。

NDJSON 数据集文件包含:

  1. 数据集记录(第一行):包含数据集元数据,包括任务类型、类别名称和一般信息
  2. 图像记录(后续各行):包含单张图像的数据,包括尺寸、标注和文件路径
NDJSON 示例
{
    "type": "dataset",
    "task": "detect",
    "name": "Example",
    "description": "COCO NDJSON example dataset",
    "url": "https://platform.ultralytics.com/user/datasets/example",
    "class_names": { "0": "person", "1": "bicycle", "2": "car" },
    "bytes": 426342,
    "version": 0,
    "created_at": "2024-01-01T00:00:00Z",
    "updated_at": "2025-01-01T00:00:00Z"
}

自定义图像元数据#

每条图像记录都可以包含一个 metadata JSON 对象,用于存储应用特定的上下文信息,例如拍摄条件、设备标识符或审核状态。支持嵌套值。导入 Ultralytics Platform 后,元数据会与对应图像一同存储,并可在图像的全屏信息面板中查看或编辑。

{
    "type": "image",
    "file": "airbus-wing.jpg",
    "url": "https://example.com/airbus-wing.jpg",
    "split": "train",
    "metadata": {
        "aircraft": { "family": "A350", "section": "wing" },
        "inspectionStatus": "reviewed"
    }
}

Platform 将顶层元数据键的长度限制为 128 个字符,将每张图像序列化后的元数据对象限制为 500,000 个字符,并将单次 NDJSON 导入中的有效元数据总量限制为 500,000 个字符。

使用示例#

要在 YOLO26 中使用 NDJSON 数据集,只需指定 .ndjson 文件的路径:

示例
from ultralytics import YOLO

# 加载模型
model = YOLO("yolo26n.pt")

# 使用 NDJSON 数据集进行训练
results = model.train(data="path/to/dataset.ndjson", epochs=100, imgsz=640)

NDJSON 格式的优势#

  • 单文件:所有数据集信息都包含在一个文件中
  • 流式处理:无需将所有数据加载到内存,即可逐行处理大型数据集
  • 云集成:支持远程图像 URL,可用于云端训练
  • 可扩展:便于添加自定义元数据字段
  • 版本控制:单文件格式与 git 和版本控制系统配合良好

支持的数据集#

以下列出了受支持的数据集及其简要说明。其中大多数数据集也托管在 Ultralytics Platform 上,你可以浏览图像和标注、查看数据集统计信息,并克隆数据集用于云端训练。

  • African-wildlife:包含非洲野生动物图像的数据集,涵盖水牛、大象、犀牛和斑马。
  • Argoverse:Argoverse-HD 2D 检测数据集,包含 54,446 张城市自动驾驶图像,涵盖 8 类道路目标。
  • 脑肿瘤:用于检测脑部 MRI 图像中脑肿瘤的数据集,肿瘤以单一类别的边界框标注。
  • COCO:COCO(常见场景中的物体)是一个大规模目标检测、分割和图像描述数据集,包含 80 个目标类别。
  • COCO8:从 COCO train2017 的前 8 张图像中选取的较小子集,其中 4 张用于训练,4 张用于验证,适合快速测试。
  • COCO8-Grayscale:将 RGB 转换为灰度图像后生成的 COCO8 灰度版本,适用于单通道模型评估。
  • COCO8-Multispectral:通过插值 RGB 波长生成的 COCO8 10 通道多光谱版本,适用于具备光谱感知能力的模型评估。
  • COCO12-Formats:一个包含 12 张图像的测试数据集,涵盖 12 种受支持的图像格式(AVIF、BMP、DNG、HEIC、JP2、JPEG、JPG、MPO、PNG、TIF、TIFF、WebP),用于验证图像加载流程。
  • COCO16:从 COCO train2017 的前 16 张图像中选取的子集(8 张训练图像 + 8 张验证图像),适用于快速测试。
  • COCO32:从 COCO train2017 的前 32 张图像中选取的子集(16 张训练图像 + 16 张验证图像),适用于快速测试。
  • COCO64:从 COCO train2017 的前 64 张图像中选取的子集(32 张训练图像 + 32 张验证图像),适用于快速测试。
  • COCO128:从 COCO train2017 的前 128 张图像中选取的较小子集,适用于测试。
  • Construction-PPE:一个展示建筑工地工人及其标注安全装备的数据集,包括安全帽、背心、手套、靴子和护目镜;还包含 no_helmet、no_goggle 等缺失装备标注,可用于真实环境中的合规监测。
  • Global Wheat 2020:一个包含 2020 年全球小麦挑战赛所用麦穗图像的数据集。
  • HomeObjects-3K:一个包含室内家居用品的数据集,如床、椅子、电视等,非常适合智能家居自动化、机器人、增强现实和房间布局分析等应用。
  • KITTI:一个包含真实驾驶场景以及立体视觉、LiDAR 和 GPS/IMU 数据的数据集,在此用于2D 目标检测任务,例如识别城市、乡村和高速公路环境中的汽车、行人和骑行者。
  • LVIS:一个大规模目标检测和实例分割数据集,包含 1,203 个目标类别。
  • Medical-pills:包含药片图像的数据集,标注内容适用于药品质量保证、药片分拣和法规合规等应用。
  • Objects365:一个高质量、大规模的目标检测数据集,包含 365 个目标类别和超过 170 万张训练图像。
  • OpenImagesV7:Google 提供的综合性数据集,包含 170 万张训练图像和 4.2 万张验证图像。
  • Roboflow 100:一个多样化的目标检测基准,包含涵盖七个图像领域的 100 个数据集,可用于全面评估模型。
  • Signature:一个包含各种文档图像及签名标注的数据集,可支持文档验证和欺诈检测研究。
  • SKU-110K:一个零售环境中的密集目标检测数据集,包含超过 1.1 万张图像和 170 万个边界框。
  • TT100K:清华-腾讯 100K(TT100K)交通标志数据集,包含 16,817 张街景图像,涵盖 221 个标志类别,可用于检测和分类。
  • Ultralytics 基准测试:一套由 Ultralytics 推出的基准测试套件,包含 37 个经过筛选的检测数据集,覆盖医疗、航空影像、工业、零售等领域,并采用固定协议来衡量模型在真实世界中的泛化能力。
  • VisDrone:一个包含无人机拍摄图像中目标检测和多目标跟踪数据的数据集,拥有超过 1 万张图像和视频序列。
  • VOC:Pascal 视觉对象类别 (VOC) 数据集,用于目标检测和分割,包含 20 个目标类别和超过 11K 张图像。
  • xView:一个用于俯视图像目标检测的数据集,包含 60 个目标类别和超过 100 万个已标注目标。

添加你自己的数据集#

如果你有自己的数据集,并希望使用它以 Ultralytics YOLO 格式训练检测模型,请确保它符合上文“Ultralytics YOLO 格式”中指定的格式。将标注转换为所需格式,并在 YAML 配置文件中指定路径、类别数量和类别名称。

转换或迁移标签格式#

将 COCO 数据集格式转换为 YOLO 格式#

你可以使用以下代码片段,将常用的 COCO 数据集格式的标签转换为 YOLO 格式:

示例
from ultralytics.data.converter import convert_coco

convert_coco(labels_dir="path/to/coco/annotations/")

此转换工具可用于将 COCO 数据集或任何采用 COCO 格式的数据集转换为 Ultralytics YOLO 格式。该过程会将基于 JSON 的 COCO 标注转换为更简洁的文本格式 YOLO 标注,使其兼容 Ultralytics YOLO 模型。如需了解完整工作流程,包括类别 ID 映射、目录布局以及分割或姿态标注,请参阅将 COCO 标注转换为 YOLO。

请务必仔细检查你想使用的数据集是否与你的模型兼容,并遵循必要的格式约定。格式正确的数据集对于成功训练目标检测模型至关重要。

接下来做什么#

整理好数据集后,开始训练模型。不确定从哪个预训练模型开始?在 YOLO26 模型系列中比较各个选项。

常见问题#

  • Ultralytics YOLO 格式是一种结构化配置,用于在训练项目中定义数据集。你需要设置训练、验证和测试图像及其对应标签的路径。例如:

    # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
    
    # COCO8 dataset (first 8 images from COCO train2017) by Ultralytics
    # Documentation: https://docs.ultralytics.com/datasets/detect/coco8
    # Example usage: yolo train data=coco8.yaml
    # parent
    # ├── ultralytics
    # └── datasets
    #     └── coco8 ← downloads here (1 MB)
    
    # Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
    path: coco8 # dataset root dir
    train: images/train # train images (relative to 'path') 4 images
    val: images/val # val images (relative to 'path') 4 images
    test: # test images (optional)
    
    # Classes
    names:
      0: person
      1: bicycle
      2: car
      3: motorcycle
      4: airplane
      5: bus
      6: train
      7: truck
      8: boat
      9: traffic light
      10: fire hydrant
      11: stop sign
      12: parking meter
      13: bench
      14: bird
      15: cat
      16: dog
      17: horse
      18: sheep
      19: cow
      20: elephant
      21: bear
      22: zebra
      23: giraffe
      24: backpack
      25: umbrella
      26: handbag
      27: tie
      28: suitcase
      29: frisbee
      30: skis
      31: snowboard
      32: sports ball
      33: kite
      34: baseball bat
      35: baseball glove
      36: skateboard
      37: surfboard
      38: tennis racket
      39: bottle
      40: wine glass
      41: cup
      42: fork
      43: knife
      44: spoon
      45: bowl
      46: banana
      47: apple
      48: sandwich
      49: orange
      50: broccoli
      51: carrot
      52: hot dog
      53: pizza
      54: donut
      55: cake
      56: chair
      57: couch
      58: potted plant
      59: bed
      60: dining table
      61: toilet
      62: tv
      63: laptop
      64: mouse
      65: remote
      66: keyboard
      67: cell phone
      68: microwave
      69: oven
      70: toaster
      71: sink
      72: refrigerator
      73: book
      74: clock
      75: vase
      76: scissors
      77: teddy bear
      78: hair drier
      79: toothbrush
    
    # Download script/URL (optional)
    download: https://github.com/ultralytics/assets/releases/download/v0.0.0/coco8.zip

    标签以 *.txt 文件保存,每张图像对应一个文件,格式为 class x_center y_center width height,使用归一化坐标。详细指南请参阅 COCO8 数据集示例。

  • 你可以使用 Ultralytics 转换工具将 COCO 数据集转换为 YOLO 格式。以下是一个快速方法:

    from ultralytics.data.converter import convert_coco
    
    convert_coco(labels_dir="path/to/coco/annotations/")

    此代码会将你的 COCO 标注转换为 YOLO 格式,让你可以使用这些标注训练 Ultralytics YOLO 模型。

  • Ultralytics YOLO 支持多种数据集,包括:

    每个数据集页面都提供详细信息,介绍其结构和用法,助你高效训练 YOLO26。你可以在支持的数据集部分查看完整列表。

  • 要开始训练 YOLO26 模型,请确保数据集格式正确,并在 YAML 文件中定义路径。使用以下脚本开始训练:

    示例
    from ultralytics import YOLO
    
    model = YOLO("yolo26n.pt")  # 加载预训练模型
    results = model.train(data="path/to/your_dataset.yaml", epochs=100, imgsz=640)
  • Ultralytics 提供了大量示例和实用指南,介绍如何在各种应用中使用 YOLO。访问 Ultralytics 博客,查看涵盖对象检测、分割等主题的案例研究、详细教程和社区故事。如需具体示例,请查看文档中的预测模式页面。

评论54

提出问题、分享结果,或帮助其他人。

    1. Paula DerrengerUltralytics

      @zcoolster11, could you clarify what you mean by “Python Head Bop” and what you’d like to do with Ultralytics YOLO? Feel free to drop your dataset or Python questions here in the discussion so the Ultralytics team can help.

  1. Murat Raimbekov

    hey @orz-serein, short answer: no, you don't need empty label files for background images - just leave the .txt out.

    i verified this empirically on the current main branch. setup: 5 images, 2 with real labels, 1 with an empty .txt file, 2 without any .txt file at all. building a YOLODataset over them gives:

    Scanning /tmp/bgtest_full/labels... 3 images, 3 backgrounds, 0 corrupt: 100% 5/5

    all 5 images are kept. the 3 without labels (the empty-.txt one and the two with no .txt at all) all end up with the same (0, 5) labels array - they are treated identically as background images.

    so both options work:

    • no .txt file: counted as "missing" (nm=1), no labels -> background
    • empty .txt file: counted as "empty" (ne=1), no labels -> background

    both end up in the same backgrounds = nm + ne bucket in ultralytics/data/dataset.py.

    this is also stated in the detection dataset docs:

    If there are no objects in an image, no *.txt file is required.

    how many background images: the yolov5 training tips recommend 0-10% of the dataset as background images to reduce false positives (coco has about 1% background).

    hope this helps!

  2. serein

    Hello, I would like to ask a question. During the stage of preparing the training dataset, if some images do not have the target to be detected, do I need to add corresponding empty label files in the label folder?

  3. Fatima-khanjarGitHub

    Hello, I hope this message finds you well.

    I have a question regarding fine-tuning a pre-trained YOLO model (e.g., trained on the COCO dataset) on my custom dataset. My dataset includes both new classes (not present in COCO) and the same existing classes (e.g., toothbrush, car), but with different layouts. Specifically, I would like to add my new classes starting from index 80, while still leveraging the pre-trained weights for the common classes, which are the same but with different layouts.

    Is it possible to use the pre-trained weights for the common classes and only train the model on the new classes, while ensuring that the pre-trained knowledge for the common classes is preserved? If so, could you please guide me on how to proceed?

    Thank you for your time and assistance. best regards,

  4. bimal-gajeraGitHub

    Hello, I'm working on multiple dataset formats for object detection. For the YOLO dataset format, is there any way I can rename the labels directory and put it in yaml file? Something like this:

    path: path_to_root_directory
    train: train\images
    val: val\images
    test: test\images
    
    labels_dir: yolo
    
    nc: 1
    names: ['object']

    yolo directory has yolo annotations (*.txt files), and it's inside respective train, val and test directory.

    1. Glenn JocherUltralytics(已编辑)

      @bimal-gajera currently, the labels_dir key is not supported in the YAML file. Ultralytics finds label files by replacing the last /images/ directory in each image path with /labels/, so each split needs sibling images/ and labels/ directories (for example train/images and train/labels). For more details, refer to the Object Detection Datasets Overview.

      1
  5. nitya-pandey-astroGitHub

    Hello Team, I am using YOLO for detecting trails of slow-moving astronomical objects in my images. While the model detects the trails, the bounding boxes predicted around the objects are not tight enough. The boxes tend to be too loose or not well-shaped to fit the elongated, irregular trails, resulting in inaccurate object localization. I suspect, YOLO's standard rectangular bounding box not being well-suited for the elongated, curving shapes of the trails. Could you provide guidance on how to improve bounding box accuracy for this specific use case?

    1. Glenn JocherUltralytics(已编辑)

      @astronitya thank you for your question! For detecting elongated or irregular trails, consider using Oriented Bounding Boxes (OBB), which may better fit your objects' shapes compared to standard rectangular boxes. You can format your dataset in the YOLO OBB format and train a YOLO26 OBB model. Please refer to the Oriented Bounding Box (OBB) Datasets Overview for details on dataset formatting and training. Let me know if you need further clarification!

  6. Yuxuan1998GitHub

    Hi team, I am a little bit confused with the dataset folder structure. For most dataset I used, it strunctured in the way that each of train/ and val/ folders contains images/ and labels/ folders. However, the COCO8 dataset example shows the opposite way, each of images/ and labels/ folder contains test/ and val/ folders. Does the folder structure matter here? Thanks in advance

    1. Glenn JocherUltralytics(已编辑)

      @Yuxuan1998 both layouts work, as long as each image has a sibling labels directory: Ultralytics finds the label for an image by replacing the last /images/ in its path with /labels/ (so train/images/img.jpg uses train/labels/img.txt, and images/train/img.jpg uses labels/train/img.txt). Set the paths in your dataset's YAML file to the image directories. For details, refer to the Object Detection Datasets Overview. Let us know if you need further clarification!

      1
  7. wgdcxyGitHub

    Hello, my label and image files are stored according to the requirements, but they are still not recognized, and the following is an error message Thank you in advance

    WARNING ⚠️ imgsz=[2448] must be multiple of max stride 32, updating to [2464] train: Scanning D:\Textile_testing\ultralytics-seg\cs\labels\ttb... 0 images, 30 backgrounds, 0 corrupt: 100%|██████████| 30/30 [00:00<00:00, 1138.41it/s] train: WARNING ⚠️ No labels found in D:\Textile_testing\ultralytics-seg\cs\labels\ttb.cache. See https://docs.ultralytics.com/datasets/detect for dataset formatting guidance. train: WARNING ⚠️ Cache directory D:\Textile_testing\ultralytics-seg\cs\labels is not writeable, cache not saved. WARNING ⚠️ No labels found in D:\Textile_testing\ultralytics-seg\cs\labels\ttb.cache, training may not work correctly. See https://docs.ultralytics.com/datasets/detect for dataset formatting guidance. val: Scanning D:\Textile_testing\ultralytics-seg\cs\labels\ttj... 0 images, 30 backgrounds, 0 corrupt: 100%|██████████| 30/30 [00:00<00:00, 1617.94it/s] val: WARNING ⚠️ No labels found in D:\Textile_testing\ultralytics-seg\cs\labels\ttj.cache. See https://docs.ultralytics.com/datasets/detect for dataset formatting guidance. val: WARNING ⚠️ Cache directory D:\Textile_testing\ultralytics-seg\cs\labels is not writeable, cache not saved. WARNING ⚠️ No labels found in D:\Textile_testing\ultralytics-seg\cs\labels\ttj.cache, training may not work correctly. See https://docs.ultralytics.com/datasets/detect for dataset formatting guidance. Plotting labels to runs\segment\train3\labels.jpg...

    1. wgdcxyGitHub

      Hi, but my file path is very accurate, and I checked it N times, so is there any otherreason? Thank you

    2. Glenn JocherUltralytics

      @wgdcxy please ensure your label files are in the correct YOLO format, with one .txt file per image containing normalized coordinates. Also, verify that the directory permissions allow writing. For more details, refer to the dataset formatting guide linked earlier.

    3. wgdcxyGitHub

      Hello, I'm a student whose English is not particularly good, so some places may not be clear, and secondly, this is not an error but a warning.I don't know why it's the background that reads, not the images. The warnings are as follows: val: Scanning D:\Textile_testing\ultralytics-seg\cs\labels\ttj... 0 images, 30 backgrounds, 0 corrupt: 100%| 30/30 [00:00<00:00, 495.76it/s] val: WARNING ⚠️ No labels found in D:\Textile_testing\ultralytics-seg\cs\labels\ttj.cache. See https://docs.ultralytics.com/datasets/detect for dataset formatting guidance. val: WARNING ⚠️ Cache directory D:\Textile_testing\ultralytics-seg\cs\labels is not writeable, cache not saved. WARNING ⚠️ No labels found in D:\Textile_testing\ultralytics-seg\cs\labels\ttj.cache, training may not work correctly. See https://docs.ultralytics.com/datasets/detect for dataset formatting guidance. Plotting labels to runs\segment\train4\labels.jpg...

      Then this warning tells me that the cache file is missing, and I don't know why I can't generate a cache file for the file I created, so I'm here to ask you guys. Below is my own yaml file: # Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..] path: ../cs # dataset root dir train: images/ttb # train images (relative to 'path') 128 images val: images/ttj # val images (relative to 'path') 128 images test: # test images (optional) # Classes names : 0 : wf

      Below is my label file: 0 0.6799428104575164 0.5005859375 0.6844771241830065 0.500537109375 0.6845996732026144 0.497265625 0.6802696078431373 0.497119140625 0 0.6803104575163399 0.4935546875 0.6848039215686275 0.493505859375 0.6847630718954248 0.497119140625 0.6802696078431373 0.49697265625 0 0.6802696078431373 0.49013671875 0.6849673202614379 0.490185546875 0.6849264705882353 0.49345703125 0.6803513071895425 0.493359375 0 0.6805555555555556 0.48662109375 0.6850898692810458 0.486767578125 0.6850490196078431 0.490234375 0.6803513071895425 0.490234375 0 0.6808415032679739 0.483447265625 0.6852941176470588 0.48349609375 0.6852124183006536 0.486767578125 0.6806781045751634 0.486669921875 0 0.6806372549019607 0.47998046875 0.6854166666666666 0.47998046875 0.6853349673202613 0.48349609375 0.6808415032679738 0.48359375

      Finally, this yolo can be run, but I don't know why the result is 0. Here's how it works: Transferred 381/417 items from pretrained weights 195/200 8.73G 0 0 nan 0 0 2464: 100%|██████████| 8/8 [01:37<00:00, 12.13s/it] Class Images Instances Box(P R mAP50 mAP50-95) Mask(P R mAP50 mAP50-95): 100%|[00:31<00:00, 7.91s/it] all 30 0 0 0 0 0 0 0 0 0 Finally, thank you for explaining it to me

    4. wgdcxyGitHub

      By the way, the size of my picture is 2448x2048, so the imgsz entered is 2448, and your code changed the size of my picture to 2464, is it related to this. imgsz=[2448] must be multiple of max stride 32, updating to [2464]

    5. wgdcxyGitHub

      I apologize, I found a small mistake of mine. I wrote the file name as "labels" instead of "lables" which I intended to write.Please forgive my carelessness.After all, who doesn't make mistakes. I'll come back to you next time I have a problem. Thank you for your help.

    6. wgdcxyGitHub

      Transferred 417/417 items from pretrained weights Freezing layer 'model.22.dfl.conv.weight' AMP: running Automatic Mixed Precision (AMP) checks with YOLOv8n... AMP: checks passed ✅ WARNING ⚠️ imgsz=[2448] must be multiple of max stride 32, updating to [2464] train: Scanning D:\Textile_testing\ultralytics-seg\cs\labels\ttb.cache... 30 images, 0 backgrounds, 0 corrupt: 100%|██████████| 30/30 [00:00<?, ?it/s] Hello, here I am again, with a new problem, how to solve this problem about image size?Ask for answers, thank you

    7. Glenn JocherUltralytics

      @wgdcxy to address the image size issue, ensure your imgsz is a multiple of 32, as required by the model's architecture. This adjustment helps maintain compatibility with the model's stride. If you have further questions, feel free to ask!

    8. wgdcxyGitHub

      WARNING ⚠️ NMS time limit 0.900s exceeded. Hello, my teacher who has never met, what should I do with this warning?

    9. Glenn JocherUltralytics(已编辑)

      @wgdcxy the "NMS time limit exceeded" warning is not controlled by an nms argument. It appears when too many candidate boxes need to be processed within the time limit, which is common early in training when validation uses a low confidence threshold. It usually stops as the model trains, and you can reduce it by raising conf or lowering max_det during validation. If you have further questions, feel free to ask!

    10. wgdcxyGitHub

      Hello, I'm here again. The issue this time is still the same warning. I adjusted the max_time_img to 0.1 in ops. py, but I don't feel it's right. So I came to ask for your help because it still shows this warning. I hope you can tell me where to make the adjustment. Thank you again. WARNING ⚠️ NMS time limit 0.900s exceeded

    11. wgdcxyGitHub

      How can these values be improved? We can only continue training or increase the training dataset. Epoch GPU_mem box_loss seg_loss cls_loss dfl_loss Instances Size 11/500 11G nan 6.21 nan nan 132 2464: 100%|██████████| 8/8 [01:56<00:00, 14.59s/it] Class Images Instances Box(P R mAP50 mAP50-95) Mask(P R mAP50 mAP50-95): 100%|██████████| 4/4 [00:54<00:00, 13.56s/it] all 30 664 0 0 0 0 0 0 0 0

    12. Glenn JocherUltralytics

      To improve your model's performance, consider increasing the dataset size, enhancing data quality, or adjusting hyperparameters. If issues persist, reviewing the dataset for label accuracy and distribution might help.

  8. wgdcxyGitHub

    WARNING ⚠️ imgsz=[2448] must be multiple of max stride 32, updating to [2464] train: Scanning D:\Textile_testing\ultralytics-seg\cs\labels\ttb... 0 images, 30 backgrounds, 0 corrupt: 100%|██████████| 30/30 [00:00<00:00, 1138.41it/s] train: WARNING ⚠️ No labels found in D:\Textile_testing\ultralytics-seg\cs\labels\ttb.cache. See https://docs.ultralytics.com/datasets/detect for dataset formatting guidance. train: WARNING ⚠️ Cache directory D:\Textile_testing\ultralytics-seg\cs\labels is not writeable, cache not saved. WARNING ⚠️ No labels found in D:\Textile_testing\ultralytics-seg\cs\labels\ttb.cache, training may not work correctly. See https://docs.ultralytics.com/datasets/detect for dataset formatting guidance. val: Scanning D:\Textile_testing\ultralytics-seg\cs\labels\ttj... 0 images, 30 backgrounds, 0 corrupt: 100%|██████████| 30/30 [00:00<00:00, 1617.94it/s] val: WARNING ⚠️ No labels found in D:\Textile_testing\ultralytics-seg\cs\labels\ttj.cache. See https://docs.ultralytics.com/datasets/detect for dataset formatting guidance. val: WARNING ⚠️ Cache directory D:\Textile_testing\ultralytics-seg\cs\labels is not writeable, cache not saved. WARNING ⚠️ No labels found in D:\Textile_testing\ultralytics-seg\cs\labels\ttj.cache, training may not work correctly. See https://docs.ultralytics.com/datasets/detect for dataset formatting guidance. Plotting labels to runs\segment\train3\labels.jpg...

    这个问题该如何解决?