I am trying to write a code that performs object tracking (detection and tracking). I first find the detections using Yolov5 but the problem comes when I try to initialize the StrongSort to do the tracking. My code is inspired by this repository (I have all the requirements installed) and when initializing the StrongSort, the code uses as model weights "osnet_x0_25_market1501.pt", but when I do the same I get the following error:
AttributeError: 'str' object has no attribute 'name'
I don't know if I should input it in another way or download it from somewhere.
The code I wrote goes like is:
import torch
import numpy as np
import cv2
from strongsort.strong_sort import StrongSORT
import os
# Load the YOLOv5 model
model = torch.hub.load('ultralytics/yolov5', 'yolov5s', pretrained=True)
# Load the StrongSORT model
tracker = StrongSORT( model_weights= "osnet_x0_25_market1501.pt" ,
device='cuda', fp16 = True)
Discalimer. I am the creator of: https://github.com/mikel-brostrom/yolov8_tracking
That repo is highly based on: https://github.com/mikel-brostrom/yolov8_tracking. I recommend you to use the original one.
Anyways, if you still want to use that one you could try:
import torch
import numpy as np
import cv2
from pathlib import Path
from strongsort.strong_sort import StrongSORT
import os
# Load the YOLOv5 model
model = torch.hub.load('ultralytics/yolov5', 'yolov5s', pretrained=True)
# Load the StrongSORT model
tracker = StrongSORT( model_weights= Path("osnet_x0_25_market1501.pt") ,
device='cuda', fp16 = True)