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

No module named 'models' question #131

Closed
ioir123ju opened this issue Jun 19, 2020 · 9 comments
Closed

No module named 'models' question #131

ioir123ju opened this issue Jun 19, 2020 · 9 comments
Labels
bug Something isn't working

Comments

@ioir123ju
Copy link

馃悰 Bug

When I use yolov5 outside the repo and use "torch.load(the_mode, PATH)", I got the error "No module named 'models'"

I see a solution in #22.

But I got error when I use model = torch.hub.load('ultralytics/yolov5', 'yolov5s', pretrained=True)

torch.nn.modules.module.ModuleAttributeError: 'BatchNorm2d' object has no attribute '_non_persistent_buffers_set'

So I still want to load model in this way:
model.load_state_dict(torch.load(new_weights))
Can you tell me how to use model.load_state_dict ?

@ioir123ju ioir123ju added the bug Something isn't working label Jun 19, 2020
@github-actions
Copy link
Contributor

github-actions bot commented Jun 19, 2020

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

glenn-jocher commented Jun 19, 2020

@ioir123ju
Copy link
Author

ioir123ju commented Jun 19, 2020

Sorry, It doesn't solve my problem.
image

environment

pytorch 1.6

@glenn-jocher
Copy link
Member

@ioir123ju
Copy link
Author

yes, My environment meets your requirements.

torch 1.6 >= torch1.5
python 3.7

And I can run detect.py in your repo.
But can't load weight in my project.

@glenn-jocher
Copy link
Member

@ioir123ju debug your environment, or just use one of our working ones. That's what they are there for.

@rxchen
Copy link

rxchen commented Jul 14, 2020

I have the same problem, torch 1.6rc2
File "detect.py", line 23, in detect
model = attempt_load(weights, map_location=device) # load FP32 model
File "/home/ruichen/nvme/gitrepo/yolov5/models/experimental.py", line 133, in attempt_load
model.append(torch.load(w, map_location=map_location)['model'].float().fuse().eval()) # load FP32 model
File "/home/ruichen/nvme/gitrepo/yolov5/models/yolo.py", line 149, in fuse
m.conv = torch_utils.fuse_conv_and_bn(m.conv, m.bn) # update conv
File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 802, in setattr
remove_from(self.dict, self._parameters, self._buffers, self._non_persistent_buffers_set)
File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 772, in getattr
type(self).name, name))
torch.nn.modules.module.ModuleAttributeError: 'Conv' object has no attribute '_non_persistent_buffers_set'

@fpingham
Copy link
Contributor

fpingham commented Aug 9, 2020

Same problem over here.

@glenn-jocher
Copy link
Member

glenn-jocher commented Aug 9, 2020

@fpingham you are probably using an older version of the repo, an older model, or are not meeting the minimum dependency requirements. I would start from a clean slate in one of the verified environments below.

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):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants