[Python] I can't load my YOLOv5 model in streamlit , this is the error

Discussão em 'Python' iniciado por Stack, Setembro 30, 2024.

  1. Stack

    Stack Membro Participativo

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


    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 tried redirect the posixpath to windowspath :

    import pathlib
    temp = pathlib.PosixPath
    pathlib.PosixPath = pathlib.WindowsPath


    I tried loading from local source like this :

    model = torch.hub.load('path/to/yolov5', 'custom', path='path/to/best.pt', source='local') # local repo

    Continue reading...

Compartilhe esta Página