Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AssertionError: train: No labels found in /content/drive/MyDrive/Colab/Fishai-10/train/labels.cache, can not start training. #12548

Closed
1 task done
lpkpaco opened this issue Dec 23, 2023 · 13 comments
Labels
question Further information is requested Stale Stale and schedule for closing soon

Comments

@lpkpaco
Copy link

lpkpaco commented Dec 23, 2023

Search before asking

Question

I am currently using Google Colab and Roboflow to generate and train my dataset. However, I get this error message everytime when I start training.
I have looked up for solutions, like using !chmod to grant access, maintaining the directory structure etc. These methods did not work.
What should I do?
image

Here is the code that I used:
!chmod +w /content/drive/MyDrive/Colab/Fishai-10/train/labels !chmod +w /content/drive/MyDrive/Colab/Fishai-10/valid/labels !python /content/drive/MyDrive/Colab/yolov5/train.py --batch 100 --epochs 2000 --img 640 --data '/content/drive/MyDrive/Colab/Fishai-10/data.yaml' --weights yolov5s.pt --patience 100 from google.colab import runtime runtime.unassign()

And I get:
error_message.txt

Additional

No response

@lpkpaco lpkpaco added the question Further information is requested label Dec 23, 2023
Copy link
Contributor

github-actions bot commented Dec 23, 2023

👋 Hello @lpkpaco, 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.

Requirements

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

Environments

YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

YOLOv5 CI

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.

Introducing YOLOv8 🚀

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

@glenn-jocher
Copy link
Member

@lpkpaco hey there! It seems like the training process is unable to find any labels in the specified location. Here's what you can do to troubleshoot.

First, ensure that your label files are correctly located in the /content/drive/MyDrive/Colab/Fishai-10/train/labels.cache directory.

Next, check that the label files are in the correct format and contain the expected annotations.

Finally, make sure that the path to the label files is correctly specified in the data.yaml file.

Let me know if you need more help with this!

@lpkpaco
Copy link
Author

lpkpaco commented Dec 24, 2023

This is my data.yaml:
image

I think it is correct.
For more information, here are a few images for training and their label txt files:
Photo-2023-12-21-16-51-58_jpg rf 6ecd133bbbfd1eb26fcfd274c976a19e
IMG_6924_JPG rf 523331e9a276657f2fe07e2318ffaf25
Photo-2023-12-18-16-14-43_jpg rf 9ecfc7daa2f5abe2b679cd0aea08b484
Photo-2023-12-21-16-51-58_jpg.rf.6ecd133bbbfd1eb26fcfd274c976a19e.txt
IMG_6924_JPG.rf.523331e9a276657f2fe07e2318ffaf25.txt
Photo-2023-12-18-16-14-43_jpg.rf.9ecfc7daa2f5abe2b679cd0aea08b484.txt

And here is the labels.cache file (I couldn't drop it here in GitHub as the file type is not supported):
https://drive.google.com/file/d/1rZnvHzgIDU3V6UKioMNMido-vuEelXMx/view?usp=sharing

I don't know what's going wrong.
Thanks for your help.

@glenn-jocher
Copy link
Member

@lpkpaco your data.yaml configuration looks good. The label files and images are also in the correct format. However, I noticed that your labels are in ".txt" format, whereas the error message references "labels.cache".

YOLOv5 expects labels to be in the COCO JSON format or YOLO txt format. Therefore, you might want to check the label caching process in your training pipeline.

Let me know if you need further assistance!

Copy link
Contributor

👋 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 ⭐

@github-actions github-actions bot added the Stale Stale and schedule for closing soon label Jan 24, 2024
@lpkpaco
Copy link
Author

lpkpaco commented Jan 28, 2024

I found a solution but I don't know if it would work next time.
Apparently something is wrong while Roboflow is processing some data. I exported the file in COCO format first after resizing and auto-orientation and uploaded it to a new project then exported it without committing any pre-processing or augmentations. It seems to work again.
Thanks for your help anyways.

@lpkpaco lpkpaco closed this as completed Jan 28, 2024
@glenn-jocher
Copy link
Member

@lpkpaco I'm glad to hear you found a workaround by adjusting the data processing steps in Roboflow. It's possible that an issue during the preprocessing or augmentation stages could have affected the label files or their paths.

For future reference, if you encounter similar issues, consider verifying each step of the data preparation process to ensure consistency and correctness of the data format before training.

If you have any more questions or run into any other issues, feel free to reach out. Happy training! 🚀

@GreaterthanGreat
Copy link

I am experiencing the same issue. It says: "No labels found in /content/Train/Images/Backpack.cache, training may not work correctly" and "No labels found in /content/Test/Images/Backpack.cache" My image files and label files have the same name and are formatted correctly. Here is an image of the structure of my folders (I am using google colab).

Image

@lpkpaco
Copy link
Author

lpkpaco commented Jan 28, 2025

Hi @GreaterthanGreat,

I couldn’t locate why did that issue happen, probably has something to do with Colab and my Roboflow exporting process. My suggestion is: you can try yolov8 if using yolov5 is not a requirement for your project. I switched to yolov8 and such problems did not happen again. The support for v8 is also better.

@lpkpaco lpkpaco closed this as not planned Won't fix, can't repro, duplicate, stale Jan 28, 2025
@GreaterthanGreat
Copy link

Hi @GreaterthanGreat,

I couldn’t locate why did that issue happen, probably has something to do with Colab and my Roboflow exporting process. My suggestion is: you can try yolov8 if using yolov5 is not a requirement for your project. I switched to yolov8 and such problems did not happen again. The support for v8 is also better.

Thx for the advice

I was using Yolov11 originally. Just switched yolov8 and still got the same problem.

@pderrenger
Copy link
Member

If you're encountering the same issue with YOLOv8 after switching, the problem may lie in your dataset structure or export process. Double-check your dataset paths in the data.yaml file and ensure the labels directory contains .txt files with the correct YOLO format. Additionally, verify your dataset export settings in Roboflow to confirm compatibility. Refer to Ultralytics YOLOv8 Docs for dataset preparation guidance. Let me know if you need further clarification!

@GreaterthanGreat
Copy link

If you're encountering the same issue with YOLOv8 after switching, the problem may lie in your dataset structure or export process. Double-check your dataset paths in the data.yaml file and ensure the labels directory contains .txt files with the correct YOLO format. Additionally, verify your dataset export settings in Roboflow to confirm compatibility. Refer to Ultralytics YOLOv8 Docs for dataset preparation guidance. Let me know if you need further clarification!

My folder structure is the following.

Image

Could the problem be that I have more folders within the Images and Labels folder and that where my images and labels are stored?

@pderrenger
Copy link
Member

@GreaterthanGreat yes, the issue could be due to having subfolders within the Images and Labels directories. YOLO expects the images and their corresponding label .txt files to be directly under the respective folders specified in data.yaml. Ensure there are no nested subfolders, and all files are properly aligned. If subfolders are necessary, update the data.yaml paths to point to a .txt file listing all image paths instead. For more details, refer to the YOLO dataset structure guidelines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested Stale Stale and schedule for closing soon
Projects
None yet
Development

No branches or pull requests

4 participants