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

Training very small custom data in yolov5, load pre-trained weight and freeze some layers? #49

Closed
JunFang-NWPU opened this issue Jun 13, 2020 · 4 comments
Labels
enhancement New feature or request Stale

Comments

@JunFang-NWPU
Copy link

Hi,

If I have only a very small dataset, e.g., server hundred images for about ten classes. As suggested, i) I need to train my own data from the pre-trained weight, and ii) maybe I need to freeze some layers, for instance , the backbone, and only modify weight of other layers.

My questions are:
i) Are the above two methods are the best strategies to deal with training very small dataset?
ii) How to freeze some layers of the yolov5?

Thanks.

@JunFang-NWPU JunFang-NWPU added the enhancement New feature or request label Jun 13, 2020
@github-actions
Copy link
Contributor

github-actions bot commented Jun 13, 2020

Hello @JunFang-NWPU, thank you for your interest in our work! Please visit our Custom Training Tutorial to get started, and see our Jupyter Notebook Open In Colab, Docker Image, and Google Cloud Quickstart Guide for example environments.

If this is a bug report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.

If this is a custom model or data training question, please note that Ultralytics does not provide free personal support. As a leader in vision ML and AI, we do offer professional consulting, from simple expert advice up to delivery of fully customized, end-to-end production solutions for our clients, such as:

  • Cloud-based AI systems operating on hundreds of HD video streams in realtime.
  • Edge AI integrated into custom iOS and Android apps for realtime 30 FPS video inference.
  • Custom data training, hyperparameter evolution, and model exportation to any destination.

For more information please visit https://www.ultralytics.com.

@glenn-jocher
Copy link
Member

@JunFang-NWPU for training very small datasets, my number one recommendation is to not train, and instead collect more training data. The chances of your results generalizing well are not good.

If you want to continue training with a small dataset, then simply start from pretrained weights and train normally. --adam sometimes helps smaller datasets as well, though it generally benefits from a smaller learning rate than SGD, so if you use it I would reduce your hyps['lr0'] by 10 (though I have not tested it yet in this repo, so anything might happen).

python train.py --cfg yolov5s.yaml --weights yolov5s.pt

I always advise against freezing any layers. I've made this point many times before in ultralytics/yolov3, and the same applies here. If you still want to freeze layers, you can simply set the requires_grad of any parameters you want to freeze to False.

@JunFang-NWPU
Copy link
Author

OK, Thanks. I will give a try.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 1, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Stale
Projects
None yet
Development

No branches or pull requests

2 participants