Closed sebabrzovic closed 7 months ago
👋 Hello @sebabrzovic, 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 a minimum reproducible example to help us debug it.
If this is a custom training ❓ Question, please provide as much information as possible, including dataset image examples and training logs, and verify you are following our Tips for Best Training Results.
Python>=3.8.0 with all requirements.txt installed including PyTorch>=1.8. To get started:
git clone https://github.com/ultralytics/yolov5 # clone
cd yolov5
pip install -r requirements.txt # install
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, validation, inference, export and benchmarks on macOS, Windows, and Ubuntu every 24 hours and on every commit.
We're excited to announce the launch of our latest state-of-the-art (SOTA) object detection model for 2023 - YOLOv8 🚀!
Designed to be fast, accurate, and easy to use, YOLOv8 is an ideal choice for a wide range of object detection, image segmentation and image classification tasks. With YOLOv8, you'll be able to quickly and accurately detect objects in real-time, streamline your workflows, and achieve new levels of accuracy in your projects.
Check out our YOLOv8 Docs for details and get started with:
pip install ultralytics
@sebabrzovic hello!
It seems like there might be an issue with your label files or their paths. Here are a few steps to troubleshoot this problem:
Check Label Files: Ensure that your label .txt
files are not empty and formatted correctly. Each line in a label file should represent one object and follow the format: <class> <x_center> <y_center> <width> <height>
, with values normalized between 0 and 1.
Paths in YAML: Verify that the paths in your logos.yaml
file are correct relative to the directory from which you're running the train.py
script.
No Background Labels: The error message indicates a large number of backgrounds (14234) and no labels. Ensure that your dataset does not contain label files with only the class 'background' or no objects.
Clear Cache: If you've made changes to your dataset or labels, clear the cache by deleting {train_data_path}\train_data\labels\train.cache
before running the training again.
Check Images and Labels Alignment: Make sure that for every image in the images/train/
directory, there is a corresponding label file in labels/train/
with the exact same filename (except for the file extension).
Permissions: Ensure that you have read/write permissions for the directories and files involved in the training process.
If you've checked all the above and the issue persists, consider sharing a snippet of your label file content for further assistance. Remember, the community is here to help!
@glenn-jocher Hey, thanks for your answer, today i checked all the posibilities, I doubled check my images, the labels, the backgrounds, and unfortunately none of them worked. Here is an image of how i have my files ordered and how i have my logos.yaml
Is there anything that I'm missing?
@sebabrzovic, thanks for the update and for checking those items.
From the information provided, it seems like your file structure and logos.yaml
appear to be correct. However, since the image you're trying to show isn't visible here, I can't confirm the exact setup.
Here are a few more things to consider:
Label File Content: Open a few .txt
label files and ensure they contain the correct object annotations. If they are empty or incorrectly formatted, the training process will not detect any labels.
File Naming: Confirm that the image files and label files have the exact same base filenames. For example, image1.png
should have a corresponding label file named image1.txt
.
YAML Content: Double-check the logos.yaml
content for any typos or formatting issues. The path
should be correct relative to where you're running the script, and the train
and val
should correctly point to the image folders.
Dataset Integrity: Use the val.py
script with the --task val
option to validate your dataset without training. This can help identify issues with the dataset.
Verbose Output: Run the training with the --verbose
flag to get more detailed output, which might help pinpoint the issue.
If you've gone through all these steps and the problem persists, you might want to share the content of one of your label files here for further inspection. Please ensure there's no sensitive information in the content you share.
@glenn-jocher I have a similar error:
Transferred 343/349 items from yolov5n.pt
AMP: checks passed ✅
optimizer: SGD(lr=0.01) with parameter groups 57 weight(decay=0.0), 60 weight(decay=0.0005), 60 bias
train: Scanning /home/aessawy/workspace/amiras/new/datasets/CV3/labels/train... 0 images, 21713 backgrounds, 0 corrupt: 100%|██████████| 21713/21713 [02:19<
train: WARNING ⚠️ No labels found in /home/aessawy/workspace/amiras/new/datasets/CV3/labels/train.cache. See https://docs.ultralytics.com/yolov5/tutorials/train_custom_data
train: WARNING ⚠️ Cache directory /home/aessawy/workspace/amiras/new/datasets/CV3/labels is not writeable: [Errno 2] No such file or directory: '/home/aessawy/workspace/amiras/new/datasets/CV3/labels/train.cache.npy'
Traceback (most recent call last):
File "train.py", line 836, in
I did the check steps you mentioned but the problem is still exist.
@amira-essawy, it looks like there are a couple of issues highlighted in the error message:
No Labels Found: The scan reports 0 images
and a large number of backgrounds, which indicates that it did not find any valid image-label pairs. Ensure that your image files in the images/train
directory have corresponding label files with the same base name in the labels/train
directory.
Write Permission: The warning about the cache directory not being writable suggests a file system permission issue. Make sure that the user running the train.py
script has the necessary permissions to read from and write to the /home/aessawy/workspace/amiras/new/datasets/CV3/labels
directory.
Here's what you can do next:
labels
directory with ls -l
and ensure you have write access. If not, use chmod
to modify the permissions..txt
files to ensure they are not empty and are correctly formatted.train
and val
paths point to the correct directories.--verbose
flag for more detailed output.If you've tried all the above and the issue still exists, please share the content of your dataset YAML file and a snippet from one of your label .txt
files for further assistance. Remember to exclude any sensitive information.
👋 Hello there! We wanted to give you a friendly reminder that this issue has not had any recent activity and may be closed soon, but don't worry - you can always reopen it if needed. If you still have any questions or concerns, please feel free to let us know how we can help.
For additional resources and information, please see the links below:
Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!
Thank you for your contributions to YOLO 🚀 and Vision AI ⭐
Search before asking
Question
Hello! Im having trouble trying to train with yolov5: I have my folders ordered in this manner:
train_data/ -logos.yaml images/ train/ -image1.png -image2.png val/ -image3.png -image4.png labels/ train/ -image1.txt -image2.txt val/ -image3.txt -image4.txt yolov5/
Now my logos.yaml is:
path: ../train_data train: images/train val: images/val
names: 0: first_object 1: 2nd_object
The problem is when i run this code : python train.py --img 640 --epochs 3 --data ../train_data/logos.yaml --weights yolov5m.pt --cache ram i get the same error:
Transferred 475/481 items from yolov5m.pt optimizer: SGD(lr=0.01) with parameter groups 79 weight(decay=0.0), 82 weight(decay=0.0005), 82 bias train: Scanning C:\Users\sebab\Documents\Seba\DCC\SEMESTRE_9\PRACTICA\train_data\labels\train... 1294 images, 14234 backgrounds, 0 corrupt: 100%|██████████| 14234/14234 [ train: New cache created: {train_data_path}\train_data\labels\train.cache Traceback (most recent call last): File "{yolo_path}\yolov5\train.py", line 836, in
main(opt)
File "{yolo_path}\yolov5\train.py", line 616, in main
train(opt.hyp, opt, device, callbacks)
File "{yolo_path}\yolov5\train.py", line 248, in train
train_loader, dataset = create_dataloader(
File "{yolo_path}\yolov5\utils\dataloaders.py", line 177, in create_dataloader
dataset = LoadImagesAndLabels(
File "{yolo_path}\yolov5\utils\dataloaders.py", line 574, in init
assert nl > 0 or not augment, f"{prefix} All labels empty in {cache_path}, can not start training. {HELP_URL}"
AssertionError: train: All labels empty in {train_data_path}\train_data\labels\train.cache, can not start training. See https://docs.ultralytics.com/yolov5/tutorials/train_custom_data
I've tried running the code withouth the cache but it gives me the same error,
Additional
I've tried everything down to the obviouse, I've tried rewriting my roots, checking my labels, checking whether i have the proper requeriments, tryinh from the begining in another directory, and nothing works. with any help i'd be grateful.