DiaaZiada / Object-Counter-YOLOV3

Object counter is toolkit uses YOLO V3(you only look once version 3) algorithm. this toolkit not only make object detection on images/videos but also count the number of objects presents in the image/video.
26 stars 4 forks source link

TypeError: can't convert CUDA tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first. #1

Open dee6600 opened 4 years ago

dee6600 commented 4 years ago

python video.py --cam Loading network..... C:\Users\dee\Anaconda3\envs\torch\lib\site-packages\torch\nn_reduction.py:43: UserWarning: size_average and reduce args will be deprecated, please use reduction='mean' instead. warnings.warn(warning.format(ret)) Network successfully loaded OpenCV: FFMPEG: tag 0x47504a4d/'MJPG' is not supported with codec id 7 and format 'mp4 / MP4 (MPEG-4 Part 14)' OpenCV: FFMPEG: fallback to use tag 0x7634706d/'mp4v' video.py:127: UserWarning: volatile was removed and now has no effect. Use with torch.no_grad(): instead. output = model(Variable(img, volatile = True)) Traceback (most recent call last): File "video.py", line 128, in output = non_max_suppression(output, confidence, num_classes, nms_conf = nms_thesh) File "C:\Users\dee\Documents\Object-Counter-YOLOV3\util\utils.py", line 127, in non_max_suppression img_classes = unique(imagepred[:,-1]) # -1 index holds the class index File "C:\Users\dee\Documents\Object-Counter-YOLOV3\util\utils.py", line 63, in unique tensor_np = tensor.detach().numpy() TypeError: can't convert CUDA tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first. [ WARN:0] global C:\projects\opencv-python\opencv\modules\videoio\src\cap_msmf.cpp (674) SourceReaderCB::~SourceReaderCB terminating async callback

Trying on cam

Whisper94 commented 4 years ago

I have the same issue. How have you solved it?

smithee77 commented 4 years ago

Hi same issue here

Whisper94 commented 4 years ago

@smithee77 I've got it aß I changed to tensor.cpu(). detach().numpy() But I have no output prediction aß Image. Only in cmd or conda as text

smithee77 commented 4 years ago

@Whisper94 hi! same here! I tried your solution and works fine :) except no output image :(

wz0424 commented 4 years ago

@Whisper94 hi! same here! I tried your solution and works fine :) except no output image :(

me too no output image