foolwood / DCFNet_pytorch

DCFNet: Discriminant Correlation Filters Network for Visual Tracking
https://arxiv.org/pdf/1704.04057.pdf
MIT License
207 stars 60 forks source link

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

Closed JasonmorrowGuo closed 4 years ago

JasonmorrowGuo commented 4 years ago

Related code: search = patch_crop - config.net_average_image response = net(torch.Tensor(search).cuda()) peak, idx = torch.max(response.view(config.num_scale, -1), 1) peak = peak.data.cpu().numpy() * config.scale_penalties best_scale = np.argmax(peak) r_max, c_max = np.unravel_index(idx[best_scale], config.net_input_size) The error described in the title is in the lase line. i don't know why it was still wrong.

ahmedosamaz commented 2 years ago

the same error for me.. did you find an answer?!

JasonmorrowGuo commented 2 years ago

the same error for me.. did you find an answer?!

maybe you can convert the CUDA tensor X to numpy by X.detach().cpu().numpy()