ultralytics / ultralytics

Ultralytics YOLO11 🚀
https://docs.ultralytics.com
GNU Affero General Public License v3.0
32.46k stars 6.24k forks source link

Remove/add class from yolo11n.pt #17459

Open Andy2139 opened 2 days ago

Andy2139 commented 2 days ago

Search before asking

Question

Hello, I am a very new user to Ultralytics and YOLO, and I am getting started using YOLO v11. I am able to install and use the pre-trained model yolo11n.pt and use the coco8 data set to train and validate the model. I am also able to get the model identifying objects in my own images. However, I would like it to identify additional objects that are not in the standard 80 classes of the coco dataset.

As soon as I change the classes in the coco.yaml file in any way (even just removing a single class) and then do model.train on the .yaml file, the model is no longer able to detect any objects in any image. Am I doing something wrong? Is it losing all it's pre-training because of the class being removed? Any other helpful tips are appreciated.

Thank you!

Additional

No response

UltralyticsAssistant commented 2 days ago

👋 Hello @Andy2139, thank you for your interest in Ultralytics 🚀! We recommend visiting our comprehensive Docs for new users, which provides many Python and CLI usage examples. Many common questions are addressed there, so it's a great place to start.

If this is a 🐛 Bug Report, you can help us debug it by providing a minimum reproducible example.

Since your question involves custom training and dataset manipulation, please ensure you have followed the steps in our Tips for Best Training Results. Providing information such as dataset image examples and training logs can also be invaluable.

For engaging with the Ultralytics community, you have plenty of options! Join us for real-time chat on Discord 🎧. If you prefer in-depth discussions, we welcome you to our Discourse. Or you can share and learn with peers in active threads on our Subreddit.

Upgrade

To make sure your issue isn't already resolved in the latest version, upgrade to the newest ultralytics package and ensure all requirements are met in a Python>=3.8 environment, with PyTorch>=1.8:

pip install -U ultralytics

Environments

YOLO models can be run in various up-to-date environments. These environments come pre-installed with essential dependencies like CUDA, Python, and PyTorch:

Status

Ultralytics CI

If the badge is green, all Ultralytics CI tests are currently passing. These tests verify the correct operation of all YOLO Modes and Tasks on macOS, Windows, and Ubuntu every 24 hours and on every commit.

This is an automated response to guide you, but rest assured that an Ultralytics engineer will be along to assist you more personally soon! 😊

Y-T-G commented 2 days ago

It will always forget the classes if you don't have the original classes and images for the original classes in your dataset.

https://github.com/ultralytics/ultralytics/issues/5126#issuecomment-2405896842

Andy2139 commented 2 days ago

It will always forget the classes if you don't have the original classes and images for the original classes in your dataset.

#5126 (comment)

Ah okay thank you, what about when adding a new class? That seems to have the same effect.

Y-T-G commented 2 days ago

You can't add a class without a dataset containing images of all the classes including the existing ones.

Andy2139 commented 1 day ago

You can't add a class without a dataset containing images of all the classes including the existing ones.

So you have to re-train it for all classes?

Y-T-G commented 1 day ago

Yeah