cfotache / pytorch_objectdetecttrack

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

torch.FloatTensor but found type torch.DoubleTensor #1

Closed mahavird closed 5 years ago

mahavird commented 5 years ago

Hi Chris,

You have done a great job.

But While executing the object_tracker.py, I am getting the following error:

RuntimeError: Expected object of type torch.FloatTensor but found type torch.DoubleTensor for argument #3 'other'

error

Where am I going wrong ?

Thanks :)

cfotache commented 5 years ago

I updated that file, but it was just small changes due to the fact that I changed the imported modules names. It's working fine for me, just make sure you use Python 3.6 and Torch 1.0 (can't guarantee it works with older versions)

mahavird commented 5 years ago

@cfotache Thanks for the reply. I tried it with python 3.6 but still, the same issue persists. Can you tell which version of pytorch and Cuda are you using?

cfotache commented 5 years ago

Torch 1.0.0.dev20181009 Cuda 8.0.61 I installed them the way I described in this article: https://medium.com/@chrisfotache/getting-started-with-fastai-v1-the-easy-way-using-python-3-6-apt-and-pip-772386952d03

I uploaded a video, overpass.mp4 in the images/ folder, can you try with that? Just to make sure there's not an issue with your video format (i know the FFMPEG decode is very sensitive and I have to convert many videos)

mahavird commented 5 years ago

Hi @cfotache ,

I couldn't find the video you mentioned above? Can you please confirm, where is the video?

Thanks.

egidisa commented 5 years ago

@mahavird To make it work with torch version <1 you should manually convert your tensors to np arrays before passing them to cpu processes, as sort is. Changing on line 88 of _objecttracker.py tracked_objects = mot_tracker.update(detections.cpu()) to tracked_objects = mot_tracker.update(detections.cpu().numpy()) did the trick for me

In Pytorch 1.0 they don't move tensors to cpu implicitly anymore, as stated in their release notes. If you change to torch 1.0 it should work as well :)

Implicit numpy conversion no longer implicitly moves a tensor to CPU. Therefore, you may have to explicitly move a CUDA tensor to CPU (tensor.to('cpu')) before an implicit conversion. (#10553).