Failed to upload custom trained model

from roboflow import Roboflow

rf = Roboflow(api_key="xxxx")
project = rf.workspace("dnf").project("dnf_v3")
project.version(4).deploy(model_type='yolov5', model_path='C:/work/codes/yolov5/runs/train/exp19')
loading Roboflow workspace...
loading Roboflow project...
Traceback (most recent call last):
  File ".\robo.py", line 5, in <module>
    project.version(4).deploy(model_type='yolov5', model_path='C:/work/codes/yolov5/runs/train/exp19')
  File "C:\Users\changyuyang\AppData\Local\Programs\Python\Python38\lib\site-packages\roboflow\core\version.py", line 499, in deploy
    model = torch.load(os.path.join(model_path, "weights/best.pt"))
  File "C:\Users\changyuyang\AppData\Local\Programs\Python\Python38\lib\site-packages\torch\serialization.py", line 1014, in load
    return _load(opened_zipfile,
  File "C:\Users\changyuyang\AppData\Local\Programs\Python\Python38\lib\site-packages\torch\serialization.py", line 1422, in _load
    result = unpickler.load()
  File "C:\Users\changyuyang\AppData\Local\Programs\Python\Python38\lib\site-packages\torch\serialization.py", line 1415, in find_class
    return super().find_class(mod_name, name)
ModuleNotFoundError: No module named 'models'

I’m not importing this ‘models’ package directly, I only imported Roboflow.

Hi @Dan_Young

Sorry about the trouble you’re having. Is this running on your own local code, as opposed to one of our notebooks, for example?

One thing you can try is that you need to have the correct version of the YOLOv5 package installed to do the model upload process correctly. From our YOLOv5 notebook, try running this before your upload:

# clone YOLOv5 repository
!git clone https://github.com/ultralytics/yolov5  # clone repo
%cd yolov5
!git reset --hard 064365d8683fd002e9ad789c1e91fa3d021b44f0

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.