cfotache / pytorch_objectdetecttrack

Object detection in images, and tracking across video frames
483 stars 253 forks source link

Compilation is failing Back #30

Open ZahraAnam opened 3 years ago

ZahraAnam commented 3 years ago

Hi! I am trying to use your code for object detection and tracking using Ubuntu 20.04. Detection on image works fine but when attempting on videos and trying to track, I get following warnings and errors:

/home/anam/anaconda3/envs/yolov3/lib/python3.6/site-packages/torch/nn/_reduction.py:44: UserWarning: size_average and reduce args will be deprecated, please use reduction='mean' instead. warnings.warn(warning.format(ret)) /home/anam/Codes/YOLOv4/Yolov3/pytorch_objectdetecttrack/sort.py:33: NumbaWarning: Compilation is falling back to object mode WITH looplifting enabled because Function "iou" failed type inference due to: non-precise type pyobject During: typing of argument at /home/anam/Codes/YOLOv4/Yolov3/pytorch_objectdetecttrack/sort.py (38)

File "sort.py", line 38: def iou(bb_test,bb_gt):

""" xx1 = np.maximum(bb_test[0], bb_gt[0]) ^

@jit /home/anam/anaconda3/envs/yolov3/lib/python3.6/site-packages/numba/core/object_mode_passes.py:178: NumbaWarning: Function "iou" was compiled in object mode without forceobj=True.

File "sort.py", line 34: @jit def iou(bb_test,bb_gt): ^

state.func_ir.loc)) /home/anam/anaconda3/envs/yolov3/lib/python3.6/site-packages/numba/core/object_mode_passes.py:188: NumbaDeprecationWarning: Fall-back from the nopython compilation path to the object mode compilation path has been detected, this is deprecated behaviour.

For more information visit https://numba.pydata.org/numba-doc/latest/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit

File "sort.py", line 34: @jit def iou(bb_test,bb_gt): ^

state.func_ir.loc)) Traceback (most recent call last): File "object_detector.py", line 124, in tracked_objects = mot_tracker.update(detections.cpu()) File "/home/anam/Codes/YOLOv4/Yolov3/pytorch_objectdetecttrack/sort.py", line 209, in update matched, unmatched_dets, unmatched_trks = associate_detections_to_trackers(dets,trks) File "/home/anam/Codes/YOLOv4/Yolov3/pytorch_objectdetecttrack/sort.py", line 153, in associate_detections_to_trackers if(d not in matched_indices[:,0]): TypeError: tuple indices must be integers or slices, not tuple

Wondering if you can help.

Leizhengwang commented 3 years ago

Yes, sort.py has the same problem in my side ------TypeError: tuple indices must be integers or slices, not tuple, can you help?

ZahraAnam commented 3 years ago

Am trying to solve it, if I do it I'll post here.

ZahraAnam commented 3 years ago

I resolved my first error by a simple change "if(d not in matched_indices[0]):" i.e. Only access the 0 and 1 element of tuple. But now I have problem in matching section.

geohwk commented 3 years ago

Getting the same issue on sort.py with videos. The only change I made was altering the sklearn module to scipy in sort.py.

tletnes commented 3 years ago

I was able to work around this by replacing the import of linear_assignment with:

from scipy.optimize import linear_sum_assignment
def linear_assignment(x):
  indices = linear_sum_assignment(x)
  indices = np.asarray(indices)
  return np.transpose(indices)
geohwk commented 3 years ago

I was able to work around this by replacing the import of linear_assignment with:

from scipy.optimize import linear_sum_assignment
def linear_assignment(x):
  indices = linear_sum_assignment(x)
  indices = np.asarray(indices)
  return np.transpose(indices)

This also worked great for me. Thank you!