데이터셋 개요

Ultralytics는 탐지, 인스턴스 분할, 시맨틱 분할, 깊이 추정, 분류, 포즈 추정, 방향 경계 상자(OBB)와 같은 컴퓨터 비전 작업용 데이터셋을 지원합니다. 아래에는 주요 Ultralytics 데이터셋 목록과 각 컴퓨터 비전 작업 및 관련 데이터셋의 요약이 나와 있습니다. 추적 모드는 추적기별 학습 없이 탐지, 분할, 포즈 및 OBB 모델을 기반으로 실행됩니다. 추적 데이터셋을 참조하세요.



시청: Ultralytics 데이터셋 개요

객체 탐지#

바운딩 박스 객체 탐지는 이미지 속 각 객체 주위에 바운딩 박스를 그려 객체를 탐지하고 위치를 지정하는 컴퓨터 비전 기법입니다.

  • African-wildlife: 버팔로, 코끼리, 코뿔소, 얼룩말을 포함한 아프리카 야생동물 이미지로 구성된 데이터셋입니다.
  • Argoverse: 풍부한 어노테이션이 포함된 도시 환경의 3D 추적 및 모션 예측 데이터셋입니다.
  • 뇌종양: 뇌 MRI 이미지에서 뇌종양을 탐지하기 위한 데이터셋으로, 종양에 단일 클래스의 바운딩 박스가 라벨링되어 있습니다.
  • COCO: 컨텍스트 내 일반 객체(COCO)는 80개 객체 범주를 포함하는 대규모 객체 탐지, 분할 및 캡셔닝 데이터셋입니다.
  • COCO8: COCO train2017의 처음 8개 이미지(학습용 4개, 검증용 4개)로 구성된 소규모 하위 집합으로, 빠른 테스트에 적합합니다.
  • COCO8-Grayscale: RGB를 그레이스케일로 변환해 만든 COCO8의 그레이스케일 버전으로, 단일 채널 모델 평가에 유용합니다.
  • COCO8-Multispectral: RGB 파장을 보간해 만든 COCO8의 10채널 다중 스펙트럼 버전으로, 스펙트럼 인식 모델 평가에 유용합니다.
  • COCO12-Formats: 이미지 로딩 파이프라인 검증을 위해 지원되는 12가지 이미지 형식(AVIF, BMP, DNG, HEIC, JP2, JPEG, JPG, MPO, PNG, TIF, TIFF, WebP)을 모두 포함한 12개 이미지 테스트 데이터셋입니다.
  • COCO128: COCO train2017의 처음 128개 이미지로 구성된 소규모 하위 집합으로, 테스트에 적합합니다.
  • Construction-PPE: 헬멧, 조끼, 장갑, 안전화, 고글과 같은 주요 안전 장비와 장비 미착용 여부를 라벨링한 건설 현장 이미지 데이터셋입니다. 규정 준수 및 작업자 보호를 위한 AI 모델 개발을 지원합니다.
  • Global Wheat 2020: Global Wheat Challenge 2020을 위해 밀 이삭 이미지를 포함한 데이터셋입니다.
  • HomeObjects-3K: 일반적인 가정용품 12종이 포함된 실내 장면 어노테이션 데이터셋으로, 스마트 홈 시스템, 로보틱스, 증강 현실용 컴퓨터 비전 모델을 개발하고 테스트하는 데 적합합니다.
  • KITTI: 스테레오, LiDAR, GPS/IMU 입력이 포함된 잘 알려진 자율 주행 데이터셋으로, 다양한 도로 장면에서 2D 객체 탐지에 사용됩니다.
  • LVIS: 1,203개 객체 범주를 포함하는 대규모 객체 탐지 및 인스턴스 분할 데이터셋입니다.
  • Medical-pills: 의약품 품질 관리, 분류, 업계 표준 준수 확인 등의 작업을 지원하도록 설계된 의약품 알약 라벨링 이미지 데이터셋입니다.
  • Objects365: 365개 객체 범주와 170만 개 이상의 어노테이션 이미지로 구성된 고품질 대규모 객체 탐지 데이터셋입니다.
  • Open Images V7: 601개 클래스, 학습 이미지 170만 장, 검증 이미지 4만 2천 장으로 구성된 대규모 Google 데이터셋입니다.
  • RF100: 포괄적인 모델 평가를 위해 7개 이미지 도메인에 걸친 100개 데이터셋으로 구성된 다양한 객체 탐지 벤치마크입니다.
  • Signature: 서명이 어노테이션된 다양한 문서 이미지 데이터셋으로, 문서 검증 및 사기 탐지 연구를 지원합니다.
  • SKU-110K: 1만 1천 개가 넘는 이미지와 170만 개의 바운딩 박스를 포함하는 소매 환경의 고밀도 객체 탐지 데이터셋입니다.
  • TT100K: Tsinghua-Tencent 100K 교통 표지판 데이터셋으로, 221개 표지판 범주에 걸친 스트리트 뷰 이미지 16,817개를 포함합니다.
  • Ultralytics 벤치마크: 의료, 항공, 산업, 소매 및 기타 분야의 선별된 탐지 데이터셋 37개를 아우르는 자체 벤치마크 제품군으로, 실제 환경에서 모델의 일반화 성능을 측정하기 위한 고정 프로토콜을 제공합니다.
  • VisDrone: 드론 촬영 이미지로 구성된 객체 탐지 및 다중 객체 추적 데이터셋으로, 1만 개가 넘는 이미지와 비디오 시퀀스를 포함합니다.
  • VOC: 객체 클래스 20개와 이미지 2만 1천 개 이상을 포함하는 객체 탐지 및 분할용 Pascal 시각 객체 클래스(VOC) 데이터셋입니다.
  • xView: 60개 객체 범주와 100만 개가 넘는 어노테이션 객체를 포함하는 항공 이미지 객체 탐지 데이터셋입니다.

인스턴스 분할#

인스턴스 분할은 이미지 속 객체를 픽셀 수준에서 식별하고 위치를 지정하는 컴퓨터 비전 기법입니다. 각 픽셀의 클래스만 분류하는 시맨틱 분할과 달리, 인스턴스 분할은 같은 클래스에 속한 개별 인스턴스를 구분합니다.

  • Carparts-seg: 차량 부품 식별을 위해 특별히 구축한 데이터셋으로, 설계, 제조, 연구 요구 사항을 지원합니다. 객체 탐지와 분할 작업에 모두 사용할 수 있습니다.
  • COCO: 20만 개가 넘는 라벨링 이미지로 구성된 대규모 데이터셋으로, 객체 탐지, 분할, 캡셔닝 작업을 위해 설계되었습니다.
  • COCO8-seg: 분할 어노테이션이 포함된 COCO 이미지 8개 하위 집합으로 구성된 소규모 인스턴스 분할 작업용 데이터셋입니다.
  • COCO128-seg: 분할 어노테이션이 포함된 COCO 이미지 128개 하위 집합으로 구성된 소규모 인스턴스 분할 작업용 데이터셋입니다.
  • Crack-seg: 도로와 벽의 균열 탐지를 위해 특별히 제작된 데이터셋으로, 객체 탐지 및 분할 작업에 모두 적용할 수 있습니다.
  • Package-seg: 창고나 산업 현장의 패키지 식별에 맞춰 구성된 데이터셋으로, 객체 탐지 및 분할 애플리케이션에 모두 적합합니다.

시맨틱 분할#

시맨틱 분할은 이미지의 모든 픽셀에 클래스 레이블을 할당하여 자율 주행, 장면 파싱, 토지 피복 매핑 등의 애플리케이션에 사용할 수 있는 밀집 장면 맵을 생성합니다.

  • Cityscapes: 학습 클래스 19개로 구성된 도시 거리 장면 시맨틱 분할 데이터셋입니다.
  • Cityscapes8: 시맨틱 분할 파이프라인을 빠르게 확인할 수 있는 Cityscapes 이미지 8개로 구성된 소규모 하위 집합입니다.
  • ADE20K: 시맨틱 클래스 150개를 포함하는 장면 파싱 데이터셋입니다.

깊이 추정#

단안 깊이 추정은 단일 RGB 이미지에서 픽셀별 깊이 맵을 미터 단위로 예측하여 3D 장면 재구성, 로봇 내비게이션, AR/VR 애플리케이션을 지원합니다.

  • Depth8: 파이프라인을 빠르게 확인할 수 있는 SUN RGB-D 이미지 8개로 구성된 소규모 하위 집합입니다.
  • ARKitScenes: Apple ARKit LiDAR로 캡처한 실제 실내 RGB-D 데이터로, 가장 큰 실제 학습 데이터 소스입니다.
  • SUN RGB-D: 서로 다른 네 가지 RGB-D 센서로 캡처한 실제 실내 장면입니다.
  • DIODE: 측량용 레이저 스캐너로 수집한 실내외 고밀도 깊이 데이터입니다.
  • Hypersim: 픽셀별 깊이가 완벽하게 제공되는 사실적인 합성 실내 장면입니다.
  • TartanAir: 약 80m까지의 고밀도 깊이 데이터가 포함된 합성 AirSim 환경입니다.
  • Virtual KITTI 2: 고밀도 깊이 데이터가 포함된 KITTI 주행 장면의 합성 재현 데이터입니다.
  • KITTI: Velodyne LiDAR 깊이 데이터가 포함된 실제 야외 자율 주행 장면으로, KITTI Eigen 벤치마크이기도 합니다.
  • ImageNet(의사 라벨링): 증류를 위한 Depth Anything 3 의사 라벨이 포함된 ImageNet-1K 이미지입니다.
  • NYU Depth V2: Microsoft Kinect v1으로 캡처한 표준 실내 깊이 벤치마크입니다.
  • ETH3D: 정밀도가 높은 실내외 레이저 스캐너 벤치마크입니다.
  • Make3D: 분포 외 야외 캠퍼스 벤치마크입니다.
  • iBims-1: 깊이 경계와 평면 표면을 위한 고품질 실내 벤치마크입니다.

분류#

이미지 분류는 시각적 콘텐츠를 바탕으로 이미지를 하나 이상의 사전 정의된 클래스나 범주에 분류하는 컴퓨터 비전 작업입니다.

  • Caltech 101: 이미지 분류 작업을 위해 객체 범주 101개의 이미지를 포함하는 데이터셋입니다.
  • Caltech 256: 객체 범주 256개와 더 까다로운 이미지를 포함하는 Caltech 101의 확장 버전입니다.
  • CIFAR-10: 10개 클래스의 32x32 컬러 이미지 6만 개로 구성되며, 클래스마다 이미지 6천 개를 포함하는 데이터셋입니다.
  • CIFAR-100: 객체 범주 100개와 클래스당 이미지 600개를 포함하는 CIFAR-10의 확장 버전입니다.
  • Fashion-MNIST: 이미지 분류 작업을 위해 패션 범주 10개의 그레이스케일 이미지 7만 장으로 구성된 데이터셋입니다.
  • ImageNet: 이미지 1,400만 개 이상과 범주 2만 개를 포함하는 대규모 객체 탐지 및 이미지 분류 데이터셋입니다.
  • ImageNet-10: 더 빠른 실험과 테스트를 위해 범주 10개로 구성한 ImageNet의 소규모 하위 집합입니다.
  • Imagenette: 빠른 학습과 테스트를 위해 쉽게 구분할 수 있는 클래스 10개를 포함한 ImageNet의 소규모 하위 집합입니다.
  • Imagewoof: 이미지 분류 작업을 위해 개 품종 범주 10개를 포함하는 더 까다로운 ImageNet 하위 집합입니다.
  • MNIST: 이미지 분류 작업을 위한 손글씨 숫자 그레이스케일 이미지 7만 장으로 구성된 데이터셋입니다.
  • MNIST160: MNIST 학습 및 테스트 분할에서 숫자(0~9)마다 처음 8개 이미지를 가져온 데이터셋으로, 총 160개 이미지로 구성됩니다.

자세 추정#

포즈 추정은 카메라 또는 월드 좌표계를 기준으로 객체의 포즈를 판별하는 기술입니다. 여기에는 객체, 특히 사람이나 동물의 키포인트 또는 관절을 식별하는 과정이 포함됩니다.

  • COCO: 자세 추정 작업을 위해 설계된 사람 자세 어노테이션이 포함된 대규모 데이터셋입니다.
  • COCO8-pose: 사람 자세 어노테이션이 포함된 COCO 이미지 8개 하위 집합으로 구성된 소규모 자세 추정 작업용 데이터셋입니다.
  • Dog-pose: 개에 초점을 맞춘 약 8,500개 이미지로 구성되고 개마다 24개 키포인트가 어노테이션된 포괄적인 자세 추정 작업용 데이터셋입니다.
  • Hand-Keypoints: 사람의 손을 중심으로 한 26,000장 이상의 이미지로 구성된 데이터셋입니다. 손마다 21개의 키포인트가 주석으로 표시되어 있으며 포즈 추정 작업을 위해 설계되었습니다.
  • Tiger-pose: 호랑이에 초점을 맞춘 이미지 263개로 구성되고 호랑이마다 12개 키포인트가 어노테이션된 소규모 자세 추정 작업용 데이터셋입니다.

방향성 경계 상자(OBB)#

방향 바운딩 박스(OBB)는 회전된 바운딩 박스를 사용해 이미지 속 기울어진 객체를 탐지하는 컴퓨터 비전 기법으로, 항공 및 위성 이미지에 자주 적용됩니다. 기존 바운딩 박스와 달리 OBB는 다양한 방향의 객체를 더 잘 감쌀 수 있습니다.

  • DOTA-v2: 170만 개 인스턴스와 11,268개 이미지로 구성된 널리 사용되는 OBB 항공 이미지 데이터셋입니다.
  • DOTA8: DOTAv1 분할 세트의 처음 8개 이미지(학습용 4개, 검증용 4개)로 구성된 소규모 하위 집합으로, 빠른 테스트에 적합합니다.
  • DOTA128: 학습과 검증에 모두 사용되는 DOTAv1의 128개 이미지 하위 집합으로, OBB 모델 테스트에 적합한 규모와 다양성을 제공합니다.

새 데이터셋 기여#

새 데이터셋을 기여하려면 기존 인프라와 잘 부합하는지 확인하기 위해 몇 가지 단계를 거쳐야 합니다. 필요한 단계는 다음과 같습니다:



시청: Ultralytics 데이터셋에 기여하는 방법

새 데이터셋 기여 단계#

  1. 이미지 수집: 데이터셋에 포함할 이미지를 수집합니다. 공개 데이터베이스나 자체 컬렉션 등 다양한 출처에서 이미지를 가져올 수 있습니다.

  2. 이미지 주석: 작업에 따라 경계 상자, 세그먼트 또는 키포인트를 사용하여 이미지에 주석을 표시합니다.

  3. 어노테이션 내보내기: Ultralytics가 지원하는 YOLO *.txt 파일 형식으로 어노테이션을 변환합니다.

  4. 데이터셋 구성: 데이터셋을 올바른 폴더 구조로 정리합니다. 최상위 디렉터리로 images/과 labels/이 있어야 하며, 각 디렉터리 안에는 train/와 val/ 하위 디렉터리가 있어야 합니다.

    dataset/
    ├── images/
    │   ├── train/
    │   └── val/
    └── labels/
        ├── train/
        └── val/
  5. data.yaml 파일 만들기: 데이터셋의 루트 디렉터리에 데이터셋, 클래스 및 기타 필요한 정보를 설명하는 data.yaml 파일을 만듭니다.

  6. 이미지 최적화(선택 사항): 더 효율적으로 처리할 수 있도록 데이터셋 크기를 줄이려면 아래 코드를 사용해 이미지를 최적화할 수 있습니다. 필수 작업은 아니지만 데이터셋 크기를 줄이고 다운로드 속도를 높이는 데 권장됩니다.

  7. 데이터셋 압축: 전체 데이터셋 폴더를 zip 파일로 압축합니다.

  8. 문서 작성 및 PR 제출: 데이터셋과 기존 프레임워크에 통합되는 방식을 설명하는 문서 페이지를 작성합니다. 그런 다음 Pull Request (PR)를 제출합니다. PR 제출 방법에 대한 자세한 내용은 Ultralytics 기여 가이드라인을 참조하세요.

데이터셋 최적화 및 압축 예제 코드#

데이터셋 최적화 및 압축
from pathlib import Path

from ultralytics.data.utils import compress_one_image
from ultralytics.utils.downloads import zip_directory

# 데이터셋 디렉터리 정의
path = Path("path/to/dataset")

# 데이터셋 이미지 최적화(선택 사항)
for f in path.rglob("*.jpg"):
    compress_one_image(f)

# 'path/to/dataset.zip'으로 데이터셋 압축
zip_directory(path)

이 단계를 따르면 Ultralytics의 기존 구조와 잘 통합되는 새 데이터셋을 기여할 수 있습니다.

자주 묻는 질문#

  • Ultralytics는 객체 탐지를 위한 다양한 데이터셋을 지원합니다. 예를 들면 다음과 같습니다.

    • COCO: 80개 객체 카테고리를 포함하는 대규모 객체 탐지, 분할 및 캡션 데이터셋입니다.
    • LVIS: 1,203개 객체 카테고리를 포함하며, 보다 세분화된 객체 탐지 및 분할을 위해 설계된 방대한 데이터셋입니다.
    • Argoverse: 풍부한 어노테이션이 포함된 도시 환경의 3D 추적 및 모션 예측 데이터셋입니다.
    • VisDrone: 드론 촬영 이미지의 객체 탐지 및 다중 객체 추적 데이터가 포함된 데이터셋입니다.
    • SKU-110K: 11K개 이상의 이미지로 소매 환경의 밀집 객체 탐지를 다루는 데이터셋입니다.

    이 데이터셋은 다양한 객체 탐지 애플리케이션을 위한 강력한 Ultralytics YOLO 모델 학습을 지원합니다.

  • 새 데이터셋을 기여하려면 다음과 같은 여러 단계를 거쳐야 합니다.

    1. 이미지 수집: 공개 데이터베이스나 개인 컬렉션에서 이미지를 수집합니다.
    2. 이미지 어노테이션: 작업에 따라 바운딩 박스, 세그먼트 또는 키포인트를 지정합니다.
    3. 어노테이션 내보내기: 어노테이션을 YOLO *.txt 형식으로 변환합니다.
    4. 데이터셋 구성: images/ 및 labels/ 디렉터리를 사용하고, 각 디렉터리 안에 train/ 및 val/ 하위 디렉터리를 배치하는 폴더 구조를 사용합니다.
    5. data.yaml 파일 생성: 데이터셋 설명, 클래스 및 기타 관련 정보를 포함합니다.
    6. 이미지 최적화(선택 사항): 효율성을 높이기 위해 데이터셋 크기를 줄입니다.
    7. 데이터셋 압축: 데이터셋을 zip 파일로 압축합니다.
    8. 문서 작성 및 PR 제출: 데이터셋을 설명하고 Ultralytics 기여 가이드라인에 따라 Pull Request를 제출합니다.

    자세한 가이드는 새 데이터셋 기여하기를 참조하세요.

  • Ultralytics Platform은 다음을 포함한 데이터셋 관리 및 분석 기능을 제공합니다.

    • 데이터셋 관리: 한곳에서 데이터셋을 업로드하고 정리하며 관리할 수 있습니다.
    • 즉시 학습 통합: 추가 설정 없이 업로드한 데이터셋을 모델 학습에 바로 사용합니다.
    • 시각화 도구: 데이터셋 이미지와 어노테이션을 탐색하고 시각화합니다.
    • 데이터셋 분석: 데이터셋의 분포와 특성에 대한 인사이트를 얻습니다.

    데이터셋은 동일한 플랫폼에서 관리 단계에서 모델 학습 단계로 바로 이동합니다.

  • Ultralytics YOLO 모델은 컴퓨터 비전 작업에 다음과 같은 여러 고유 기능을 제공합니다:

    • 실시간 성능: 시간에 민감한 애플리케이션을 위한 고속 추론 및 학습 기능입니다.
    • 다목적성: 탐지, 인스턴스 분할, 시맨틱 분할, 깊이 추정, 분류, 포즈 추정 및 방향성 바운딩 박스(OBB) 작업을 통합된 프레임워크에서 지원합니다.
    • 사전 학습 모델: 다양한 애플리케이션에 사용할 수 있는 고성능 사전 학습 모델을 제공하여 학습 시간을 줄입니다.
    • 폭넓은 커뮤니티 지원: 문제 해결과 개발을 위한 활발한 커뮤니티와 포괄적인 문서를 제공합니다.
    • 간편한 통합: 기존 프로젝트 및 워크플로에 통합할 수 있는 간단한 API를 제공합니다.
  • Ultralytics 도구를 사용하여 데이터셋을 최적화하고 압축하려면 다음 코드 예제를 따르세요:

    데이터셋 최적화 및 압축
    from pathlib import Path
    
    from ultralytics.data.utils import compress_one_image
    from ultralytics.utils.downloads import zip_directory
    
    # 데이터셋 디렉터리 정의
    path = Path("path/to/dataset")
    
    # 데이터셋 이미지 최적화(선택 사항)
    for f in path.rglob("*.jpg"):
        compress_one_image(f)
    
    # 'path/to/dataset.zip'으로 데이터셋 압축
    zip_directory(path)

    이 과정은 데이터셋의 크기를 줄여 저장 효율성을 높이고 다운로드 속도를 개선합니다.

댓글73

질문을 하거나 결과를 공유하거나 다른 사람을 도와주세요.

  1. Fatima-khanjarGitHub

    Hello, I hope you're doing well.

    I have a question regarding the imgsz argument in YOLO (imgsz=224).

    How exactly does the resizing process work internally? Specifically:

    • Are images resized with padding to maintain aspect ratio?
    • What if the original images are very small (e.g., 50×50)? Are they upscaled with padding, or just stretched to fit the target size?
    • Does this resizing strategy affect model performance or accuracy?

    Thanks in advance for your clarification!

  2. gdenis82GitHub(수정됨)

    Hi. Please tell me how I can balance the class weights in data.yaml for yolo11x-seg:

    train: path/to/dataset/train/images
    val: path/to/dataset/val/images
    
    nc: 2 # number of classes
    names: [class 0, class 1] # list of class name 
    cls_pw: [0.9, 0.1] 
    or 
    pos_weight: [0.9, 0.1]

    I did not find an exact understanding of how to do this.

    1. Glenn JocherUltralytics(수정됨)

      @gdenis82 hello! Class weights like cls_pw or pos_weight are not defined within the data.yaml file itself.

      These parameters are typically hard-coded within your Python training script.

    2. gdenis82GitHub

      Hello. Good documentation. You're the best at it. Thank you. I looked at it again, found a lot of interesting and useful things, but I still haven't found the answer to this question. Here is a simple example with a train. What argument do I need to use to balance the class weights?

      from ultralytics import YOLO
      
      # Load a model
      model = YOLO("yolo11x-seg.pt")  # load a pretrained model (recommended for training)
      
      # Train the model with 2 GPUs
      results = model.train(data="data.yaml", epochs=100, imgsz=640, device=[0, 1])
    3. Glenn JocherUltralytics

      @gdenis82 to handle class imbalance in YOLO11x-seg training, you have a few options:

      1. Use the cls parameter in the training function to adjust the classification loss weight:

        model.train(data="data.yaml", epochs=100, imgsz=640, device=[0, 1], cls=0.7)  # Adjust overall classification loss weight
      2. For more granular control, you can create a custom configuration file to define class weights. The class weights are typically handled in the loss function, not directly in the data.yaml.

      3. For severely imbalanced datasets, consider these practical approaches:

        • Adjust your dataset sampling to balance class representation
        • Use techniques like oversampling of minority classes or undersampling of majority classes
        • Apply data augmentation more heavily to underrepresented classes

      Class-specific weights aren't directly specified as a training argument in the current API. If you need very fine-grained control, you might need to modify the loss function implementation.

      Does this help with your class balancing needs?

    4. gdenis82GitHub

      @glenn-jocher Thank you. Do I understand correctly that this approach sets a reduced total weight of the classification error and corrects only the overall component of the loss function. For ** the entire cluster analysis**, and not separately for each class. This is useful if we have a small data imbalance and all classes can be adjusted in the same way. If each class should have individual weights (depending on the classes shown in the image), what should be done?

      # Determine the weights of the classes
      # Assume 3 classes: 0 - majority class, 1 - minority class, 2 - rare class
      weights = torch.tensor([0.5, 2.0, 3.0])  # The weights should be the inverse of the frequency of occurrence of classes.
    5. Glenn JocherUltralytics(수정됨)

      @gdenis82 you're correct - the cls parameter adjusts the overall classification loss weight, not individual class weights. For implementing individual class weights in YOLO, you would need to modify the loss function directly in the source code.

      The most straightforward approach would be to:

      1. Clone the Ultralytics repository
      2. Locate the loss implementation (typically in ultralytics/utils/loss.py)
      3. Modify the classification loss calculation to incorporate your custom class weights
      4. Use your modified version for training

      For example, you might need to add something like:

      # In the loss function where classification loss is calculated
      class_weights = torch.tensor([0.5, 2.0, 3.0], device=targets.device)
      cls_loss = cls_loss * class_weights[targets.long()]

      Alternatively, data-based approaches are often more practical:

      • Oversampling underrepresented classes
      • Augmenting minority classes more aggressively
      • Using techniques like focal loss (a FocalLoss class exists in ultralytics/utils/loss.py, but it is not used by default)

      These approaches often yield better results than direct weight modification and don't require source code changes.

  3. D3RK0GitHub

    Hi,

    Introduction

    For a couple of days now, I am trying to set YOLOv8 in classification mode in order to classify flowers in the images of the Oxford Flower dataset (i.e. https://www.robots.ox.ac.uk/~vgg/data/flowers/102/). I am using ImageNet pretrained weights to start my training.

    The error

    However, I am the obtaining error:

    Dataset not found ⚠️, missing path C:\Users\ <'my_path'> \Oxford-Flower-dataset\oxford_flower.yaml, attempting download... Downloading https://ultralytics.com/assets/C://Users/ <'my_path'> /Oxford-Flower-dataset/oxford_flower.yaml.zip to 'C:\Users\ <'my_path'> \Oxford-Flower-dataset\oxford_flower.yaml.zip'...

    My code

    • Creation of model object: model = YOLO("yolov8m-cls.pt")

    • Model.training: model.train(mode="classify", data=data_file_path, epochs=num_epochs, batch=batch_size, imgsz=256, lr0=lr, optimizer="AdamW", cos_lr=True, momentum=0.937, weight_decay=weight_decay)

    • Note that variable "data_file_path" is the path to my .yaml file I created for the Oxford Flower dataset

    My yaml file

    The content of my .yaml file is:

    names:

    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9 ....
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102 nc: 102 path: C:/Users/ <'my_path'> /Oxford-Flower-dataset/jpg train: train/images train_label_dir: train/labels val: val/images val_label_dir: val/labels

    Data directories

    The directories of my data is exactly the way your colleague / member "pderrenger" describes it in her message of March 30th 2024. It looks like:

    dataset/ ├── train/ │ ├── images/ │ └── labels.txt └── val/ ├── images/ └── labels.txt

    Labels.txt content

    The content of labels.txt is:

    image_06734.txt 1 image_06735.txt 1 image_06737.txt 1 image_06742.txt 1 image_06743.txt 1 image_06745.txt 1 image_06746.txt 1 image_06748.txt 1 image_06751.txt 1 image_06752.txt 1 ....

    Question

    Why is it unable to find the data? What I am I missing

    1. D3RK0GitHub

      The dashes in "My yaml file" section has been automatically changed bullet points. That is not intended. So, bullet points in that section are dashes.

    2. Glenn JocherUltralytics(수정됨)

      @D3RK0 it seems the issue is with the dataset path. For classification, data should be the path to the dataset root directory (not a YAML file), containing train/ and val/ (or test/) folders with one subfolder per class. The .yaml you created is not used for classification, which is why Ultralytics tried to download it. For more details, visit https://docs.ultralytics.com/datasets/classify/.

      1
    3. D3RK0GitHub

      @glenn-jocher Thank you for your quick reply!

      Testing directories as they are in the .yaml file

      All the directories in my .yaml file should exist: image

      Note that the prepare_dataset.data_dir variable is created by using a simple dialog: filedialog.askdirectory(title="Select the image data folder:").

      Folder structure

      As indicated by your colleague, I am using the following structure:

      dataset/ ├── train/ │ ├── images/ │ └── labels.txt └── val/ ├── images/ └── labels.txt

      Is this structure correct?

      Note that in the dataset folder (which is called, in my case, the jpg folder) are all the original .jpeg images files. Originally, the Oxford Flower dataset did not had this structure; all the image files are in jpg folder. Therefore, I created the folder structure you see above and copied the image files (via a script) to the train/images and val/images. But, I did not remove the original image files in the jpg folders. Could not removing the originals be the problem?

      Creating the data_file_path variable

      Comparably, to create data_file_path variable, I use data_file_path = filedialog.askopenfilename(title="Please select the dataset .yaml dataset file for YOLOv8:").

      Directories in the .yaml file

      In the .yaml file, do indicate the labels directory with the extension e.g. train/labels.txt?

    4. Glenn JocherUltralytics(수정됨)

      It looks like the issue is the dataset layout. For classification, pass the dataset root directory as data (not a YAML file), and make sure it contains train/ and val/ folders with one subfolder per class (the folder name is the class label). No labels directory or label files are used.

      1
    5. D3RK0GitHub(수정됨)

      @glenn-jocher Thank you for your quick reply :-D

      Clarification about the path key directory

      Note that the path key is not literally C:/Users/ <'my_path'> /Oxford-Flower-dataset/jpg. With <'my_path'>, I omitted part of the path for privacy. More realistically, it is like C:/Users/my_several_folders/Oxford-Flower-dataset/jpg. I hope we are the same page on that :-) .

      Folder structure

      You are saying: "The labels should be in a directory, not a single file." So, then the correct folder structure is not the way your colleague 'pderrenger' describes it; it is:

      dataset/ ├── train/ │ ├── images/ │ └── labels/ └── val/ ├── images/ └── labels/

      This is thus the expected folder structure, is it not? I have changed my folder structure to match with the expected folder, as described above. In my case, it is now: image

      Where the jpg folder is the root directory of my dataset and to which the aforementioned path key in my .yaml file points to. The image files are in the train/images and val/images folders. Lastly, the labels.txt files are the train/labels and val/labels folders.

      The content of current .yaml file

      names:

      • 1
      • 2
      • 3 ...
      • 100
      • 101
      • 102 nc: 102 path: C:/Users/derk_/Documents/Universiteit/IRP/Research_Project/Oxford-Flower-dataset/jpg train: train/images train_label_dir: train/labels val: val/images val_label_dir: val/labels

      In summary

      path key

      The path key is approximately C:/Users/my_several_folders/Oxford-Flower-dataset/jpg. This is my root directory of my dataset.

      Current folder structure

      The current folder structure is: image

      Changes I made

      • I changed the folder structure
      • I did not change the .yaml file content, because I can not see how that is wrong

      Result of the changes

      Changing the folder structure did not solve the problem. It is still unable to find the dataset.

      Additional questions

      Could you please be explicit about what the correct folder structure is? Could you please give an example of what a correct .yaml structure looks like, as this is not reported in the Ultralytics documentation (unless I missed it)?

      Many thanks!

    6. Glenn JocherUltralytics(수정됨)

      It seems the folder structure is causing the issue. For classification, no label files are needed: place the images of each class in a folder named after the class, inside train/ and val/. Then pass the dataset root directory as data. For more details, please refer to the classification dataset guide.

      1
    7. D3RK0GitHub

      @glenn-jocher Many thanks for your quick responses!

      Changes

      I changed my code from making the single labels.txt file to making individual label .txt files. It now looks like:

      image

      At the top of image is part of the directory. Below there are the label .txt files. In bottom-left is example of the content of such label file.

      Are the names of the label .txt file correct?

      Result

      Still the same dataset not found error :(

    8. Glenn JocherUltralytics(수정됨)

      Each image's class is taken from the name of the folder it sits in, so no label files are needed for classification. Make sure your data is organized as dataset/train/<class_name>/*.jpg and dataset/val/<class_name>/*.jpg, and pass the dataset root directory as data.

    9. D3RK0GitHub

      @glenn-jocher Thanks for responding!

      I have solved the previous problem. I have another problem, however.

      Output by the YOLOv8 model

      YAML file created at: C:/Users/derk_/Documents/Universiteit/IRP/Research_Project/Oxford-Flower-dataset/jpg\oxford_flower.yaml New https://pypi.org/project/ultralytics/8.3.28 available 😃 Update with 'pip install -U ultralytics' engine\trainer: task=classify, mode=train, model=yolov8m-cls.pt, data=C:/Users/derk_/Documents/Universiteit/IRP/Research_Project/Oxford-Flower-dataset/jpg, epochs=1, time=None, patience=100, batch=16, imgsz=224, save=True, save_period=1, cache=False, device=cpu, workers=8, project=None, name=train38, exist_ok=False, pretrained=True, optimizer=AdamW, verbose=True, seed=0, deterministic=True, single_cls=False, rect=False, cos_lr=True, close_mosaic=10, resume=False, amp=True, fraction=1.0, profile=False, freeze=None, multi_scale=False, overlap_mask=True, mask_ratio=4, dropout=0.0, val=True, split=val, save_json=False, save_hybrid=False, conf=None, iou=0.7, max_det=300, half=False, dnn=False, plots=True, source=None, vid_stride=1, stream_buffer=False, visualize=False, augment=False, agnostic_nms=False, classes=None, retina_masks=False, embed=None, show=False, save_frames=False, save_txt=False, save_conf=False, save_crop=False, show_labels=True, show_conf=True, show_boxes=True, line_width=None, format=torchscript, keras=False, optimize=False, int8=False, dynamic=False, simplify=True, opset=None, workspace=4, nms=False, lr0=0.01, lrf=0.01, momentum=0.937, weight_decay=0.01, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1, box=7.5, cls=0.5, dfl=1.5, pose=12.0, kobj=1.0, label_smoothing=0.0, nbs=64, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.1, scale=0.5, shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, bgr=0.0, mosaic=1.0, mixup=0.0, copy_paste=0.0, copy_paste_mode=flip, auto_augment=randaugment, erasing=0.4, crop_fraction=1.0, cfg=None, tracker=botsort.yaml, save_dir=C:\runs\classify\train38 train: C:\Users\derk_\Documents\Universiteit\IRP\Research_Project\Oxford-Flower-dataset\jpg\train... found 6149 images in 102 classes: ERROR ❌️ requires 2 classes, not 102 val: C:\Users\derk_\Documents\Universiteit\IRP\Research_Project\Oxford-Flower-dataset\jpg\val... found 1020 images in 102 classes: ERROR ❌️ requires 2 classes, not 102 test: C:\Users\derk_\Documents\Universiteit\IRP\Research_Project\Oxford-Flower-dataset\jpg\test... found 1020 images in 102 classes: ERROR ❌️ requires 2 classes, not 102 Overriding model.yaml nc=1000 with nc=2 from n params module arguments
      0 -1 1 1392 ultralytics.nn.modules.conv.Conv [3, 48, 3, 2]
      1 -1 1 41664 ultralytics.nn.modules.conv.Conv [48, 96, 3, 2]
      2 -1 2 111360 ultralytics.nn.modules.block.C2f [96, 96, 2, True]
      3 -1 1 166272 ultralytics.nn.modules.conv.Conv [96, 192, 3, 2]
      4 -1 4 813312 ultralytics.nn.modules.block.C2f [192, 192, 4, True]
      5 -1 1 664320 ultralytics.nn.modules.conv.Conv [192, 384, 3, 2]
      6 -1 4 3248640 ultralytics.nn.modules.block.C2f [384, 384, 4, True]
      7 -1 1 2655744 ultralytics.nn.modules.conv.Conv [384, 768, 3, 2]
      8 -1 2 7084032 ultralytics.nn.modules.block.C2f [768, 768, 2, True]
      9 -1 1 988162 ultralytics.nn.modules.head.Classify [768, 2]
      YOLOv8m-cls summary: 141 layers, 15,774,898 parameters, 15,774,898 gradients

      The problem

      The "[...] ERROR ❌️ requires 2 classes, not 102 [...]" is giving for all my data splits.

      My yaml file.

      The content of my yaml file:

      names: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102] nc: 102 path: C:/Users/my_several_folders/Oxford-Flower-dataset/jpg test: test/images test_label_dir: test/labels train: train/images train_label_dir: train/labels val: val/images val_label_dir: val/labels

      The length of names is equal to the value of nc, 102, so that is not disparate.

      My folder structure

      jpg/ ├── train/ │ ├── 1/ │ │ ├── img1.jpg │ │ └── img2.jpg │ ├── 2/ │ └── ... ├── val/ │ ├── 1/ │ ├── 2/ │ └── ... └── test/ ├── 1/ ├── 2/ └── ...

      The names of the classes should thus correctly correspond to folder names of the folder wherein the images of that given class are stored.

      Question

      Are you familiar with the "[...] ERROR ❌️ requires 2 classes, not 102 [...]" error? What are the most common solutions to this problem?

      Many thanks!

    10. Glenn JocherUltralytics

      @D3RK0 it seems the model configuration is set to expect 2 classes instead of 102. Ensure that the nc parameter in your model configuration matches the number of classes in your dataset. Adjust the model configuration to nc: 102 to resolve this issue.

    11. D3RK0GitHub(수정됨)

      @glenn-jocher Many thanks for your quick response!

      How can I do that? I mean, as you can see from the content of my .yaml-file, the nc parameter is already set to 102 and nc is not an accepted hyperparameter in the YOLO() or model.train() function.

    12. Glenn JocherUltralytics

      @D3RK0 ensure the model is correctly configured by setting nc: 102 in the model's YAML file before training. If the issue persists, verify that the model weights are compatible with the number of classes.

    13. xcf1GitHub

      Hello, I'd like to ask you a question. In the evaluation results I generated, the scores.txt file shows AP: 0.429, AP_50: 0.702, AP_75: 0.457, AP_medium: 0.338, AP_large: 0.555, AR: 0.490, AR_50: 0.725, AR_75: 0.536, AR_medium: 0.385, AR_large: 0.632. However, in the stdout.txt file, 0.429 is the value for AP_0.50:0.95. So, I'm confused about where to find the official COCO AP and AR values. Below are screenshots of my two text files, the first being scores.txt and the second being stdout.txt. C763135E5B2A74CD91CF4AE2CB267B0C D7D7B6AEADAA7158A90D83D8AD4B98FA

    14. Glenn JocherUltralytics(수정됨)

      The official COCO AP (Average Precision) metric is AP@0.50:0.95 which corresponds to the 0.429 value in your results. This matches both your scores.txt AP value and stdout.txt AP_0.50:0.95. For full details on COCO evaluation metrics, see the official COCO evaluation documentation.

  4. rakezshreGitHub

    Hi, I wanted to use MVTec dataset for training in Ultralytics framework with yolo. But the dataset doesnt have labelling but instead it has ground_truth with some parameters and masking. Is it possible to make a yaml file for the MVTec dataset (most easiest way)? If there is any method. Please let me know.

    Thanks.

    1. Glenn JocherUltralytics

      To use the MVTec dataset with YOLO, you'll need to convert the ground truth and masks into YOLO format. This involves creating bounding box annotations and a data.yaml file. You can refer to the Ultralytics documentation for guidance on dataset preparation and formatting. If you have further questions, feel free to ask!

    2. rakezshreGitHub

      Is there any easyway to convert MVTec dataset with YOLO with ground truth and masks. It consists of large dataset and creating bounding box annotation seems time consuming. I can see the ultralytics format for data.yaml. But issue is with the bounding box consversion.

    3. Glenn JocherUltralytics

      To convert the MVTec dataset for YOLO, you'll need to create bounding box annotations from the masks and ground truth. Tools like LabelImg can help with manual annotation. Once you have the annotations, you can format them into YOLO's required structure and create a data.yaml file. For more details, visit the Ultralytics documentation on dataset preparation.

  5. Andriw75GitHub

    I am usually interested in understanding what data I am adding to my dataset, as this can be beneficial or harmful depending on the project. I am trying to initialize the YOLO dataset to apply transformations required by the training parameters, but I often encounter errors. Thank you in advance for your help!

    from ultralytics.data.dataset import YOLODataset, v8_transforms from ultralytics.engine.trainer import check_det_dataset

    class Hyperparameters: def init(self, hyp_dict): for key, value in hyp_dict.items(): setattr(self, key, value)

    Initialize the YOLO dataset

    dataset = YOLODataset( img_path="path/to/images", # Replace with your image path data=check_det_dataset("path/to/dataset.yaml"), # Replace with your dataset configuration imgsz=640, batch_size=1 )

    Define hyperparameters for transformations

    hyp = { "mosaic": 1.0, "copy_paste": 0.5, "degrees": 10.0, "translate": 0.2, "scale": 0.9, "shear": 0.5, "perspective": 0.4, "copy_paste_mode": 'flip', 'mixup': 0.5, 'hsv_h': 0.1, 'hsv_s': 0.1, 'hsv_v': 0.1, 'flipud': 0.1, 'fliplr': 0.1 }

    hyperparams = Hyperparameters(hyp)

    Apply transformations to the dataset

    transforms = v8_transforms(dataset, imgsz=640, hyp=hyperparams)

    Attempt to augment data

    augmented_data = transforms(dataset[0])

    albumentations: Blur(p=0.01, blur_limit=(3, 7)), MedianBlur(p=0.01, blur_limit=(3, 7)), ToGray(p=0.01, num_output_channels=3, method='weighted_average'), CLAHE(p=0.01, clip_limit=(1, 4.0), tile_grid_size=(8, 8)) albumentations: Blur(p=0.01, blur_limit=(3, 7)), MedianBlur(p=0.01, blur_limit=(3, 7)), ToGray(p=0.01, num_output_channels=3, method='weighted_average'), CLAHE(p=0.01, clip_limit=(1, 4.0), tile_grid_size=(8, 8))

    Error Encountered When I run the code, I encounter the following error: ValueError: could not broadcast input array from shape (0,640,640) into shape (364,640,640) the size always changes

    1. Glenn JocherUltralytics

      @Andriw75 it seems like the error might be due to mismatched image sizes. Ensure all images in your dataset are correctly sized to 640x640 before applying transformations. If the issue persists, double-check your dataset paths and configuration. For further details, you can refer to the Ultralytics documentation on datasets.

  6. MehrsaMashhadiGitHub

    Hello. I hope you are doing well. I have paired RGB and thermal images, and I want to train yolov9 with 4 channel data. I want the model to read the first 3 channels from the RGB folder, and the thermal image from the thermal folder. all of the paired images have the same name, they are in different folders named ir, and vi. can you please help me how I should address this to the model?

    1. Glenn JocherUltralytics

      @MehrsaMashhadi to train YOLOv9 with 4-channel data, you'll need to modify the data loading process to combine RGB and thermal images into a single input. You can create a custom dataset class that reads images from both folders and concatenates them into a 4-channel tensor. Ensure your model architecture supports 4-channel input. For more details, refer to the dataset customization section in the Ultralytics documentation.

  7. toxanbiGitHub

    I am absolute newbiew in machine learning coming from the world of low-level and system programming (drivers, firmware, electronics and so on). I have some questions.

    1. Is my understanding correct that in machine learning there is a term 'model' which denotes an interconnect of neurons, i.e. the topogy of a neural network, a data structure describing how neurons are connected to each other, and, on the other hand, there is a 'weights' or 'weight file' which holds coefficients describing how signals (stymulus, activations) of a particular neuron influences on other neurons? If this is correct, which one of these two is represented by .pt-file? Or .pt file holds both of these? What is anatomy of .pt-files and where can I learn about it?

    2. Let's assume that we are going to make a NN which can classify or detect three types of objects: cats, frogs and birds. What is optimal strategy of mastering a dataset to learn it: a) A given images must contain either one of these object (annotated by bounding box) b) A given image must contain multiple objects of the same type. c) It's better for every image to have all three instances of these kinds on it c-a) And it's better to not overlap. c-b) And, countrary, it's better to have overlapping to learn NN to handle such cases.

    Should I feed NN with a pictures which doesn't have objects of interest at all or it is useless?

    1. Now instead of having three categories (cats, frogs and birds) we are going to add yet another one which is "other live-forms". Is it a good practive to feed NN with tonns of images of completely different (visually) animals all tagged (annotated) as "other live-forms" or it's better to annotate each animal (other than cat, frog or bird) by setting a class corresponding to their real-world kind? Won't it confuse a NN if crocodiles and kangooros are all annotated as the object of same class? I presume that a process of learning/training is all about finding a features which uniquelly distinguish one class of objects from the others by finding proper weights/coefficients and if vast variety of totally different objects must be considered all having the same type, it may be impossible to find proper weights at all. Or it's not the case? If it is, seems that for that particular task one should use two different NNs: one to distinguisth alive objects for non-alive, and the second stage NN to detect cats/frogs/dogs (and if the second one doesn't detect either of these, but the first one detected a life-form, then it is considered "other life-form").

    2. It's stated that default YOLO models which are available on this website are pretrained on COCO dataset. I saw a discussion on whether it's better to learn your NN from scratch or use a model pretrained on COCO. From my point of view traning a model (which was originally trained on COCO dataset) on your own dataset does only make sense if your custom dataset has exactly the same combinartion of 80 classes as COCO? And if you have less categories than COCO or more categories or even exactly 80 but of completely different types (e.g. you are learning NN to distinguish 80 kinds of vehicle motors), then the only option is learning from scratch?

    3. I can't find a complete and strict definition of that the term 'val' or 'validation' means in context of training a model? Does it affects behaviour of the model or it is just a way to see how well training went?

    4. When we learn a model to detect cats we feed it with images of what is DEFINITELY a cat. But is there a way to show it depiciting objects that are DEFINITELY NOT a cat to avoid false-positives? Other than introducing separate categories for objects that looks very similar to a cat and may be confused with cats but are not really a cat.

    5. Many articles and videos tell us that YOLO format of labels is just s plain-text file with separate line for every label and each line consists of 5 fields; class-id and normalized coordinates of a bounding-box. But what about instance segmentation tasks? Oriented boundong box detection? Bone prediction (aka post)? Doesn't it require completely different and more complex format of annotations (compared to just specifying bounding box)?

    1. Glenn JocherUltralytics

      @toxanbi 1. Your understanding is correct. The .pt file in PyTorch contains both the model architecture and the weights. You can learn more about the anatomy of .pt files in the PyTorch documentation.

      1. For optimal dataset creation, include diverse scenarios: single objects, multiple objects, overlapping objects, and images without objects. This helps the model generalize better.

      2. It's better to have specific classes for different animals rather than a generic "other live-forms" class. This avoids confusion and improves model accuracy.

      3. Pretraining on COCO is beneficial even if your dataset differs. Transfer learning can help the model learn faster and perform better, even with different categories.

      4. Validation (val) is used to evaluate the model's performance on a separate dataset during training. It doesn't affect the model's behavior but helps monitor training progress.

      5. To reduce false positives, you can include images without the target object in your training dataset. This helps the model learn what not to detect.

      6. For tasks like instance segmentation, oriented bounding boxes, and pose estimation, the annotation format is more complex. Refer to the specific task documentation for details on the required annotation formats.

  8. WARHE8DGitHub

    Hello, how can i update my model and dataset to public? I only see 2 options private and anyone with link. thanks!

    1. Paula DerrengerUltralytics

      @WARHE8D to make your model and dataset public, you need to ensure they are properly shared on a platform that supports public access. Currently, the options you mentioned ("private" and "anyone with link") are likely platform-specific settings. If you're using a service like Google Drive or Dropbox, you may need to adjust the sharing settings to "public" or "anyone with the link can view." For more detailed steps on contributing datasets to Ultralytics, please refer to the Contribute New Datasets section in our documentation.

      1
  9. 1729asrafulGitHub

    I have 47 classes csv file. each file contains 100 images in csv formate with label. now how I can traine it?

    1. Glenn JocherUltralytics(수정됨)

      @1729asraful hi there!

      To train your model using a CSV file containing 47 classes and 100 images per class, you'll need to follow a few steps to prepare your data and then use the Ultralytics YOLO framework for training. Here’s a concise guide to get you started:

      Step 1: Convert CSV to YOLO Format

      First, you need to convert your CSV annotations into the YOLO format. Each image should have a corresponding .txt file with annotations in the format:

      <class> <x_center> <y_center> <width> <height>

      Where:

      • <class> is the class index (0 to 46 for your 47 classes).
      • <x_center>, <y_center>, <width>, and <height> are normalized values (between 0 and 1) relative to the image dimensions.
      Step 2: Organize Your Dataset

      Organize your dataset into the following structure:

      dataset/
      ├── train/
      │   ├── images/
      │   └── labels/
      └── val/
          ├── images/
          └── labels/

      Place your images in the images/ directories and the corresponding YOLO format annotation files in the labels/ directories.

      Step 3: Create a data.yaml File

      Create a data.yaml file in the root of your dataset directory with the following content:

      train: path/to/dataset/train/images
      val: path/to/dataset/val/images
      
      nc: 47  # number of classes
      names: [class0, class1, ..., class46]  # list of class names
      Step 4: Train Your Model

      You can now train your model using the Ultralytics YOLO framework. Here’s an example using the CLI:

      yolo detect train data=path/to/data.yaml model=yolo26n.pt epochs=100 imgsz=640

      Or using Python:

      from ultralytics import YOLO
      
      # Load a model
      model = YOLO('yolo26n.pt')  # load a pretrained model
      
      # Train the model
      results = model.train(data='path/to/data.yaml', epochs=100, imgsz=640)
      Additional Resources

      For more detailed information on dataset preparation and training, please refer to the Ultralytics Datasets Documentation.

      If you encounter any issues, please provide a minimum reproducible example so we can assist you better. You can find more details on how to create one here.

      Happy training! 🚀

    2. Glenn JocherUltralytics(수정됨)

      @1729asraful you're welcome! 😊

      To train your model using a CSV file containing 47 classes and 100 images per class, you'll need to convert your CSV annotations into the YOLO format and organize your dataset accordingly. Here’s a step-by-step guide:

      Step 1: Convert CSV to YOLO Format

      First, convert your CSV annotations into the YOLO format. Each image should have a corresponding .txt file with annotations in the format:

      <class> <x_center> <y_center> <width> <height>

      Where:

      • <class> is the class index (0 to 46 for your 47 classes).
      • <x_center>, <y_center>, <width>, and <height> are normalized values (between 0 and 1) relative to the image dimensions.
      Step 2: Organize Your Dataset

      Organize your dataset into the following structure:

      dataset/
      ├── train/
      │   ├── images/
      │   └── labels/
      └── val/
          ├── images/
          └── labels/

      Place your images in the images/ directories and the corresponding YOLO format annotation files in the labels/ directories.

      Step 3: Create a data.yaml File

      Create a data.yaml file in the root of your dataset directory with the following content:

      train: path/to/dataset/train/images
      val: path/to/dataset/val/images
      
      nc: 47  # number of classes
      names: [class0, class1, ..., class46]  # list of class names
      Step 4: Train Your Model

      You can now train your model using the Ultralytics YOLO framework. Here’s an example using the CLI:

      yolo detect train data=path/to/data.yaml model=yolo26n.pt epochs=100 imgsz=640

      Or using Python:

      from ultralytics import YOLO
      
      # Load a model
      model = YOLO('yolo26n.pt')  # load a pretrained model
      
      # Train the model
      results = model.train(data='path/to/data.yaml', epochs=100, imgsz=640)

      For more detailed information on dataset preparation and training, please refer to the Ultralytics Datasets Documentation.

      If you encounter any issues, please provide a minimum reproducible example so we can assist you better. You can find more details on how to create one here.

      Happy training! 🚀

  10. Llll0l0lGitHub

    Hello, I'm new to machine learning, is it possible to train videos? i turned them into imgs however will it understand that the label belongs to continuous imgs that are sequential ?

    Thank you for reading

    1. Paula DerrengerUltralytics(수정됨)

      @Llll0l0l hello,

      Welcome to the world of machine learning! 🌟 Yes, it is indeed possible to train models using video data. Converting videos into sequential images is a common practice. However, to ensure that the model understands the temporal context (i.e., that the images are sequential and belong to a continuous video), you might want to consider using multi-object tracking (MOT) techniques.

      In multi-object tracking, the model not only detects objects in each frame but also assigns a unique ID to each detected object, maintaining this ID across frames. This way, the model can track the movement and changes of objects over time, understanding the sequential nature of the data.

      Here’s a brief overview of how you can approach this:

      1. Convert Video to Frames: You’ve already done this step by converting your video into images.
      2. Annotate Frames: Ensure that your images are annotated correctly. Each frame should have annotations that indicate the presence and location of objects.
      3. Use a Multi-Object Tracking Model: Ultralytics supports various models and configurations for multi-object tracking. You can use models like YOLO26 with trackers such as BoT-SORT or ByteTrack.

      Here’s a simple example of how you can set up multi-object tracking using YOLO26:

      from ultralytics import YOLO
      
      # Load a model
      model = YOLO("yolo26n.pt")  # Load an official model
      
      # Perform tracking on a video source
      results = model.track("path/to/your/video.mp4", show=True)  # Tracking with default tracker

      For more detailed guidance, you can refer to the Ultralytics documentation on multi-object tracking.

      If you encounter any issues or need further assistance, please ensure you are using the latest version of the Ultralytics packages. Additionally, providing a minimum reproducible example can greatly help in diagnosing and resolving any problems. You can find more information on creating a reproducible example here.

      Happy experimenting, and feel free to reach out if you have more questions! 😊

    2. Paula DerrengerUltralytics(수정됨)

      Hello @Llll0l0l,

      Thank you for your kind words! 😊

      Regarding your question about training on video data: converting videos into sequential images is a great start. However, to ensure the model understands the temporal context, you might want to explore multi-object tracking (MOT) techniques. These techniques help the model maintain object identities across frames, effectively understanding the continuity in the sequence.

      Here's a brief guide on how to proceed:

      1. Convert Video to Frames: As you've done, convert your video into individual frames.
      2. Annotate Frames: Ensure each frame is annotated correctly. This involves labeling objects in each frame.
      3. Use Multi-Object Tracking: Utilize models like YOLO26 with trackers such as BoT-SORT or ByteTrack to maintain object identities across frames.

      Here’s an example of how you can set up multi-object tracking using YOLO26:

      from ultralytics import YOLO
      
      # Load a model
      model = YOLO("yolo26n.pt")  # Load an official model
      
      # Perform tracking on a video source
      results = model.track("path/to/your/video.mp4", show=True)  # Tracking with default tracker

      For more detailed guidance, you can refer to the Ultralytics documentation on multi-object tracking.

      If you encounter any issues, please ensure you are using the latest version of the Ultralytics packages. Providing a minimum reproducible example can also greatly help in diagnosing and resolving any problems. You can find more information on creating a reproducible example here.

      Feel free to reach out if you have more questions. Happy experimenting! 🚀