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

code for the yaml file #13515

Open
1 task done
rmarkovic00 opened this issue Feb 19, 2025 · 3 comments
Open
1 task done

code for the yaml file #13515

rmarkovic00 opened this issue Feb 19, 2025 · 3 comments
Labels
question Further information is requested

Comments

@rmarkovic00
Copy link

Search before asking

Question

Hi, I'm trying to pre-train the yolov5m model downloaded from the ultralitics site on my custom dataset which has 3 classes: car,truck person. Is it necessary to match the class ID with the class ID of the coco dataset in yaml file? For example:

yaml file:
train: /path_to_train_images/
val: /path_to_val_images/

nc: 8 # Broj klasa od 0 do 7 (moraš uključiti sve klase do najvećeg ID-a!)

names: ["Person", "Unknown", "Car", "Unknown", "Unknown", "Unknown", "Unknown", "Truck"]

or its just okej like this:

yaml file:
train: /path_to_train_images/
val: /path_to_val_images/

nc: 8

names: ["Person", "Unknown", "Car", "Unknown", "Unknown", "Unknown", "Unknown", "Truck"]

because in coco dataset person has ID=0 car=2 and truck=7.

Additional

No response

@rmarkovic00 rmarkovic00 added the question Further information is requested label Feb 19, 2025
@UltralyticsAssistant
Copy link
Member

👋 Hello @rmarkovic00, thank you for your interest in YOLOv5 🚀 and for your question regarding custom dataset configuration!

It looks like you're trying to set up your YAML file for training YOLOv5 on a custom dataset. Here's some general guidance:

  • For custom training questions, it's important to ensure your dataset and YAML configuration are properly set up. The names in the YAML file should correspond to the classes in your dataset, and their indices (IDs) should match the order in which they appear in the names list, rather than aligning with COCO class IDs. YOLOv5 does not require any alignment with COCO for custom datasets. Please ensure your dataset annotations are consistent with your names list.

If this is a 🐛 Bug Report, we kindly ask you to provide a minimum reproducible example (MRE), including details on reproducible YAML configurations, relevant code snippets, debugging logs, and any other information to help us diagnose the issue more effectively 🚀.

Additional Resources

Please also refer to our ⭐️ Tutorials for more guidance:

Requirements

Your environment should meet the following:

To verify installation, run:

git clone https://github.com/ultralytics/yolov5  # clone
cd yolov5
pip install -r requirements.txt  # install

Verified Environments

YOLOv5 supports the following environments for training and running models:

Status

To check current CI status, click below:
YOLOv5 CI
If the badge is green, all YOLOv5 Continuous Integration (CI) tests are passing ✅.

An Ultralytics engineer will assist you as soon as possible. Let us know if you have additional questions in the meantime! 😊

@rmarkovic00
Copy link
Author

Thank you very much!

@sriram-dsl
Copy link

@rmarkovic00 When creating a custom dataset, there is no need to align your custom classes with COCO classes.

You can define your own class names and structure, such as:

nc: 3  
names: [person, car, truck]  # or [car, person, truck] or [truck, person, car] – the order doesn't matter  

However, you must ensure that the labeling data is correctly aligned with the class names in your dataset.

For example, if your labels are:

0: person  
1: car  
2: truck  

Then, the names should be:

names: [person, car, truck]

Any CNN or ML model does not directly deal with class names—it only uses them for one-hot encoding and for human readability.

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

No branches or pull requests

3 participants