跳至内容

挥发性有机化合物数据集

PASCAL VOC(视觉对象类别)数据集是一个著名的对象检测、分割和分类数据集。该数据集旨在鼓励对各种物体类别进行研究,通常用于计算机视觉模型的基准测试。对于从事物体检测、分割和分类任务的研究人员和开发人员来说,这是一个必不可少的数据集。

主要功能

  • VOC 数据集包括两个主要挑战:VOC2007 和 VOC2012。
  • 数据集包含 20 个物体类别,包括汽车、自行车和动物等常见物体,以及船只、沙发和餐桌等更具体的类别。
  • 注释包括用于对象检测和分类任务的对象边界框和类标签,以及用于分割任务的分割掩码。
  • VOC provides standardized evaluation metrics like mean Average Precision (mAP) for object detection and classification, making it suitable for comparing model performance.

数据集结构

挥发性有机化合物数据集分为三个子集:

  1. 训练:该子集包含用于训练物体检测、分割和分类模型的图像。
  2. 验证:该子集包含在模型训练过程中用于验证的图像。
  3. 测试:该子集包括用于测试和基准测试训练过的模型的图像。该子集的地面实况注释不公开,其结果将提交给PASCAL VOC 评估服务器进行性能评估。

应用

The VOC dataset is widely used for training and evaluating deep learning models in object detection (such as YOLO, Faster R-CNN, and SSD), instance segmentation (such as Mask R-CNN), and image classification. The dataset's diverse set of object categories, large number of annotated images, and standardized evaluation metrics make it an essential resource for computer vision researchers and practitioners.

数据集 YAML

YAML(另一种标记语言)文件用于定义数据集配置。它包含数据集的路径、类和其他相关信息。就 VOC 数据集而言,YAML 文件中的 VOC.yaml 文件保存在 https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/datasets/VOC.yaml.

ultralytics/cfg/datasets/VOC.yaml

# Ultralytics YOLO 🚀, AGPL-3.0 license
# PASCAL VOC dataset http://host.robots.ox.ac.uk/pascal/VOC by University of Oxford
# Documentation: # Documentation: https://docs.ultralytics.com/datasets/detect/voc/
# Example usage: yolo train data=VOC.yaml
# parent
# ├── ultralytics
# └── datasets
#     └── VOC  ← downloads here (2.8 GB)

# 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: ../datasets/VOC
train: # train images (relative to 'path')  16551 images
  - images/train2012
  - images/train2007
  - images/val2012
  - images/val2007
val: # val images (relative to 'path')  4952 images
  - images/test2007
test: # test images (optional)
  - images/test2007

# Classes
names:
  0: aeroplane
  1: bicycle
  2: bird
  3: boat
  4: bottle
  5: bus
  6: car
  7: cat
  8: chair
  9: cow
  10: diningtable
  11: dog
  12: horse
  13: motorbike
  14: person
  15: pottedplant
  16: sheep
  17: sofa
  18: train
  19: tvmonitor

# Download script/URL (optional) ---------------------------------------------------------------------------------------
download: |
  import xml.etree.ElementTree as ET

  from tqdm import tqdm
  from ultralytics.utils.downloads import download
  from pathlib import Path

  def convert_label(path, lb_path, year, image_id):
      def convert_box(size, box):
          dw, dh = 1. / size[0], 1. / size[1]
          x, y, w, h = (box[0] + box[1]) / 2.0 - 1, (box[2] + box[3]) / 2.0 - 1, box[1] - box[0], box[3] - box[2]
          return x * dw, y * dh, w * dw, h * dh

      in_file = open(path / f'VOC{year}/Annotations/{image_id}.xml')
      out_file = open(lb_path, '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)

      names = list(yaml['names'].values())  # names list
      for obj in root.iter('object'):
          cls = obj.find('name').text
          if cls in names and int(obj.find('difficult').text) != 1:
              xmlbox = obj.find('bndbox')
              bb = convert_box((w, h), [float(xmlbox.find(x).text) for x in ('xmin', 'xmax', 'ymin', 'ymax')])
              cls_id = names.index(cls)  # class id
              out_file.write(" ".join(str(a) for a in (cls_id, *bb)) + '\n')


  # Download
  dir = Path(yaml['path'])  # dataset root dir
  url = 'https://github.com/ultralytics/assets/releases/download/v0.0.0/'
  urls = [f'{url}VOCtrainval_06-Nov-2007.zip',  # 446MB, 5012 images
          f'{url}VOCtest_06-Nov-2007.zip',  # 438MB, 4953 images
          f'{url}VOCtrainval_11-May-2012.zip']  # 1.95GB, 17126 images
  download(urls, dir=dir / 'images', curl=True, threads=3, exist_ok=True)  # download and unzip over existing paths (required)

  # Convert
  path = dir / 'images/VOCdevkit'
  for year, image_set in ('2012', 'train'), ('2012', 'val'), ('2007', 'train'), ('2007', 'val'), ('2007', 'test'):
      imgs_path = dir / 'images' / f'{image_set}{year}'
      lbs_path = dir / 'labels' / f'{image_set}{year}'
      imgs_path.mkdir(exist_ok=True, parents=True)
      lbs_path.mkdir(exist_ok=True, parents=True)

      with open(path / f'VOC{year}/ImageSets/Main/{image_set}.txt') as f:
          image_ids = f.read().strip().split()
      for id in tqdm(image_ids, desc=f'{image_set}{year}'):
          f = path / f'VOC{year}/JPEGImages/{id}.jpg'  # old img path
          lb_path = (lbs_path / f.name).with_suffix('.txt')  # new label path
          f.rename(imgs_path / f.name)  # move image
          convert_label(path, lb_path, year, id)  # convert labels to YOLO format

使用方法

To train a YOLO11n model on the VOC dataset for 100 epochs with an image size of 640, you can use the following code snippets. For a comprehensive list of available arguments, refer to the model Training page.

列车示例

from ultralytics import YOLO

# Load a model
model = YOLO("yolo11n.pt")  # load a pretrained model (recommended for training)

# Train the model
results = model.train(data="VOC.yaml", epochs=100, imgsz=640)
# Start training from a pretrained *.pt model
yolo detect train data=VOC.yaml model=yolo11n.pt epochs=100 imgsz=640

图片和注释示例

VOC 数据集包含一组不同的图像,其中有各种物体类别和复杂场景。下面是数据集中的一些图像示例及其相应的注释:

数据集样本图像

  • 镶嵌图像:该图像展示了由马赛克数据集图像组成的训练批次。马赛克是一种在训练过程中使用的技术,可将多幅图像合并为单幅图像,以增加每个训练批次中物体和场景的多样性。这有助于提高模型对不同物体尺寸、长宽比和环境的泛化能力。

该示例展示了 VOC 数据集中图像的多样性和复杂性,以及在训练过程中使用镶嵌技术的好处。

引文和致谢

如果您在研究或开发工作中使用 VOC 数据集,请引用以下论文:

@misc{everingham2010pascal,
      title={The PASCAL Visual Object Classes (VOC) Challenge},
      author={Mark Everingham and Luc Van Gool and Christopher K. I. Williams and John Winn and Andrew Zisserman},
      year={2010},
      eprint={0909.5206},
      archivePrefix={arXiv},
      primaryClass={cs.CV}
}

We would like to acknowledge the PASCAL VOC Consortium for creating and maintaining this valuable resource for the computer vision community. For more information about the VOC dataset and its creators, visit the PASCAL VOC dataset website.

常见问题

什么是 PASCAL VOC 数据集,为什么它对计算机视觉任务很重要?

The PASCAL VOC (Visual Object Classes) dataset is a renowned benchmark for object detection, segmentation, and classification in computer vision. It includes comprehensive annotations like bounding boxes, class labels, and segmentation masks across 20 different object categories. Researchers use it widely to evaluate the performance of models like Faster R-CNN, YOLO, and Mask R-CNN due to its standardized evaluation metrics such as mean Average Precision (mAP).

How do I train a YOLO11 model using the VOC dataset?

To train a YOLO11 model with the VOC dataset, you need the dataset configuration in a YAML file. Here's an example to start training a YOLO11n model for 100 epochs with an image size of 640:

列车示例

from ultralytics import YOLO

# Load a model
model = YOLO("yolo11n.pt")  # load a pretrained model (recommended for training)

# Train the model
results = model.train(data="VOC.yaml", epochs=100, imgsz=640)
# Start training from a pretrained *.pt model
yolo detect train data=VOC.yaml model=yolo11n.pt epochs=100 imgsz=640

挥发性有机化合物数据集中包含哪些主要挑战?

VOC 数据集包括两个主要挑战:VOC2007 和 VOC2012。这些挑战测试 20 种不同物体类别的物体检测、分割和分类。每张图像都精心标注了边界框、类别标签和分割掩码。这些挑战赛提供了 mAP 等标准化指标,便于对不同的计算机视觉模型进行比较和基准测试。

PASCAL VOC 数据集如何加强模型基准测试和评估?

The PASCAL VOC dataset enhances model benchmarking and evaluation through its detailed annotations and standardized metrics like mean Average Precision (mAP). These metrics are crucial for assessing the performance of object detection and classification models. The dataset's diverse and complex images ensure comprehensive model evaluation across various real-world scenarios.

How do I use the VOC dataset for semantic segmentation in YOLO models?

要使用YOLO 模型将 VOC 数据集用于语义分割任务,需要在 YAML 文件中正确配置数据集。YAML 文件定义了训练分割模型所需的路径和类。详细设置请查看 VOC 数据集 YAML 配置文件VOC.yaml。

📅 Created 11 months ago ✏️ Updated 1 month ago

评论