FaceDetection-DSFD icon indicating copy to clipboard operation
FaceDetection-DSFD copied to clipboard

Use new-style autograd function with static forward method.

Open kevinzezel opened this issue 4 years ago • 6 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.

kevinzezel avatar May 05 '20 03:05 kevinzezel

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

chixiangw avatar Sep 21 '20 21:09 chixiangw

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

Me too

liuleiBUAA avatar Dec 09 '20 09:12 liuleiBUAA

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

me too... :(

hourieh77 avatar Jul 22 '21 06:07 hourieh77

Not yet

------------------ 原始邮件 ------------------ 发件人: "Tencent/FaceDetection-DSFD" @.>; 发送时间: 2021年7月22日(星期四) 下午2:34 @.>; @.@.>; 主题: Re: [Tencent/FaceDetection-DSFD] Use new-style autograd function with static forward method. (#63)

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

me too... :(

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

liuleiBUAA avatar Jul 22 '21 14:07 liuleiBUAA

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

gkrisp98 avatar Mar 14 '23 11:03 gkrisp98

@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)))
               ###########################################################修改代码################################################################

OceanWong1991 avatar Mar 22 '23 01:03 OceanWong1991