You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched the YOLOv5 issues and discussions and found no similar questions.
Question
Hi there,
I simply want to train two-classification model, such as cat and dog, or 0 and 1.
so that I want to use branch classifer with out pretrained model.
I found that the classifier.py will load pretrained torchhub model anyway, is there any method to disable loading pretrained model and ?
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 training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available.
YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), validation (val.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit.
@hrnbot thanks for answer man~
But in branch classifier, the pythonfile classifier.py is used to train a classifer instead of train.py, and there's not an option --weights in classifier.py ,the model is initing by torch hub.load.
The train.py in this branch still contain the conception of anchor, but u known the classifer should not contain anchor like detector does, so I guess the train.py could not be used in this branch.
using model yolov5s
if i change the option pretrained = false ,there will be some urlerror occur[connection timed out].
maybe i should check my connection first
ok ,there's no more url error
it shows that Exception: Cache may be out of date, try force_reload=True by loading model model = torch.hub.load('ultralytics/yolov5', opt.model, autoshape=False ,pretrained=False)
@junyuancat1 good news 😃! Your original issue may now be fixed ✅ in PR #5966. You can now pass pretrained=False when loading YOLOv5 PyTorch Hub models.
To receive this update:
Git – git pull from within your yolov5/ directory or git clone https://github.com/ultralytics/yolov5 again
PyTorch Hub – Force-reload model = torch.hub.load('ultralytics/yolov5', 'yolov5s', force_reload=True)
Docker – sudo docker pull ultralytics/yolov5:latest to update your image
Thank you for spotting this issue and informing us of the problem. Please let us know if this update resolves the issue for you, and feel free to inform us of any other issues you discover or feature requests that come to mind. Happy trainings with YOLOv5 🚀!
@glenn-jocher awsome!The classifier branch already contains model configs(model.yaml) . Since i need no pretrain,so I just temporarily using Model(cfg,ch,cn) to construct a model instead of loading from pytorch hub, It works for me.
I'll try using pretrained=false to fix my issue. Thanks for such an precise and fast debug!
Activity
github-actions commentedon Dec 13, 2021
👋 Hello @junyuancat1, 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 screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.
If this is a custom training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available.
For business inquiries or professional support requests please visit https://ultralytics.com or email Glenn Jocher at glenn.jocher@ultralytics.com.
Requirements
Python>=3.6.0 with all requirements.txt installed including PyTorch>=1.7. To get started:
$ git clone https://github.com/ultralytics/yolov5 $ cd yolov5 $ pip install -r requirements.txtEnvironments
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
If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), validation (val.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit.
hrnbot commentedon Dec 13, 2021
@junyuancat1 you can use --weights '' " to start learning from scratch.
junyuancat1 commentedon Dec 13, 2021
@hrnbot thanks for answer man~
But in branch classifier, the pythonfile classifier.py is used to train a classifer instead of train.py, and there's not an option --weights in classifier.py ,the model is initing by torch hub.load.
The train.py in this branch still contain the conception of anchor, but u known the classifer should not contain anchor like detector does, so I guess the train.py could not be used in this branch.
junyuancat1 commentedon Dec 13, 2021
using model yolov5s
if i change the option pretrained = false ,there will be some urlerror occur[connection timed out].
maybe i should check my connection first
junyuancat1 commentedon Dec 13, 2021
ok ,there's no more url error
it shows that Exception: Cache may be out of date, try
force_reload=Trueby loading modelmodel = torch.hub.load('ultralytics/yolov5', opt.model, autoshape=False ,pretrained=False)glenn-jocher commentedon Dec 13, 2021
@junyuancat1 I'm able to reproduce a
pretrained=Falseerror. I will investigate today.[-]How to use classifier without pretrained model[/-][+]`pretrained=False` bug[/+]`pretriained=False` fix
`pretrained=False` fix (#5966)
glenn-jocher commentedon Dec 13, 2021
@junyuancat1 good news 😃! Your original issue may now be fixed ✅ in PR #5966. You can now pass
pretrained=Falsewhen loading YOLOv5 PyTorch Hub models.To receive this update:
git pullfrom within youryolov5/directory orgit clone https://github.com/ultralytics/yolov5againmodel = torch.hub.load('ultralytics/yolov5', 'yolov5s', force_reload=True)sudo docker pull ultralytics/yolov5:latestto update your imageThank you for spotting this issue and informing us of the problem. Please let us know if this update resolves the issue for you, and feel free to inform us of any other issues you discover or feature requests that come to mind. Happy trainings with YOLOv5 🚀!
junyuancat1 commentedon Dec 14, 2021
@glenn-jocher awsome!The classifier branch already contains model configs(model.yaml) . Since i need no pretrain,so I just temporarily using Model(cfg,ch,cn) to construct a model instead of loading from pytorch hub, It works for me.
I'll try using pretrained=false to fix my issue. Thanks for such an precise and fast debug!
glenn-jocher commentedon Dec 14, 2021
@junyuancat1 great! Yes you can also construct a model the way you show.
Update Neuralmagic-YoloV5 integration to v6.1 (#29)
`pretrained=False` fix (ultralytics#5966)
`pretrained=False` fix (#5966)
`pretrained=False` fix (#5966)