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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

When train my custom data, how to load pretrained model? It says not match with default weights. #43

Closed
h030162 opened this issue Jun 12, 2020 · 8 comments
Labels
question Further information is requested Stale

Comments

@h030162
Copy link

h030162 commented Jun 12, 2020

馃殌 Feature

Motivation

Pitch

Alternatives

Additional context

@h030162 h030162 added the enhancement New feature or request label Jun 12, 2020
@github-actions
Copy link
Contributor

github-actions bot commented Jun 12, 2020

Hello @h030162, 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

@h030162 can you supply code to reproduce your error please?

@glenn-jocher
Copy link
Member

glenn-jocher commented Jun 12, 2020

@h030162 I just tested this on our colab notebook, and everything works correctly. You can load up an 80 class model with pretrained weights if you are training on coco, or you can change the class count of your model and dataset as well. The only requirement is that the dataset and model class counts must match each other:

Dataset:

yolov5/data/coco128.yaml

Lines 14 to 15 in ad71d2d

# number of classes
nc: 80

Model:

# parameters
nc: 80 # number of classes

If you change nc, everything still works correctly. In this case the model will be composed of pretrained weights except for the output layers, which are no longer the same shape as the pretrained output layers. The output layers will remain initialized by random weights.

@h030162
Copy link
Author

h030162 commented Jun 15, 2020

./yolov5_checkpoint/yolov5_models/yolov5x.pt is not compatible with ./models/yolov5x.yaml. Specify --weights '' or specify a --cfg compatible with ./yolov5_checkpoint/yolov5_models/yolov5x.pt.

I just change yolov5x.yaml nc from 80 to 2. and change yaml file in data .nc from 80 to2. names:["dog", "cat"]

@glenn-jocher
Copy link
Member

glenn-jocher commented Jun 15, 2020

@h030162 I tested this again (a second time) in colab, and everything is still working fine. I updated yolov5x.yaml and coco128.yaml to 160 classes (duplicated the names to reach 160 names), and started training with the following command, all is correct with no problems.

python train.py --img 640 --batch 16 --epochs 5 --data ./data/coco128.yaml --cfg ./models/yolov5x.yaml --weights yolov5x.pt

See https://docs.ultralytics.com/yolov5/tutorials/train_custom_data

@glenn-jocher glenn-jocher added question Further information is requested and removed enhancement New feature or request labels Jun 15, 2020
@ou525
Copy link

ou525 commented Jun 15, 2020

@glenn-jocher I also have this problem

@glenn-jocher
Copy link
Member

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

@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
question Further information is requested Stale
Projects
None yet
Development

No branches or pull requests

3 participants