I can't figure out how to pass detections to ByteTrack (https://github.com/ifzhang/ByteTrack) I tried to follow the instructions given by the creator but nothing went as planned. Here is my code:
# Perform object detection with YOLOv5
results = model(frame)
#print(results)
# Process detection results
bbs = []
for det in results.pandas().xyxy[0].iterrows():
_, detection = det
xmin = float(detection.xmin)
ymin = float(detection.ymin)
xmax = float(detection.xmax - xmin)
ymax = float(detection.ymax - ymin)
confidence = float(detection.confidence)
class_id = int(detection.name)
if class_id >= 0 and class_id < len(class_labels):
class_label = class_labels[class_id]
if confidence > conf_threshold: # 0.4
# Append detection to the list of bounding boxes
bbs.append((xmin, ymin, xmax, ymax, confidence, class_id))
#print(bbs)
dets = (bbs, num_classes)
#print(dets)
# Pass detection results to BYTETracker
online_targets = tracker.update(dets, img_size) #, info_imgs
And the error:
TypeError Traceback (most recent call last)
Cell In[17], line 77
73 dets = (bbs, num_classes)
74 #print(dets)
75
76 # Pass detection results to BYTETracker
---> 77 online_targets = tracker.update(dets, img_size) #, info_imgs
79 # Process tracking results
80 for target in online_targets:
File ~\AppData\Local\anaconda3\envs\bytetrackpypi\lib\site-packages\bytetracker\byte_tracker.py:186, in BYTETracker.update(self, dets, _)
183 lost_stracks = []
184 removed_stracks = []
--> 186 xyxys = dets[:, 0:4]
187 xywh = xyxy2xywh(xyxys)
188 confs = dets[:, 4]
TypeError: tuple indices must be integers or slices, not tuple
I fixed the problem by transforming dets into float tensors:
dets = torch.FloatTensor(bbs)