Überblick über Datensätze für die Objekterkennung
Für das Training eines robusten und präzisen Modells zur Objekterkennung ist ein umfassender Datensatz erforderlich. Diese Anleitung stellt verschiedene Datensatzformate vor, die mit dem Ultralytics YOLO-Modell kompatibel sind, und erläutert deren Struktur und Verwendung sowie die Umwandlung zwischen verschiedenen Formaten.
Unterstützte Datensatzformate#
Ultralytics-YOLO-Format#
Das Ultralytics-YOLO-Format ist ein Datensatzkonfigurationsformat, mit dem du das Stammverzeichnis des Datensatzes, die relativen Pfade zu den Verzeichnissen mit Trainings-, Validierungs- und Testbildern oder zu *.txt-Dateien mit Bildpfaden sowie ein Wörterbuch mit Klassennamen angeben kannst. Hier ein Beispiel:
# 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.zipJedes von train, val und test akzeptiert ein Verzeichnis, eine Bilddatei, eine Liste von Verzeichnissen oder Bilddateien oder eine UTF-8-*.txt-Datei, die pro Zeile einen Bildpfad enthält (Pfade, die mit ./ beginnen, werden relativ zur Datei *.txt aufgelöst). Eine *.txt-Datei ist nützlich, um mit einer Teilmenge eines Verzeichnisses zu trainieren, nicht beschriftete Bilder zu überspringen oder Bilder aus mehreren Quellen in einem Split zusammenzuführen.
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(Optional) colors weist jeder Klasse eine Anzeigefarbe als Zeichenfolge "#rrggbb" in Anführungszeichen zu, die nach Klassen-ID indiziert ist, z. B. colors: ["#042aff", "#ff0000"]. Trainierte und exportierte Modelle behalten diese Farben für ihre Vorhersagen bei; Klassen ohne eigene Farbe verwenden die Standard-Palette. Ein NDJSON-Datensatzdatensatz kann dasselbe Feld colors enthalten.
Labels für dieses Format sollten im YOLO-Format exportiert werden, mit einer *.txt-Datei pro Bild. Wenn ein Bild keine Objekte enthält, ist keine *.txt-Datei erforderlich. Die *.txt-Datei sollte so formatiert sein, dass sie eine Zeile pro Objekt im class x_center y_center width height-Format enthält. Die Koordinaten der Bounding Box müssen im normalisierten xywh-Format angegeben werden (Werte von 0 bis 1). Wenn deine Boxen in Pixeln angegeben sind, solltest du x_center und width durch die Bildbreite und y_center und height durch die Bildhöhe teilen. Die Koordinaten beziehen sich auf die Darstellung des Bildes im Viewer, nachdem seine EXIF-Ausrichtung angewendet wurde, so liest Ultralytics jedes Bild ein. Die Klassennummern sollten bei 0 beginnen.

Die Labeldatei für das obige Bild enthält zwei Personen (Klasse 0) und eine Krawatte (Klasse 27):

Wenn du das Ultralytics-YOLO-Format verwendest, ordne deine Trainings- und Validierungsbilder sowie Labels wie im folgenden Beispiel des COCO8-Datensatzes an.

Anwendungsbeispiel#
So kannst du Datensätze im YOLO-Format verwenden, um dein Modell zu trainieren:
from ultralytics import YOLO
# Ein Modell laden
model = YOLO("yolo26n.pt") # ein vortrainiertes Modell laden (für das Training empfohlen)
# Das Modell trainieren
results = model.train(data="coco8.yaml", epochs=100, imgsz=640)Ultralytics-NDJSON-Format#
Das NDJSON-Format (JSON mit einem Datensatz pro Zeile) bietet eine alternative Möglichkeit, Datensätze für Ultralytics-YOLO-Modelle zu definieren. In diesem Format werden Metadaten des Datensatzes und Annotationen in einer einzigen Datei gespeichert, wobei jede Zeile ein eigenes JSON-Objekt enthält.
Eine NDJSON-Datensatzdatei enthält:
- Datensatzdatensatz (erste Zeile): Enthält Metadaten zum Datensatz, darunter den Aufgabentyp, Klassennamen und allgemeine Informationen
- Bilddatensätze (nachfolgende Zeilen): Enthalten einzelne Bilddaten wie Abmessungen, Annotationen und Dateipfade
{
"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"
}Benutzerdefinierte Bildmetadaten#
Jeder Bilddatensatz kann ein JSON-Objekt metadata mit anwendungsspezifischen Angaben enthalten, etwa zu Aufnahmebedingungen, Gerätekennungen oder Prüfstatus. Verschachtelte Werte werden unterstützt. Beim Import in die Ultralytics Platform werden die Metadaten mit dem Bild gespeichert und können im Vollbild-Informationsbereich angezeigt oder bearbeitet werden.
{
"type": "image",
"file": "airbus-wing.jpg",
"url": "https://example.com/airbus-wing.jpg",
"split": "train",
"metadata": {
"aircraft": { "family": "A350", "section": "wing" },
"inspectionStatus": "reviewed"
}
}Die Platform begrenzt Schlüssel der obersten Ebene in den Metadaten auf 128 Zeichen, das serialisierte Metadatenobjekt jedes Bildes auf 500.000 Zeichen und die effektiven Metadaten insgesamt in einem NDJSON-Import auf 500.000 Zeichen.
Anwendungsbeispiel#
Um einen NDJSON-Datensatz mit YOLO26 zu verwenden, gib einfach den Pfad zur Datei .ndjson an:
from ultralytics import YOLO
# Ein Modell laden
model = YOLO("yolo26n.pt")
# Mit NDJSON-Datensatz trainieren
results = model.train(data="path/to/dataset.ndjson", epochs=100, imgsz=640)Vorteile des NDJSON-Formats#
- Eine Datei: Alle Informationen zum Datensatz sind in einer Datei enthalten
- Streaming: Große Datensätze lassen sich zeilenweise verarbeiten, ohne alles in den Arbeitsspeicher zu laden
- Cloud-Integration: Unterstützt entfernte Bild-URLs für cloudbasiertes Training
- Erweiterbarkeit: Benutzerdefinierte Metadatenfelder lassen sich leicht hinzufügen
- Versionsverwaltung: Das Dateiformat mit einer einzelnen Datei eignet sich gut für git und Versionsverwaltungssysteme
Unterstützte Datensätze#
Hier findest du eine Liste der unterstützten Datensätze mit einer kurzen Beschreibung. Die meisten dieser Datensätze sind auch auf der Ultralytics Platform verfügbar. Dort kannst du Bilder und Annotationen durchsuchen, Datensatzstatistiken anzeigen und Datensätze für das Cloud-Training klonen.
- African-wildlife: Ein Datensatz mit Bildern afrikanischer Wildtiere, darunter Büffel, Elefanten, Nashörner und Zebras.
- Argoverse: Der Argoverse-HD-2D-Erkennungsdatensatz mit 54.446 Stadtverkehrsbildern für autonomes Fahren und 8 Klassen von Straßenobjekten.
- Hirntumor: Ein Datensatz zur Erkennung von Hirntumoren in Gehirn-MRT-Bildern, die mit Begrenzungsrahmen für Tumoren einer einzelnen Klasse markiert sind.
- COCO: Common Objects in Context (COCO) ist ein umfangreicher Datensatz für Objekterkennung, Segmentierung und Bildbeschreibungen mit 80 Objektkategorien.
- COCO8: Eine kleinere Teilmenge der ersten 8 Bilder aus COCO train2017 mit 4 Trainings- und 4 Validierungsbildern, geeignet für schnelle Tests.
- COCO8-Grayscale: Eine Graustufenversion von COCO8, die durch die Umwandlung von RGB in Graustufen erstellt wurde und sich für die Auswertung von Modellen mit einem Kanal eignet.
- COCO8-Multispectral: Eine multispektrale Version von COCO8 mit 10 Kanälen, die durch Interpolation der RGB-Wellenlängen erstellt wurde und sich für die spektralbewusste Modellauswertung eignet.
- COCO12-Formats: Ein Testdatensatz mit 12 Bildern in 12 unterstützten Bildformaten (AVIF, BMP, DNG, HEIC, JP2, JPEG, JPG, MPO, PNG, TIF, TIFF, WebP) zur Validierung von Bildladepipelines.
- COCO16: Eine Teilmenge der ersten 16 Bilder aus COCO train2017 (8 Training + 8 Validierung), geeignet für schnelle Tests.
- COCO32: Eine Teilmenge der ersten 32 Bilder aus COCO train2017 (16 Training + 16 Validierung), geeignet für schnelle Tests.
- COCO64: Eine Teilmenge der ersten 64 Bilder aus COCO train2017 (32 Training + 32 Validierung), geeignet für schnelle Tests.
- COCO128: Eine kleinere Teilmenge der ersten 128 Bilder aus COCO train2017, geeignet für Tests.
- Construction-PPE: Ein Datensatz mit Baustellenpersonal und annotierter Schutzausrüstung wie Helmen, Westen, Handschuhen, Stiefeln und Schutzbrillen. Er enthält auch Annotationen zu fehlender Ausrüstung wie no_helmet und no_goggle zur Überwachung der Einhaltung von Vorschriften in der Praxis.
- Global Wheat 2020: Ein Datensatz mit Bildern von Weizenähren für die Global Wheat Challenge 2020.
- HomeObjects-3K: Ein Datensatz mit Gegenständen aus Innenräumen, darunter Betten, Stühle, Fernseher und vieles mehr – ideal für Anwendungen in der Smart-Home-Automatisierung, Robotik, erweiterten Realität und Raumanalyse.
- KITTI: Ein Datensatz mit realen Fahrszenen sowie Stereo-, LiDAR- und GPS/IMU-Daten, der hier für Aufgaben der 2D-Objekterkennung verwendet wird, etwa zur Erkennung von Autos, Fußgängern und Radfahrern in städtischen, ländlichen und Autobahnumgebungen.
- LVIS: Ein umfangreicher Datensatz für Objekterkennung und Instanzsegmentierung mit 1.203 Objektkategorien.
- Medical-pills: Ein Datensatz mit Bildern medizinischer Pillen, annotiert für Anwendungen wie pharmazeutische Qualitätssicherung, Pillensortierung und die Einhaltung gesetzlicher Vorschriften.
- Objects365: Ein hochwertiger, umfangreicher Datensatz zur Objekterkennung mit 365 Objektkategorien und mehr als 1,7 Millionen Trainingsbildern.
- OpenImagesV7: Ein umfassender Datensatz von Google mit 1,7 Millionen Trainingsbildern und 42.000 Validierungsbildern.
- Roboflow 100: Ein vielfältiger Benchmark zur Objekterkennung mit 100 Datensätzen aus sieben Bilddomänen für eine umfassende Modellbewertung.
- Signature: Ein Datensatz mit Bildern verschiedener Dokumente und annotierten Unterschriften, der die Forschung zur Dokumentenprüfung und Betrugserkennung unterstützt.
- SKU-110K: Ein Datensatz zur Erkennung dicht angeordneter Objekte im Einzelhandel mit mehr als 11.000 Bildern und 1,7 Millionen Begrenzungsrahmen.
- TT100K: Der Verkehrszeichendatensatz Tsinghua-Tencent 100K (TT100K) umfasst 16.817 Straßenansichten mit 221 Verkehrszeichenkategorien für Erkennung und Klassifizierung.
- Ultralytics Benchmark: Eine interne Benchmark-Suite mit 37 sorgfältig zusammengestellten Erkennungsdatensätzen aus den Bereichen Medizin, Luftbildaufnahmen, Industrie, Einzelhandel und weiteren Gebieten sowie einem festgelegten Verfahren zur Messung der Modellgeneralisierung in der Praxis.
- VisDrone: Ein Datensatz mit Daten zur Objekterkennung und Mehrfachobjektverfolgung aus Drohnenaufnahmen mit mehr als 10.000 Bildern und Videosequenzen.
- VOC: Der Pascal-Datensatz Visual Object Classes (VOC) zur Objekterkennung und Segmentierung mit 20 Objektklassen und über 11.000 Bildern.
- xView: Ein Datensatz zur Objekterkennung in Luftbildern mit 60 Objektkategorien und mehr als 1 Million annotierten Objekten.
Eigenen Datensatz hinzufügen#
Wenn du einen eigenen Datensatz hast und ihn zum Trainieren von Erkennungsmodellen im Ultralytics-YOLO-Format verwenden möchtest, stelle sicher, dass er dem oben unter „Ultralytics-YOLO-Format“ angegebenen Format entspricht. Konvertiere deine Annotationen in das erforderliche Format und gib die Pfade, die Anzahl der Klassen und die Klassennamen in der YAML-Konfigurationsdatei an.
Beschriftungsformate übertragen oder konvertieren#
COCO-Datensatzformat in YOLO-Format konvertieren#
Mit dem folgenden Codebeispiel kannst du Labels aus dem Format des beliebten COCO-Datensatzes in das YOLO-Format umwandeln:
from ultralytics.data.converter import convert_coco
convert_coco(labels_dir="path/to/coco/annotations/")Mit diesem Konvertierungswerkzeug kannst du den COCO-Datensatz oder jeden Datensatz im COCO-Format in das Ultralytics-YOLO-Format konvertieren. Dabei werden die JSON-basierten COCO-Annotationen in das einfachere textbasierte YOLO-Format umgewandelt, das mit Ultralytics-YOLO-Modellen kompatibel ist. Den vollständigen Ablauf – einschließlich der Zuordnung von Klassen-IDs, der Verzeichnisstruktur sowie Segmentierungs- oder Posenschätzungs-Annotationen – findest du unter COCO-Annotationen in YOLO konvertieren.
Prüfe sorgfältig, ob der Datensatz, den du verwenden möchtest, mit deinem Modell kompatibel ist und den erforderlichen Formatvorgaben entspricht. Korrekt formatierte Datensätze sind entscheidend für das erfolgreiche Training von Objekterkennungsmodellen.
Wie geht es weiter?#
Nachdem du deinen Datensatz formatiert hast, starte das Training deines Modells. Du weißt nicht, mit welchem vortrainierten Modell du beginnen sollst? Vergleiche die Optionen in der YOLO26-Modellfamilie.
Häufig gestellte Fragen#
Das Ultralytics-YOLO-Format ist eine strukturierte Konfiguration zum Definieren von Datensätzen in deinen Trainingsprojekten. Dabei werden die Pfade zu deinen Trainings-, Validierungs- und Testbildern sowie den zugehörigen Beschriftungen festgelegt. Zum Beispiel:
# 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.zipBeschriftungen werden in
*.txt-Dateien gespeichert, eine Datei pro Bild. Sie sind alsclass x_center y_center width heightmit normalisierten Koordinaten formatiert. Eine ausführliche Anleitung findest du im Beispiel zum COCO8-Datensatz.Du kannst einen COCO-Datensatz mithilfe der Ultralytics-Konvertierungswerkzeuge in das YOLO-Format konvertieren. Hier ist eine kurze Anleitung:
from ultralytics.data.converter import convert_coco convert_coco(labels_dir="path/to/coco/annotations/")Dieser Code wandelt deine COCO-Annotationen in das YOLO-Format um, damit du Ultralytics-YOLO-Modelle damit trainieren kannst.
Ultralytics YOLO unterstützt zahlreiche Datensätze, darunter:
Die Seite zu jedem Datensatz enthält detaillierte Informationen zu seiner Struktur und Verwendung, abgestimmt auf ein effizientes YOLO26-Training. Die vollständige Liste findest du im Abschnitt Unterstützte Datensätze.
Um mit dem Training eines YOLO26-Modells zu beginnen, stelle sicher, dass dein Datensatz korrekt formatiert ist und die Pfade in einer YAML-Datei angegeben sind. Verwende das folgende Skript, um das Training zu starten:
Beispielfrom ultralytics import YOLO model = YOLO("yolo26n.pt") # Vortrainiertes Modell laden results = model.train(data="path/to/your_dataset.yaml", epochs=100, imgsz=640)Ultralytics stellt zahlreiche Beispiele und praxisnahe Anleitungen zur Verwendung von YOLO für vielfältige Anwendungen bereit. Im Ultralytics-Blog findest du Fallstudien, ausführliche Tutorials und Beiträge aus der Community zu Objekterkennung, Segmentierung und mehr. Konkrete Beispiele findest du auf der Dokumentationsseite zum Predict-Modus.
Kommentare54
Stell eine Frage, teile deine Ergebnisse oder hilf jemand anderem.
zcoolster11
Python Head Bop
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.
Murat Raimbekovhey @orz-serein, short answer: no, you don't need empty label files for background images - just leave the
.txtout.i verified this empirically on the current main branch. setup: 5 images, 2 with real labels, 1 with an empty
.txtfile, 2 without any.txtfile at all. building aYOLODatasetover them gives:Scanning /tmp/bgtest_full/labels... 3 images, 3 backgrounds, 0 corrupt: 100% 5/5all 5 images are kept. the 3 without labels (the empty-
.txtone and the two with no.txtat all) all end up with the same(0, 5)labels array - they are treated identically as background images.so both options work:
- no
.txtfile: counted as "missing" (nm=1), no labels -> background - empty
.txtfile: counted as "empty" (ne=1), no labels -> background
both end up in the same
backgrounds = nm + nebucket inultralytics/data/dataset.py.this is also stated in the detection dataset docs:
If there are no objects in an image, no
*.txtfile 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!
- no
sereinHello, 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?
Fatima-khanjar
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,
bimal-gajera
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.
Glenn JocherUltralytics(bearbeitet)@bimal-gajera currently, the
labels_dirkey 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 siblingimages/andlabels/directories (for exampletrain/imagesandtrain/labels). For more details, refer to the Object Detection Datasets Overview.1
nitya-pandey-astro
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?
Glenn JocherUltralytics(bearbeitet)@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!
nitya-pandey-astro
@glenn-jocher Thankyou very much for the prompt response. I am going to work on your suggestions.
Yuxuan1998
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/andval/folders containsimages/andlabels/folders. However, the COCO8 dataset example shows the opposite way, each ofimages/andlabels/folder containstest/andval/folders. Does the folder structure matter here? Thanks in advance
Glenn JocherUltralytics(bearbeitet)@Yuxuan1998 both layouts work, as long as each image has a sibling
labelsdirectory: Ultralytics finds the label for an image by replacing the last/images/in its path with/labels/(sotrain/images/img.jpgusestrain/labels/img.txt, andimages/train/img.jpguseslabels/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
milanaveed
Hello, can you please fix the broken images on this page? Can't see the label file example.
wgdcxy
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...
Glenn JocherUltralyticsIt seems like your dataset labels are not being recognized. Please ensure your label files are in the correct YOLO format and that the directory is writable. For detailed guidance, visit the dataset formatting section at https://docs.ultralytics.com/datasets/detect/.
wgdcxy
Hi, but my file path is very accurate, and I checked it N times, so is there any otherreason? Thank you
Glenn JocherUltralytics@wgdcxy please ensure your label files are in the correct YOLO format, with one
.txtfile per image containing normalized coordinates. Also, verify that the directory permissions allow writing. For more details, refer to the dataset formatting guide linked earlier.wgdcxy
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
wgdcxy
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]
wgdcxy
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.
wgdcxy
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
Glenn JocherUltralytics@wgdcxy to address the image size issue, ensure your
imgszis 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!wgdcxy
WARNING ⚠️ NMS time limit 0.900s exceeded. Hello, my teacher who has never met, what should I do with this warning?
Glenn JocherUltralytics(bearbeitet)@wgdcxy the "NMS time limit exceeded" warning is not controlled by an
nmsargument. 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 raisingconfor loweringmax_detduring validation. If you have further questions, feel free to ask!wgdcxy
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
wgdcxy
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
Glenn JocherUltralyticsTo 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.
wgdcxy
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...
这个问题该如何解决?
Glenn JocherUltralyticsIt looks like your dataset labels are missing or not formatted correctly. Please ensure your labels are in the YOLO format and check the directory permissions. For detailed guidance, visit the dataset formatting section at https://docs.ultralytics.com/datasets/detect/.
