Panoramica dei dataset per il rilevamento degli oggetti
Per addestrare un modello di rilevamento degli oggetti robusto e accurato, serve un dataset completo. Questa guida presenta diversi formati di dataset compatibili con il modello Ultralytics YOLO e ne illustra la struttura, l'utilizzo e la conversione da un formato all'altro.
Formati di dataset supportati#
Formato Ultralytics YOLO#
Il formato Ultralytics YOLO è un formato di configurazione dei dataset che consente di definire la directory principale del dataset, i percorsi relativi alle directory delle immagini di addestramento/validazione/test o ai file *.txt contenenti i percorsi delle immagini e un dizionario di nomi delle classi. Ecco un esempio:
# 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.zipOgnuno tra train, val e test accetta una directory, un file immagine, un elenco di directory o file immagine oppure un file *.txt UTF-8 che elenca un percorso immagine per riga (i percorsi che iniziano con ./ vengono risolti relativamente al file *.txt). Un file *.txt è utile per addestrare su un sottoinsieme di una directory, ignorare le immagini senza etichette o combinare immagini provenienti da più fonti in un'unica suddivisione.
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(Facoltativo) colors assegna a ciascuna classe un colore di visualizzazione sotto forma di stringa "#rrggbb" tra virgolette, indicizzata per ID della classe, ad esempio colors: ["#042aff", "#ff0000"]. I modelli addestrati ed esportati mantengono questi colori nelle predizioni; le classi senza un colore assegnato usano la palette predefinita. Un record di un dataset NDJSON può contenere lo stesso campo colors.
Le etichette per questo formato devono essere esportate nel formato YOLO con un file *.txt per immagine. Se un'immagine non contiene oggetti, non è necessario alcun file *.txt. Il file *.txt deve essere formattato con una riga per oggetto nel formato class x_center y_center width height. Le coordinate del riquadro di delimitazione devono essere nel formato xywh normalizzato (da 0 a 1). Se i riquadri sono espressi in pixel, dividi x_center e width per la larghezza dell'immagine, e y_center e height per l'altezza dell'immagine. Le coordinate si riferiscono all'immagine così come viene visualizzata, con il suo orientamento EXIF applicato, ovvero nel modo in cui Ultralytics legge ogni immagine. I numeri delle classi devono partire da zero (iniziare da 0).

Il file delle etichette corrispondente all'immagine qui sopra contiene 2 persone (classe 0) e una cravatta (classe 27):

Quando usi il formato Ultralytics YOLO, organizza le immagini e le etichette di addestramento e validazione come mostrato nell'esempio del dataset COCO8 qui sotto.

Esempio d'uso#
Ecco come puoi usare i dataset in formato YOLO per addestrare il tuo modello:
from ultralytics import YOLO
# Carica un modello
model = YOLO("yolo26n.pt") # carica un modello preaddestrato (consigliato per l'addestramento)
# Addestra il modello
results = model.train(data="coco8.yaml", epochs=100, imgsz=640)Formato Ultralytics NDJSON#
Il formato NDJSON (JSON delimitato da newline) offre un modo alternativo per definire dataset per i modelli Ultralytics YOLO. Questo formato memorizza i metadati e le annotazioni del dataset in un unico file, dove ogni riga contiene un oggetto JSON distinto.
Un file di dataset NDJSON contiene:
- Record del dataset (prima riga): contiene i metadati del dataset, inclusi il tipo di attività, i nomi delle classi e le informazioni generali
- Record delle immagini (righe successive): contengono i dati delle singole immagini, incluse dimensioni, annotazioni e percorsi dei file
{
"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"
}Metadati personalizzati delle immagini#
Ogni record di immagine può includere un oggetto JSON metadata per fornire informazioni specifiche dell'applicazione, come le condizioni di acquisizione, gli identificativi delle apparecchiature o lo stato della revisione. Sono supportati valori annidati. Quando importi i dati in Ultralytics Platform, i metadati vengono salvati insieme all'immagine e puoi visualizzarli o modificarli dal pannello informativo a schermo intero.
{
"type": "image",
"file": "airbus-wing.jpg",
"url": "https://example.com/airbus-wing.jpg",
"split": "train",
"metadata": {
"aircraft": { "family": "A350", "section": "wing" },
"inspectionStatus": "reviewed"
}
}Platform limita le chiavi dei metadati di primo livello a 128 caratteri, l'oggetto dei metadati serializzato di ogni immagine a 500.000 caratteri e i metadati effettivi combinati di una singola importazione NDJSON a 500.000 caratteri.
Esempio d'uso#
Per usare un dataset NDJSON con YOLO26, basta specificare il percorso del file .ndjson:
from ultralytics import YOLO
# Carica un modello
model = YOLO("yolo26n.pt")
# Addestra usando un dataset NDJSON
results = model.train(data="path/to/dataset.ndjson", epochs=100, imgsz=640)Vantaggi del formato NDJSON#
- File singolo: tutte le informazioni del dataset sono contenute in un unico file
- Elaborazione in streaming: consente di elaborare dataset di grandi dimensioni riga per riga senza caricare tutto in memoria
- Integrazione con il cloud: supporta URL di immagini remote per l'addestramento basato sul cloud
- Estensibilità: è facile aggiungere campi di metadati personalizzati
- Controllo delle versioni: il formato a file singolo è adatto a git e ai sistemi di controllo delle versioni
Dataset supportati#
Ecco un elenco dei dataset supportati, ciascuno con una breve descrizione. La maggior parte di questi dataset è disponibile anche su Ultralytics Platform, dove puoi esplorare immagini e annotazioni, consultare le statistiche dei dataset e clonarli per l'addestramento nel cloud.
- African-wildlife: un dataset con immagini della fauna selvatica africana, tra cui bufali, elefanti, rinoceronti e zebre.
- Argoverse: il dataset di rilevamento 2D Argoverse-HD, composto da 54.446 immagini urbane per la guida autonoma, suddivise in 8 classi di oggetti stradali.
- Tumore cerebrale: un dataset per rilevare tumori cerebrali in immagini di risonanza magnetica cerebrale, etichettati con riquadri delimitatori dei tumori in un'unica classe.
- COCO: Oggetti comuni nel contesto (COCO) è un dataset su larga scala per il rilevamento e la segmentazione di oggetti e la generazione di didascalie, con 80 categorie di oggetti.
- COCO8: Un sottoinsieme ridotto delle prime 8 immagini di COCO train2017, di cui 4 per l'addestramento e 4 per la convalida, adatto a test rapidi.
- COCO8-Grayscale: Una versione in scala di grigi di COCO8, ottenuta convertendo RGB in scala di grigi, utile per valutare modelli a canale singolo.
- COCO8-Multispectral: Una versione multispettrale a 10 canali di COCO8, ottenuta interpolando le lunghezze d'onda RGB, utile per valutare modelli sensibili allo spettro.
- COCO12-Formats: un dataset di test con 12 immagini, ciascuna in uno dei 12 formati supportati (AVIF, BMP, DNG, HEIC, JP2, JPEG, JPG, MPO, PNG, TIF, TIFF, WebP), per convalidare le pipeline di caricamento delle immagini.
- COCO16: un sottoinsieme delle prime 16 immagini di COCO train2017 (8 per l'addestramento + 8 per la validazione), adatto a test rapidi.
- COCO32: un sottoinsieme delle prime 32 immagini di COCO train2017 (16 per l'addestramento + 16 per la validazione), adatto a test rapidi.
- COCO64: un sottoinsieme delle prime 64 immagini di COCO train2017 (32 per l'addestramento + 32 per la validazione), adatto a test rapidi.
- COCO128: Un sottoinsieme ridotto delle prime 128 immagini di COCO train2017, adatto ai test.
- Construction-PPE: un dataset con operai nei cantieri e dispositivi di protezione individuale annotati, come caschi, giubbotti, guanti, stivali e occhiali; include annotazioni relative ai dispositivi mancanti, come no_helmet e no_goggle, per il monitoraggio della conformità in contesti reali.
- Global Wheat 2020: Un dataset con immagini di spighe di grano per la sfida Global Wheat Challenge 2020.
- HomeObjects-3K: un dataset di oggetti domestici da interni, tra cui letti, sedie, TV e altro, ideale per applicazioni di domotica, robotica, realtà aumentata e analisi della disposizione degli ambienti.
- KITTI: un dataset con scene di guida reali e dati stereo, LiDAR e GPS/IMU, usato qui per attività di rilevamento 2D degli oggetti, come l'identificazione di automobili, pedoni e ciclisti in ambienti urbani, rurali e autostradali.
- LVIS: Un dataset su larga scala per il rilevamento di oggetti e la segmentazione di istanze, con 1.203 categorie di oggetti.
- Medical-pills: un dataset con immagini di pillole, annotate per applicazioni quali il controllo di qualità farmaceutico, lo smistamento delle pillole e la conformità normativa.
- Objects365: un dataset di alta qualità e su larga scala per il rilevamento degli oggetti, con 365 categorie di oggetti e oltre 1,7 milioni di immagini di addestramento.
- OpenImagesV7: Un dataset completo di Google con 1,7 milioni di immagini di addestramento e 42.000 immagini di convalida.
- Roboflow 100: un benchmark diversificato per il rilevamento degli oggetti, con 100 dataset che coprono sette domini di immagini per una valutazione completa dei modelli.
- Signature: Un dataset con immagini di vari documenti e firme annotate, a supporto della ricerca sulla verifica documentale e sul rilevamento delle frodi.
- SKU-110K: Un dataset dedicato al rilevamento di oggetti in ambienti di vendita al dettaglio ad alta densità, con oltre 11.000 immagini e 1,7 milioni di riquadri di delimitazione.
- TT100K: il dataset di segnali stradali Tsinghua-Tencent 100K (TT100K), con 16.817 immagini di strade appartenenti a 221 categorie di segnali, per attività di rilevamento e classificazione.
- Ultralytics Benchmark: una suite di benchmark proprietaria basata su 37 dataset di rilevamento selezionati in ambito medico, aereo, industriale, della vendita al dettaglio e in altri settori, con un protocollo fisso per misurare la generalizzazione dei modelli nel mondo reale.
- VisDrone: Un dataset con dati di rilevamento di oggetti e tracking multi-oggetto da immagini e sequenze video riprese da droni, con oltre 10.000 immagini.
- VOC: il dataset Pascal Visual Object Classes (VOC) per il rilevamento e la segmentazione degli oggetti, con 20 classi di oggetti e oltre 11K immagini.
- xView: Un dataset per il rilevamento di oggetti in immagini aeree, con 60 categorie di oggetti e oltre 1 milione di oggetti annotati.
Aggiungere il tuo dataset#
Se hai un tuo dataset e vuoi usarlo per addestrare modelli di rilevamento con il formato Ultralytics YOLO, assicurati che rispetti il formato specificato sopra nella sezione "Formato Ultralytics YOLO". Converti le annotazioni nel formato richiesto e specifica i percorsi, il numero di classi e i nomi delle classi nel file di configurazione YAML.
Trasferire o convertire i formati delle etichette#
Formato del dataset COCO nel formato YOLO#
Puoi convertire le etichette dal formato del popolare dataset COCO al formato YOLO utilizzando il seguente frammento di codice:
from ultralytics.data.converter import convert_coco
convert_coco(labels_dir="path/to/coco/annotations/")Questo strumento di conversione può essere usato per convertire il dataset COCO o qualsiasi dataset nel formato COCO nel formato Ultralytics YOLO. Il processo trasforma le annotazioni COCO basate su JSON nel più semplice formato YOLO basato su testo, rendendole compatibili con i modelli Ultralytics YOLO. Per il flusso di lavoro completo — inclusi la mappatura degli ID delle classi, la struttura delle directory e le annotazioni di segmentazione o posa — consulta Convertire le annotazioni COCO in YOLO.
Ricordati di verificare che il dataset che vuoi usare sia compatibile con il tuo modello e rispetti le convenzioni di formato necessarie. I dataset formattati correttamente sono fondamentali per addestrare modelli di rilevamento degli oggetti efficaci.
E adesso?#
Una volta formattato il dataset, inizia ad addestrare il tuo modello. Non sai da quale modello preaddestrato iniziare? Confronta le opzioni nella famiglia di modelli YOLO26.
Domande frequenti#
Il formato Ultralytics YOLO è una configurazione strutturata per definire i dataset nei tuoi progetti di addestramento. Prevede l'impostazione dei percorsi delle immagini di addestramento, convalida e test e delle rispettive etichette. Ad esempio:
# 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.zipLe etichette vengono salvate in file
*.txt, uno per ogni immagine, formattati comeclass x_center y_center width heightcon coordinate normalizzate. Per una guida dettagliata, consulta l'esempio del dataset COCO8.Puoi convertire un dataset COCO nel formato YOLO usando gli strumenti di conversione Ultralytics. Ecco un metodo rapido:
from ultralytics.data.converter import convert_coco convert_coco(labels_dir="path/to/coco/annotations/")Questo codice converte le tue annotazioni COCO nel formato YOLO per consentirti di addestrare i modelli Ultralytics YOLO su di esse.
Ultralytics YOLO supporta un'ampia gamma di dataset, tra cui:
La pagina di ogni dataset fornisce informazioni dettagliate sulla struttura e sull'utilizzo, pensate per un addestramento efficiente di YOLO26. Esplora l'elenco completo nella sezione Dataset supportati.
Per iniziare ad addestrare un modello YOLO26, assicurati che il dataset sia formattato correttamente e che i percorsi siano definiti in un file YAML. Usa il seguente script per iniziare l'addestramento:
Esempiofrom ultralytics import YOLO model = YOLO("yolo26n.pt") # Carica un modello preaddestrato results = model.train(data="path/to/your_dataset.yaml", epochs=100, imgsz=640)Ultralytics mette a disposizione numerosi esempi e guide pratiche per utilizzare YOLO in diverse applicazioni. Visita il blog Ultralytics per casi di studio, tutorial dettagliati e testimonianze della community su rilevamento degli oggetti, segmentazione e altro. Per esempi specifici, consulta la pagina della modalità Predict nella documentazione.
Commenti54
Fai una domanda, condividi i tuoi risultati o aiuta qualcun altro.
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(modificato)@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(modificato)@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(modificato)@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(modificato)@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/.
