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 HUB issues and discussions and found no similar questions.
Question
the .pt file i trained via ultralytics hub on yolov5lu, does not work on yolov5 i downloaded from ultralytics github. i have loaded the model via torch hub (yes forced reload is true) but other pt which i trained via roboflow jupyter notebook works on the yolov5 i downloaded from git. Am i missing something
the error is Exception: 'Detect' object has no attribute 'grid'. Cache may be out of date, try force_reload=True
something with hubconf file on yolov5 master folder,
all other pt files work which i have trained using roboflow notebook on colab
YOLOv5l summary (fused): 303 layers, 53132179 parameters, 0 gradients
Adding AutoShape...
Traceback (most recent call last):
File "C:\Users\om\Desktop\ugv proto\codes./yolov5-master\hubconf.py", line 73, in _create
return model.to(device)
File "C:\Users\om\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 989, in to
return self._apply(convert)
File "C:\Users\om\Desktop\ugv proto\codes./yolov5-master\models\common.py", line 652, in _apply
m.grid = list(map(fn, m.grid))
File "C:\Users\om\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1269, in getattr
raise AttributeError("'{}' object has no attribute '{}'".format(
AttributeError: 'Detect' object has no attribute 'grid'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "c:\Users\om\Desktop\ugv proto\codes\track.py", line 15, in
model = torch.hub.load('./yolov5-master', 'custom', source ='local', path=a, force_reload=True)
File "C:\Users\om\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\hub.py", line 542, in load
model = _load_local(repo_or_dir, model, *args, **kwargs)
File "C:\Users\om\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\hub.py", line 572, in _load_local
model = entry(*args, **kwargs)
File "C:\Users\om\Desktop\ugv proto\codes./yolov5-master\hubconf.py", line 83, in custom
return _create(path, autoshape=autoshape, verbose=_verbose, device=device)
File "C:\Users\om\Desktop\ugv proto\codes./yolov5-master\hubconf.py", line 78, in _create
raise Exception(s) from e
Exception: 'Detect' object has no attribute 'grid'. Cache may be out of date, try force_reload=True or see ultralytics/yolov5#36 for help.
The text was updated successfully, but these errors were encountered:
@omumbare7 Thanks for asking the question. The YOLOv5lu and YOLOv5l models are not the same, there have been some tweaks that make them incompatible. All the v5u models can only be run with the ultralytics package, and they will not run with YOLOv5. And the same can be said for models trained with YOLOv5 and not ultralytics. They will work with YOLOv5 but not with ultralytics.
You will need to run inference with the ultralytics package if you have trained a v5u model in HUB.
fromultralyticsimportYOLO# Load a modelmodel=YOLO('path/to/best.pt') # load a custom model# Predict with the modelresults=model('https://ultralytics.com/images/bus.jpg', save=True) # predict on an image
You're welcome @omumbare7! Please do give it a try and let us know if you encounter any other issues or have further questions. We're here to help! Remember, the key point is to use the Ultralytics package for inference if you've trained a v5u model on the HUB. Thank you for being a part of the YOLO and Ultralytics community.
Search before asking
Question
the .pt file i trained via ultralytics hub on yolov5lu, does not work on yolov5 i downloaded from ultralytics github. i have loaded the model via torch hub (yes forced reload is true) but other pt which i trained via roboflow jupyter notebook works on the yolov5 i downloaded from git. Am i missing something
the error is Exception: 'Detect' object has no attribute 'grid'. Cache may be out of date, try
force_reload=True
something with hubconf file on yolov5 master folder,
all other pt files work which i have trained using roboflow notebook on colab
Additional
YOLOv5 2023-2-21 Python-3.10.0 torch-1.13.1+cu116 CUDA:0 (NVIDIA GeForce RTX 2060, 6144MiB)
YOLOv5l summary (fused): 303 layers, 53132179 parameters, 0 gradients
Adding AutoShape...
Traceback (most recent call last):
File "C:\Users\om\Desktop\ugv proto\codes./yolov5-master\hubconf.py", line 73, in _create
return model.to(device)
File "C:\Users\om\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 989, in to
return self._apply(convert)
File "C:\Users\om\Desktop\ugv proto\codes./yolov5-master\models\common.py", line 652, in _apply
m.grid = list(map(fn, m.grid))
File "C:\Users\om\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1269, in getattr
raise AttributeError("'{}' object has no attribute '{}'".format(
AttributeError: 'Detect' object has no attribute 'grid'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "c:\Users\om\Desktop\ugv proto\codes\track.py", line 15, in
model = torch.hub.load('./yolov5-master', 'custom', source ='local', path=a, force_reload=True)
File "C:\Users\om\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\hub.py", line 542, in load
model = _load_local(repo_or_dir, model, *args, **kwargs)
File "C:\Users\om\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\hub.py", line 572, in _load_local
model = entry(*args, **kwargs)
File "C:\Users\om\Desktop\ugv proto\codes./yolov5-master\hubconf.py", line 83, in custom
return _create(path, autoshape=autoshape, verbose=_verbose, device=device)
File "C:\Users\om\Desktop\ugv proto\codes./yolov5-master\hubconf.py", line 78, in _create
raise Exception(s) from e
Exception: 'Detect' object has no attribute 'grid'. Cache may be out of date, try
force_reload=True
or see ultralytics/yolov5#36 for help.The text was updated successfully, but these errors were encountered: