abewley / sort

Simple, online, and realtime tracking of multiple objects in a video sequence.
GNU General Public License v3.0
3.92k stars 1.09k forks source link

TypeError: list indices must be integers or slices, not tuple #108

Closed Varat7v2 closed 3 years ago

Varat7v2 commented 4 years ago

I am trying to use SORT in my project, but I am getting following error. I am trying to track the error but not able to find why its occurring.

File "sort.py", line 242, in update
    trk = KalmanBoxTracker(dets[i,:])
TypeError: list indices must be integers or slices, not tuple
Veronica1997 commented 4 years ago

I meet the same problem with you ,have you solved it? Thanks very much!

petrpilar commented 4 years ago

I added this line: dets = np.array(dets) right after update:
def update(self, dets=np.empty((0, 5))):

Maybe worked for me

abewley commented 4 years ago

Can you please provide more information on how to reproduce this error? Are you passing dets as a 2D numpy array following what is described in the update() doc string? If not you can easily create a numpy array as pilarpe4@ described.

manish33scss commented 3 years ago

i changed the whole sort file, copy pasted from original doc, attaching file for that i am using, sort_copied.txt

for x1, y1, x2, y2, obj_id, cls_pred in tracked_objects: (so this sort will return bbox coordinates, id and cls)

sampreets3 commented 3 years ago

i changed the whole sort file, copy pasted from original doc, attaching file for that i am using, sort_copied.txt

for x1, y1, x2, y2, obj_id, cls_pred in tracked_objects: (so this sort will return bbox coordinates, id and cls)

How do I go about using this new file? What I have done is I have copied and pasted the txt file into the sort.py file, and re-ran the application. This still gives me the error :

  File "<root-repo>\sort.py", line 216, in update
    trk = KalmanBoxTracker(dets[i,:])
TypeError: list indices must be integers or slices, not tuple
manish33scss commented 3 years ago

i changed the whole sort file, copy pasted from original doc, attaching file for that i am using, sort_copied.txt for x1, y1, x2, y2, obj_id, cls_pred in tracked_objects: (so this sort will return bbox coordinates, id and cls)

How do I go about using this new file? What I have done is I have copied and pasted the txt file into the sort.py file, and re-ran the application. This still gives me the error :

  File "<root-repo>\sort.py", line 216, in update
    trk = KalmanBoxTracker(dets[i,:])
TypeError: list indices must be integers or slices, not tuple

I tried this, again, its working, as far as i can remember i got this error while updating something in those files. just find out what is the type of detections, i am pasting my piece of code that is invoking tracker. and type of detections and tracked_objects

** detections=detections.type(torch.DoubleTensor)

    tracked_objects = mot_tracker.update(detections)
    detectionstest.append(detections)
    box = detections[0:4]**

type(detections) Out[2]: torch.Tensor

type(tracked_objects) Out[3]: numpy.ndarray

and can you try this sort code, on a different pc ? i think you might have to reinstall some stuff. ( just a wild guess)

KC-Zhang commented 3 years ago

the input to update() must be an np array rather than list of lists