Tencent / FaceDetection-DSFD

腾讯优图高精度双分支人脸检测器

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError: can't convert cuda:0 device type tensor to numpy.

chaotianjiao opened this issue · comments

Hello~,Thanks for your work! when I run demo.py I meet an error:

loading pretrained resnet model
Finished loading model!
Error bbox number to filter : 0,  bbox number: 0
Finished loading data
loading pretrained resnet model
Finished loading model!
/home/felix/PycharmProjects/yolov5/yolov5_venv/lib/python3.8/site-packages/torch/nn/functional.py:3328: UserWarning: nn.functional.upsample is deprecated. Use nn.functional.interpolate instead.
  warnings.warn("nn.functional.upsample is deprecated. Use nn.functional.interpolate instead.")
/home/felix/PycharmProjects/yolov5/yolov5_venv/lib/python3.8/site-packages/torch/nn/functional.py:3454: UserWarning: Default upsampling behavior when mode=bilinear is changed to align_corners=False since 0.4.0. Please specify align_corners=True if the old behavior is desired. See the documentation of nn.Upsample for details.
  warnings.warn(
Traceback (most recent call last):
  File "/home/felix/PycharmProjects/FaceDetection-DSFD/demo.py", line 232, in <module>
    test_oneimage()
  File "/home/felix/PycharmProjects/FaceDetection-DSFD/demo.py", line 200, in test_oneimage
    det0 = infer(net, img, transform, thresh, cuda, shrink)
  File "/home/felix/PycharmProjects/FaceDetection-DSFD/demo.py", line 94, in infer
    det = torch.from_numpy(np.array(det))
  File "/home/felix/PycharmProjects/yolov5/yolov5_venv/lib/python3.8/site-packages/torch/tensor.py", line 621, 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.

How could I slove it ? Thanks~

@chaotianjiao I am also facing the same error. Have you resolved it?