Tencent / FaceDetection-DSFD

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use new-style autograd function with static forward method.

kevinzezel opened this issue · comments

HI, I got this error:

pytorch==1.4.0
torchvision==0.2.1

loading pretrained resnet model
Finished loading model!
demo.py:94: UserWarning: volatile was removed and now has no effect. Use with torch.no_grad(): instead.
x = Variable(x.unsqueeze(0) , volatile=True)
/home/kzezel/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/nn/functional.py:2416: UserWarning: nn.functional.upsample is deprecated. Use nn.functional.interpolate instead.
warnings.warn("nn.functional.upsample is deprecated. Use nn.functional.interpolate instead.")
/home/kzezel/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/nn/functional.py:2506: 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.
"See the documentation of nn.Upsample for details.".format(mode))
/home/kzezel/Kevin Zezel Gomes/FaceDetection-DSFD/face_ssd.py:187: UserWarning: volatile was removed and now has no effect. Use with torch.no_grad(): instead.
prior = Variable( priorbox.forward() , volatile=True)
/tmp/pip-req-build-808afw3c/torch/csrc/autograd/python_function.cpp:622: UserWarning: Legacy autograd function with non-static forward method is deprecated and will be removed in 1.3. Please use new-style autograd function with static forward method. (Example: https://pytorch.org/docs/stable/autograd.html#torch.autograd.Function)
/tmp/pip-req-build-808afw3c/torch/csrc/autograd/python_function.cpp:622: UserWarning: Legacy autograd function with non-static forward method is deprecated and will be removed in 1.3. Please use new-style autograd function with static forward method. (Example: https://pytorch.org/docs/stable/autograd.html#torch.autograd.Function)
/tmp/pip-req-build-808afw3c/torch/csrc/autograd/python_function.cpp:622: UserWarning: Legacy autograd function with non-static forward method is deprecated and will be removed in 1.3. Please use new-style autograd function with static forward method. (Example: https://pytorch.org/docs/stable/autograd.html#torch.autograd.Function)
/tmp/pip-req-build-808afw3c/torch/csrc/autograd/python_function.cpp:622: UserWarning: Legacy autograd function with non-static forward method is deprecated and will be removed in 1.3. Please use new-style autograd function with static forward method. (Example: https://pytorch.org/docs/stable/autograd.html#torch.autograd.Function)
Traceback (most recent call last):
File "demo.py", line 250, in
test_oneimage()
File "demo.py", line 245, in test_oneimage
det = bbox_vote(det)
File "demo.py", line 69, in bbox_vote
det_accu_sum[:, 0:4] = np.sum(det_accu[:, 0:4], axis=0) / np.sum(det_accu[:, -1:])
File "/home/kzezel/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/tensor.py", line 398, in rdiv
return self.reciprocal() * other
File "/home/kzezel/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/tensor.py", line 486, in array
return self.numpy()
TypeError: can't convert CUDA tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.

Hi Kevin, how did you resolve this error? I have exactly the same problem.

Hi Kevin, how did you resolve this error? I have exactly the same problem.

Me too

Hi Kevin, how did you resolve this error? I have exactly the same problem.

me too... :(

I am facing the same proble, has anyone figured it out ?

@gkrisp98
change face_ssd.py line 345 to:

         # output = self.detect(
               #   face_loc.view(face_loc.size(0), -1, 4),         # loc preds
               #   self.softmax(face_conf.view(face_conf.size(0), -1, self.num_classes)), # conf preds
               #   self.priors.type(type(x.data))                  # default boxes
               # )

               ###########################################################修改代码################################################################
               # Detect类不支持静态方法的前向传播,因此使用类直接调用方法
               output = self.detect.forward(face_loc.view(face_loc.size(0), -1, 4),
                                            self.softmax(face_conf.view(face_conf.size(0), -1, self.num_classes)),
                                            self.priors.type(type(x.data)))
               ###########################################################修改代码################################################################