opencvobject-detectionyolov5

Yolov5 custom object detection model not loading


I have a trained a custom object detection model using yolov5 for 4 classes. I have downloaded the best.pt file. I am still confused about how to load this model using pytorch. I tried running the following code to load the model as per Yolov5 official documentation model = torch.hub.load('ultralytics/yolov5', 'custom', path='best.pt') but when I tried printing model.names, I am not getting my custom class names. Is there anything I am missing? Thank you!


Solution

    1. Try clearing your cache by adding this: force_reload=True
    2. Store your model in a local folder called model (in case you are locally trying to run this)

    then try adding this:

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