-
-
Notifications
You must be signed in to change notification settings - Fork 16.3k
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
Cannot load the model #4970
Comments
I have the same error. Two days ago, the code worked for me. |
I've tried both the old version and new version, but still having the same error :( |
The problem is here 5ed2860#diff-2cd118cbb69c9ca7b5544f4187b11335fc3addbaf2c3c5bb45435cac648c957bR18 It fails to create relative path to two paths with no common root path |
yes, the condition statement - ROOT = ROOT.relative_to(Path.cwd()) if ROOT.is_relative_to(Path.cwd()) else ROOT # relative
+ ROOT = ROOT.relative_to(Path.cwd()) Check this commit: 938b39b |
Is there a way to fix it? I tried to edit but hub.load keeps removing my fix and runs with the newest version... |
You can specify a local link to the repository when loading the model via You can also fork the version you want of the YoloV5 repo and change |
Ok. It seems like it's working for now. Thank you so much everyone. Amazing help |
@pnama Could you describe what worked for you ? Edit: This is what worked for me.
This is what my loading function looks like: model = torch.hub.load("ChainYo/yolov5", "custom", path="path/to/yolov5.pt", force_reload=True) |
Yeap. Looks like you have the perfect answer. In my case, I've already had the yolo model so I just changed the path to the local folder and it worked :) |
@pnama @Basti110 @chainyo good news 😃! Your original issue may now be fixed ✅ in PR #4974. This PR comments out relative ROOT attempts in yolo.py and tf.py which may be imported by PyTorch Hub. We did not revert to using Path().is_relative() anymore because this was only introduced in python 3.8 and we want python >3.6 compatability. To receive this update:
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 🚀! |
TODO: Add import custom model with PyTorch Hub to CI tests.
|
I get an error when I run this code torch.hub.load('ultralytics/yolov5', 'custom', path='yolov5/path/last.pt', force_reload=True)
It was working until yesterday and now I receive an error "raise ValueError("{!r} does not start with {!r}"
ValueError: 'C:\Users\aaa\.cache\torch\hub\ultralytics_yolov5_master' does not start with 'C:\Users\aaa\PycharmProjects\project\proejct1'". I have removed the files inside the cache folder but it doesn't fix the error...
Any suggestions will be appreciated. Thank you
The text was updated successfully, but these errors were encountered: