levan92 / deep_sort_realtime

A really more real-time adaptation of deep sort
MIT License
166 stars 51 forks source link

jupyter kernel die when I create DeepSort object #31

Closed M-Amrollahi closed 2 years ago

M-Amrollahi commented 2 years ago

When I try to create an object from DeepSort, the jupyter kernel will die. May I know where the issue is?

levan92 commented 2 years ago

It's hard to determine what's the problem without any error msg or logs. Maybe try directly running a similar code segment in a python script in terminal and see if you can run?

romarcg commented 2 years ago

Do you have a code example? Your jupyter kernel could be dying for reasons other than creating a DeepSort object.

I have tried the code example in the README file in a jupyter notebook with success. Here is a code snippet; consider that you will need to implement some missing functions.

import cv2
import matplotlib.pyplot as plt
from deep_sort_realtime.deepsort_tracker import DeepSort

tracker = DeepSort(max_age=5)

# read a frame
frame = cv2.imread("input.jpg")

# I have my own object detector that returns a bounding boxes list in the format DeepSort 
# requires it, see https://github.com/levan92/deep_sort_realtime/blob/0b67b75dbf96fbe5a353fd1c35b51b5b2b5bad8a/deep_sort_realtime/deepsort_tracker.py#L151
bbs = object_detector.detect(frame)  
tracks = tracker.update_tracks(bbs, frame=frame) # bbs expected to be a list of detections, each in tuples of ( [left,top,w,h], confidence, detection_class )
for track in tracks:
    if not track.is_confirmed():
        continue
    track_id = track.track_id
    #ltrb = track.to_ltrb()
    bbox = track.to_tlwh()
    # my own method to draw a track bbox on the frame 
    draw_bbox(frame, bbox, track_id) 

plt.imshow(frame)
M-Amrollahi commented 2 years ago

That is right. I have run it again on new env and it works. Thanks