Closed harrytrinh2 closed 3 years ago
π Hello @TrinhDinhPhuc, thank you for your interest in π YOLOv5! Please visit our βοΈ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.
If this is a π Bug Report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.
If this is a custom training β Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available.
For business inquiries or professional support requests please visit https://www.ultralytics.com or email Glenn Jocher at glenn.jocher@ultralytics.com.
Python 3.8 or later with all requirements.txt dependencies installed, including torch>=1.7
. To install run:
$ pip install -r requirements.txt
YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), testing (test.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit.
I did follow the tutorial and clone a fresh yolov5 to train with my custom dataset. I got that error on the first run
@TrinhDinhPhuc your console output shows you are out of date by 14 commits so before you do anything else you should update your code with git pull or git clone again. Then once you do that I would follow the Train Custom Data tutorial closely to resolve your issue.
@glenn-jocher Thank you for your reply. I did use the latest yolov5 version but still got the error!
@TrinhDinhPhuc the error message says 'no labels found'. This means that YOLOv5 training did not find any labels for your dataset. Your data paths or data.yaml may be set up incorrectly. Make sure you follow the COCO128 example and organize your directories exactly as in the tutorial: https://docs.ultralytics.com/yolov5/tutorials/train_custom_data
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I have the same problem
@VITEK-THE-BEST π Hello! Thanks for asking about YOLOv5 π dataset formatting. To train correctly your data must be in YOLOv5 format. Please see our Train Custom Data tutorial for full documentation on dataset setup and all steps required to start training your first model. A few excerpts from the tutorial:
COCO128 is an example small tutorial dataset composed of the first 128 images in COCO train2017. These same 128 images are used for both training and validation to verify our training pipeline is capable of overfitting. data/coco128.yaml, shown below, is the dataset config file that defines 1) the dataset root directory path
and relative paths to train
/ val
/ test
image directories (or *.txt files with image paths), 2) the number of classes nc
and 3) a list of class names
:
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: ../datasets/coco128 # dataset root dir
train: images/train2017 # train images (relative to 'path') 128 images
val: images/train2017 # val images (relative to 'path') 128 images
test: # test images (optional)
# Classes
nc: 80 # number of classes
names: [ 'person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light',
'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow',
'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee',
'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard',
'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple',
'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch',
'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone',
'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear',
'hair drier', 'toothbrush' ] # class names
After using a tool like Roboflow Annotate to label your images, export your labels to YOLO format, with one *.txt
file per image (if no objects in image, no *.txt
file is required). The *.txt
file specifications are:
class x_center y_center width height
format.x_center
and width
by image width, and y_center
and height
by image height.The label file corresponding to the above image contains 2 persons (class 0
) and a tie (class 27
):
Organize your train and val images and labels according to the example below. YOLOv5 assumes /coco128
is inside a /datasets
directory next to the /yolov5
directory. YOLOv5 locates labels automatically for each image by replacing the last instance of /images/
in each image path with /labels/
. For example:
../datasets/coco128/images/im0.jpg # image
../datasets/coco128/labels/im0.txt # label
Good luck π and let us know if you have any other questions!
I have the same problem, so it can not be solved?
I have the same problem
Hi, bro. Have you solved this problem,thanks
Hi bro, have you solved this problem
π Hello! Thanks for asking about YOLOv5 π dataset formatting. To train correctly your data must be in YOLOv5 format. Please see our Train Custom Data tutorial for full documentation on dataset setup and all steps required to start training your first model. A few excerpts from the tutorial:
COCO128 is an example small tutorial dataset composed of the first 128 images in COCO train2017. These same 128 images are used for both training and validation to verify our training pipeline is capable of overfitting. data/coco128.yaml, shown below, is the dataset config file that defines 1) the dataset root directory path
and relative paths to train
/ val
/ test
image directories (or *.txt files with image paths) and 2) a class names
dictionary:
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: ../datasets/coco128 # dataset root dir
train: images/train2017 # train images (relative to 'path') 128 images
val: images/train2017 # val images (relative to 'path') 128 images
test: # test images (optional)
# Classes (80 COCO classes)
names:
0: person
1: bicycle
2: car
...
77: teddy bear
78: hair drier
79: toothbrush
After using a tool like Roboflow Annotate to label your images, export your labels to YOLO format, with one *.txt
file per image (if no objects in image, no *.txt
file is required). The *.txt
file specifications are:
class x_center y_center width height
format.x_center
and width
by image width, and y_center
and height
by image height.The label file corresponding to the above image contains 2 persons (class 0
) and a tie (class 27
):
Organize your train and val images and labels according to the example below. YOLOv5 assumes /coco128
is inside a /datasets
directory next to the /yolov5
directory. YOLOv5 locates labels automatically for each image by replacing the last instance of /images/
in each image path with /labels/
. For example:
../datasets/coco128/images/im0.jpg # image
../datasets/coco128/labels/im0.txt # label
Good luck π and let us know if you have any other questions!
I have the same problem
Hi, bro. Have you solved this problem,thanks
hello, have u solved it?
@zhitkoalina if you are encountering the error "No labels found" while training your custom dataset using YOLOv5, it means that the labels are not in the proper format or not properly configured in the data.yaml
file.
To resolve this issue, you can follow the steps mentioned in the Train Custom Data page. Specifically, make sure your labels follow the YOLO format, and your data.yaml
file is properly configured with the correct class names and label file paths.
If you still face issues, you can provide more details like the directory structure of your dataset, the contents of the data.yaml
file, and the exact command used for training.
I use the following command to configure my dataset and training.
python train.py --weights yolov5s.pt --cfg yolov5s.yaml --data "E:\ZZZ_Github\yolov5\My_Datasets\Footballs.v5i.yolov5pytorch\data.yaml" --epochs 100 --batch-size 8 --device 0
But it gave me the error for
FileNotFoundError: [Errno 2] No such file or directory: 'E:\\ZZZ_Github\\yolov5\\Datasets\\Footballs.v5i.yolov5pytorch\\data.yaml'
@FanDe-chen it looks like there might be a discrepancy in the path to your data.yaml file. Please ensure that the path to your data.yaml file is correctly specified and matches the actual directory structure.
Based on the error message you provided, it seems that the path to the data.yaml file is incorrect. Double-check the path and ensure that it is pointing to the correct location of the data.yaml file on your system.
If you continue to encounter issues, make sure the data.yaml file is accessible at the specified location and that the file name and path are accurate.
π Bug
I first run this command to train the model:
β°ββ― python train.py --img 640 --batch 8 --epoch 50 --data squareone_jusRol/squareone_jusRol.yaml --weight yolov5s.pt
How ever I cannot train model because
FileNotFoundError: [Errno 2] No such file or directory: 'squareone_jusRol/data/labels/train.cache'
Expected behavior
I don't know why I cannot train the model with my custom dataset. Please help