roboflow / zero-shot-object-tracking

Object tracking implemented with the Roboflow Inference API, DeepSort, and OpenAI CLIP.
https://blog.roboflow.com/zero-shot-object-tracking/
GNU General Public License v3.0
357 stars 62 forks source link

TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first. #22

Closed pictus-ai closed 2 years ago

pictus-ai commented 2 years ago

When running this code snippet. I get the Type Error below. Any guidance would be appreciated _!python clip_objecttracker.py --source ./data/video/cars.mp4 --detection-engine yolov5


/usr/local/lib/python3.7/dist-packages/torch/functional.py:445: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ../aten/src/ATen/native/TensorShape.cpp:2157.) return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined] video 1/1 (1/266) /content/zero-shot-object-tracking/zero-shot-object-tracking/data/video/cars.mp4: yolov5 inference

[Detections] 1 persons, 8 cars, 2 trucks, Traceback (most recent call last): File "clip_object_tracker.py", line 361, in detect() File "clip_object_tracker.py", line 249, in detect class_nums = np.array([d.class_num for d in detections]) File "/usr/local/lib/python3.7/dist-packages/torch/_tensor.py", line 678, in array return self.numpy() TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.