-
Notifications
You must be signed in to change notification settings - Fork 9
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
Getting error torch.nn.modules.module.ModuleAttributeError: 'Detect' object has no attribute 'inplace' #2
Comments
Your welcome! Could you please answer the following questions:
From a first guess I would say you use an (out of the box) incompatible combination of yolov5, pytorch and coremltools. I might be able to include a fix for this if I know more details. For a first test, I would recommend downloading the yolov5s version4 model and using it with the repo as is. This should work out of the box. |
@Leon0402 Thank you very much your quick reply. I switched to the Similarly, it works for other branches like the When I run the same on the master branch, I get the earlier error: Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/samygarg/Documents/yolov5-coreml-tools/src/coreml_export/main.py", line 318, in main
model(sampleInput)
File "/Users/samygarg/Library/Caches/pypoetry/virtualenvs/coreml-tools-LHeNloI_-py3.7/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "/Users/samygarg/Documents/yolov5/models/yolo.py", line 117, in forward
return self.forward_once(x, profile) # single-scale inference, train
File "/Users/samygarg/Documents/yolov5/models/yolo.py", line 148, in forward_once
x = m(x) # run
File "/Users/samygarg/Library/Caches/pypoetry/virtualenvs/coreml-tools-LHeNloI_-py3.7/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "/Users/samygarg/Documents/yolov5/models/yolo.py", line 55, in forward
if self.inplace:
File "/Users/samygarg/Library/Caches/pypoetry/virtualenvs/coreml-tools-LHeNloI_-py3.7/lib/python3.7/site-packages/torch/nn/modules/module.py", line 779, in __getattr__
type(self).__name__, name))
torch.nn.modules.module.ModuleAttributeError: 'Detect' object has no attribute 'inplace' |
Where do you get the pretrained model from? On the Bottom you can download the Yolov5s version Version 4 Then you need to check out the source code for exactly this model: Then you need to add a Therefore: The pretrained model has to match the source code it was pretrained with! If you use the model from https://github.com/ultralytics/yolov5/releases/tag/v5.0, then checkout the v5.0 tag. As I said this should work with v2.0 , v3.0, v4.0 tag. There might be issues with the v5.0 tag, I haven't tried it yet. The reasons why the version used is so important is because yolo uses newer pytorch version and features, but coremltools (the library used for export) doesn't support the newer versions. So in order to use the v5 model I probably need to update the coremltools lib (if there is one) or even include a patch. |
Thank you very much for creating this repo.
I placed the default yolov5s.pt file in the root directory and ran the following command:
But getting this error:
Please let me know how I can get it to work.
The text was updated successfully, but these errors were encountered: