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

When you receive new data, is it good practice to train the previously trained model only with these new data? Would training a new model with all the data yield better results? What is the most appropriate practice? #13107

Open
1 task done
RichterV opened this issue Jun 19, 2024 · 4 comments
Labels
question Further information is requested

Comments

@RichterV
Copy link

RichterV commented Jun 19, 2024

Search before asking

Question

Considering that I am training a model with images that I already have. If I obtain new images, should I train the new images with the model previously trained, or should I use a new model to train with all the images I currently have? Could training a previously trained model only with the new images bias the model?

What is the most appropriate practice?

Additional

Just to add, I'm training object detection models with YOLO and receive new images every month. I'm not sure whether it's correct to retrain everything or just train with the new images.

@RichterV RichterV added the question Further information is requested label Jun 19, 2024
Copy link
Contributor

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

@RichterV hello,

Thank you for your question and for providing detailed context! When it comes to incorporating new data into your model training process, there are a few strategies you can consider:

  1. Fine-Tuning with New Data: You can continue training your previously trained model with the new data. This approach, known as fine-tuning, can be effective if the new data is similar to the original dataset. However, if the new data is significantly different, this might lead to overfitting on the new data and potentially degrade the model's performance on the original data.

  2. Training from Scratch with All Data: This approach involves combining your original dataset with the new data and training a new model from scratch. This method ensures that the model learns from the entire dataset, which can help maintain a balanced performance across all data. While this can be more computationally intensive, it often yields better results as the model can generalize better.

  3. Incremental Learning: This is a more advanced approach where the model is designed to learn incrementally from new data without forgetting the previously learned information. This requires more sophisticated techniques and is not natively supported by YOLOv5, but it can be implemented with additional effort.

Best Practice Recommendation

For most use cases, especially if you receive new data regularly, the best practice would be to retrain the model from scratch with all available data. This ensures that the model maintains a comprehensive understanding of the entire dataset, reducing the risk of bias towards newer data.

Practical Steps

  1. Combine Datasets: Merge your original dataset with the new data.
  2. Retrain the Model: Train a new model using the combined dataset.
  3. Evaluate Performance: Ensure to evaluate the model's performance on a validation set that includes both old and new data to confirm that it generalizes well.

Here is a simple example of how you might combine datasets and retrain:

# Assuming you have your original dataset and new dataset directories
original_data_path = 'path/to/original/data'
new_data_path = 'path/to/new/data'

# Combine datasets (this is a simplified example, ensure proper dataset management)
combined_data_path = 'path/to/combined/data'
os.system(f'cp -r {original_data_path}/* {combined_data_path}')
os.system(f'cp -r {new_data_path}/* {combined_data_path}')

# Train the model with the combined dataset
!python train.py --data combined_data.yaml --cfg yolov5s.yaml --weights '' --epochs 100

If you have any further questions or need additional assistance, feel free to ask. The YOLO community and the Ultralytics team are here to help!

@RichterV
Copy link
Author

Thanks for your answer, it helps a lot!

@glenn-jocher
Copy link
Member

Hello @RichterV,

Thank you for your kind words! I'm glad to hear that the information was helpful to you. 😊

If you have any further questions or run into any issues, please don't hesitate to reach out. The YOLO community and the Ultralytics team are always here to assist you. Remember, for the best training results, it's crucial to ensure your dataset is well-labeled and sufficiently large, and to start with the default settings to establish a performance baseline.

If you encounter any bugs or issues, please provide a minimum reproducible code example so we can investigate effectively. You can find more details on how to create one here: Minimum Reproducible Example. Additionally, make sure you are using the latest versions of torch and YOLOv5 from our GitHub repository.

Good luck with your training, and feel free to share your results or any further questions you might have!

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

2 participants