#๐Ÿ”’ YoloV5/Pytorch Error

7 messages ยท Page 1 of 1 (latest)

swift parrotBOT
#

@gaunt cliff

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

gaunt cliff
#
Traceback (most recent call last):
  File "C:\Users\Admin\Desktop\ai-train-cs\obj-recognition.py", line 6, in <module>
    model = torch.hub.load('ultralytics/yolov5', 'custom', path='./best.pt', force_reload=True).autoshape()
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Admin\AppData\Roaming\Python\Python312\site-packages\torch\hub.py", line 570, in load
    model = _load_local(repo_or_dir, model, *args, **kwargs)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Admin\AppData\Roaming\Python\Python312\site-packages\torch\hub.py", line 599, in _load_local
    model = entry(*args, **kwargs)
            ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Admin/.cache\torch\hub\ultralytics_yolov5_master\hubconf.py", line 135, in custom
    return _create(path, autoshape=autoshape, verbose=_verbose, device=device)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Admin/.cache\torch\hub\ultralytics_yolov5_master\hubconf.py", line 103, in _create
    raise Exception(s) from e
Exception: cannot instantiate 'PosixPath' on your system. Cache may be out of date, try `force_reload=True` or see https://docs.ultralytics.com/yolov5/tutorials/pytorch_hub_model_loading for help.
#

I have tried to to reinstall python ( remove all libraries ), clean all temp files, etc. Fresh installed python / lib. Still wouldn't work even after passing arg force_reload=True.

#
import torch
import cv2
import numpy as np
from mss import mss

model = torch.hub.load('ultralytics/yolov5', 'custom', path='./best.pt', force_reload=True).autoshape()

python code

#
import torch
from pathlib import Path

yolov5_path = Path('./yolov5')
yolov5_path_str = str(yolov5_path)

model_path = Path('./best.pt')
model_path_str = str(model_path)

model = torch.hub.load(yolov5_path_str, 'custom', path=model_path_str, source='local', force_reload=True)

image_path = Path('test.png')
image_path_str = str(image_path)

results = model(image_path_str)

results.show()

tried converting the path, still didn't work.

swift parrotBOT
#

@gaunt cliff

Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.