Can some body help me, I can't load my custom model

I’m using torch 1.11.0+cu113


import torch
path = ‘yolov5s.pt’
model = torch.hub.load(‘.’, ‘custom’, path=path, source=‘local’)
print(model(‘images\1.jpg’))


I got
File “.\load3.py”, line 3, in
model = torch.hub.load(‘.’, ‘custom’, path=path, source=‘local’)
File “C:\Users\bukob\AppData\Local\Programs\Python\Python38\lib\site-packages\torch\hub.py”, line 404, in load
model = _load_local(repo_or_dir, model, *args, **kwargs)
File “C:\Users\bukob\AppData\Local\Programs\Python\Python38\lib\site-packages\torch\hub.py”, line 430, in _load_local
hub_module = _import_module(MODULE_HUBCONF, hubconf_path)
File “C:\Users\bukob\AppData\Local\Programs\Python\Python38\lib\site-packages\torch\hub.py”, line 76, in _import_module
spec.loader.exec_module(module)
File “”, line 779, in exec_module
File “”, line 915, in get_code
File “”, line 972, in get_data
FileNotFoundError: [Errno 2] No such file or directory: ‘.\hubconf.py’

hubconf.py seems to be defined in the Yolo repository of I’m not mistaken, so you might need to install the repo or make sure the scripts are oin your python path.

yeah you’re right I have no hubconf.py then I use this


import torch
import cv2

path = ‘weaponsdex.103_9kIMG_16batch_300e.pt’
model = torch.hub.load(‘ultralytics/yolov5’, ‘custom’, path)

img = cv2.imread(“images/1.jpg”)
result = model(img)

print(result)


and it works, THX for your helpful answer

Hi ptrblck, Could you help me please?