IDEA-Research / DN-DETR

[CVPR 2022 Oral] Official implementation of DN-DETR
Apache License 2.0
541 stars 62 forks source link

error : python inference.py #58

Open STRUGGLE1999 opened 1 year ago

STRUGGLE1999 commented 1 year ago

I want to visualize the results, but when I run python inference.py,it broke an error:

RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! (when checking argument for argument index in method wrapper__index_select) image

FengLi-ust commented 1 year ago

It seems some tensors are put in CPU will some are in GPU. You can put all tensors on the GPU to fix this problem.

akitten-cn commented 1 year ago

Did you find the location of the problem, please?

SumayyaInayat commented 1 month ago

Hi, This issue can be resolved by changing the following two lines: output, = model(image[None],0) output = postprocessors['bbox'](output, torch.Tensor([[1.0, 1.0]]))[0] to ---> output, = model.cuda()(image[None].cuda(),0) output = postprocessors['bbox'](output, torch.Tensor([[1.0, 1.0]]).cuda())[0]