-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Loosing the pretrained model weights when using a new data to retrain the already trained model. #12666
Comments
👋 Hello @SIDD-1991, thank you for your interest in Ultralytics YOLOv8 🚀! We recommend a visit to the Docs for new users where you can find many Python and CLI usage examples and where many of the most common questions may already be answered. 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. Join the vibrant Ultralytics Discord 🎧 community for real-time conversations and collaborations. This platform offers a perfect space to inquire, showcase your work, and connect with fellow Ultralytics users. InstallPip install the pip install ultralytics EnvironmentsYOLOv8 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
StatusIf this badge is green, all Ultralytics CI tests are currently passing. CI tests verify correct operation of all YOLOv8 Modes and Tasks on macOS, Windows, and Ubuntu every 24 hours and on every commit. |
It sounds like you're dealing with a mix-up in training tasks using the YOLOv8 models. Here’s how you can address this: When you initially train a detection model with To train for segmentation after initially training for detection, you need to ensure that the model configuration file (i.e., the YAML file) and your specified training task are aligned with segmentation. You should check that your YAML configuration aligns with segmentation requirements, especially the last layers and their configurations. If your YAML configuration ends with a detect layer when it should be set up for segmentation, you'll need to adjust the architecture in the YAML to have segmentation-specific layers. Make sure these configurations reflect the need to output masks and not just bounding boxes. Here's a brief example how you might adjust your training call to switch tasks correctly: model = YOLO('stf-yolov8.yaml') # Ensure this YAML is set up for segmentation
results = model.train(data='your_segmentation_dataset.yaml', task='segment') Make sure that 'your_segmentation_dataset.yaml' is set up correctly for segmentation tasks, including paths to images and their corresponding masks. Changing the |
I have a model that I already trained to distinguish between two classes and it work's fine however when I try to train that model using new data just for one class it seems to loose all the metrics of the other class and is unable to recognize the former class. model = YOLO("best.pt") This new data only contains one class for example the pretrained model had data for cats and dogs and now I try to retrain it with more images of dogs. Note the images size of the original training set was 128x128 and the new images of dogs are 640x640 is that makes any difference |
To be honest i don't think you should be posting this as a comment this is a question it's better you raise a new thread so that if other's have the same issue they can easily identify in the search results |
i got from some forum that if i retrain the model with new data it will forget the old one so the correct way is to retrain with the new data added to previous data. model = YOLO("best.pt") or mode = YOLO("yolov8m.pt") would there be any difference in training accuracy like the already trained model when retrained with same data and some additional data would it be better in any way than just using the new fresh model? |
You're right in thinking that retraining a model on new data without the old data will cause it to forget the previously learned classes—a phenomenon known as "catastrophic forgetting." To preserve previous learning while incorporating new data, you should combine both old and new datasets in the retraining process. Regarding your question on using
In summary, using |
will using best.pt be any faster I mean could I work with less epoch's if I use best.pt rather than starting from scratch? |
Absolutely! Using model = YOLO("best.pt")
results = model.train(data='new_train.yaml', epochs=5) # Fewer epochs might be sufficient Just make sure to monitor the performance to ensure the model is still improving and not overfitting. Happy training! 😊 |
Search before asking
Question
I have a model that I already trained to distinguish between two classes and it work's fine however when I try to train that model using new data just for one class it seems to loose all the metrics of the other class and is unable to recognize the former class.
model = YOLO("best.pt")
results = model.train(pretrained = True, data='train.yaml', epochs=10)
This new data only contains one class for example the pretrained model had data for cats and dogs and now I try to retrain it with more images of dogs.
When I do that it is unable to recognize the cats.
Additional
No response
The text was updated successfully, but these errors were encountered: