mikel-brostrom / boxmot

BoxMOT: pluggable SOTA tracking modules for segmentation, object detection and pose estimation models
GNU Affero General Public License v3.0
6.57k stars 1.7k forks source link

Stuck in tentative #128

Closed sudhanv09 closed 3 years ago

sudhanv09 commented 3 years ago

Hi I am attempting to port this repo to ROS. I am having trouble with deepsort, it is stuck in tentative. Can you help me sort this out

mikel-brostrom commented 3 years ago

Sorry, I am not so familiar with ROS. By maybe somebody else can help you out here. Good luck!

sudhanv09 commented 3 years ago

I'm sorry for not making it clear. My problem is with deepsort and not ROS.

In deep_sort/sort/tracker.py I observe that I'm stuck in _initiate_track function and self.tracks is not updating. The is_tentative function of Track gives True and never updates

mikel-brostrom commented 3 years ago

A track is in Tentative state until the object has been associated n_init consecutive times. How are you feeding the images to track.py?

sudhanv09 commented 3 years ago
# image going to YOLO as tensor (BCHW)
    img = torch.from_numpy(image).to(device)
    img = img.half() if half else img.float()  
    img /= 255.0 
    if img.ndimension() == 3:
        img = img.unsqueeze(0)

    assert img.shape == (1,3,480,640)        

    # image going to deepsort (HWC) (480, 640, 3)
    image = image.transpose(1, 2, 0)

    # Inference
    pred = model(img, augment=augment)[0]

    # Apply NMS
    pred = non_max_suppression(pred, conf_thres, iou_thres, agnostic=agnostic_nms)

    for _, det in enumerate(pred): 

        if det is not None and len(det):

            det[:, :4] = scale_coords(
                img.shape[2:], det[:, :4], image.shape).round()

            for c in det[:, -1].unique():
                n = (det[:, -1] == c).sum()  # detections per class
                final_out[names[int(c)]] = n

            xywh_bboxs = []
            confs = []

            for *xyxy, conf, _ in det:
                x_c, y_c, bbox_w, bbox_h = xyxy_to_xywh(*xyxy)
                xywh_obj = [x_c, y_c, bbox_w, bbox_h]
                xywh_bboxs.append(xywh_obj)
                confs.append([conf.item()])

            xywhs = torch.Tensor(xywh_bboxs)
            confss = torch.Tensor(confs)

            outputs = deepsort.update(xywhs, confss, image)

            # print(f'out: {outputs}')

            if len(outputs) > 0:
                bbox_xyxy = outputs[:, :4]
                identities = outputs[:, -1]
                draw_boxes(image, bbox_xyxy, identities)
                # to MOT format
                tlwh_bboxs = xyxy_to_tlwh(bbox_xyxy)

        else:
            deepsort.increment_ages()

    return final_out, tlwh_bboxs

images are fed from ROS. theres no problem there. Can you see something off here

mikel-brostrom commented 3 years ago

I have the feeling that maybe only a single image is feed to yolo. It makes no sense otherwise that the tracks get stuck in tentative. Either they should be deleted or accepted as valid tracks if there is a continuous stream of images. What do you feed to:

https://github.com/mikel-brostrom/Yolov5_DeepSort_Pytorch/blob/461c80ce7aa5a7901f722d072a955ec4909dcfcc/track.py#L78

?

sudhanv09 commented 3 years ago

Actually I'm not using this line. I feed my images directly to the loop. So the webcam uploads to ROS and then I get the images from ROS.

"I have the feeling that maybe only a single image is feed to yolo." This could be the case. I'll check it out