ssd.pytorch
ssd.pytorch copied to clipboard
non-static forward method will be removed in 1.3
Hi, the version of my pytorch is 1.3. and the python version is 3.6. when I run the code
y = net(x)
which is for the detection. the warning is arise: 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)
I am very confused about how to solve that problem, so is there anyone have a clue?
I have same problem like you. my torch version is 1.4.0. But it seems that the problem has no effect to training. have you solve it?
Degrade the pytorch version to 1.2.0 or below will solve this problem.
Hi, the version of my pytorch is 1.3. and the python version is 3.6. when I run the code
y = net(x)
which is for the detection. the warning is arise: 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)
I am very confused about how to solve that problem, so is there anyone have a clue? Did you get the solution ?
Hi, version of colab is PyTorch1.5.0, I modified detection.py and ssd.py. so that it works without warning and error.
Since detection.py have torch.autograd.Function, I delete def init() and add @staticmethod. I also add output = self.detect.apply() in ssd.py.
I share my code and you can find in '# PyTorch1.5.0 support new-style autograd function' in source. https://github.com/miyamotok0105/pytorch_handbook/blob/master/chapter7/layers/functions/detection.py
@ayukat1016 hello.I have modified the detection file.I am confused about where to add output = self.detection. apply() in the ssd.py file.
@fywsjz Hello. You can find in line 63, 123. https://github.com/miyamotok0105/pytorch_handbook/blob/master/chapter7/ssd.py
@ayukat1016 Thank you very much. It worked
Hi, version of colab is PyTorch1.5.0, I modified detection.py and ssd.py. so that it works without warning and error.
Since detection.py have torch.autograd.Function, I delete def init() and add @staticmethod. I also add output = self.detect.apply() in ssd.py.
I share my code and you can find in '# PyTorch1.5.0 support new-style autograd function' in source. https://github.com/miyamotok0105/pytorch_handbook/blob/master/chapter7/layers/functions/detection.py
うまく動作する様になりました、ありがとうございます!
Hi, version of colab is PyTorch1.5.0, I modified detection.py and ssd.py. so that it works without warning and error.
Since detection.py have torch.autograd.Function, I delete def init() and add @staticmethod. I also add output = self.detect.apply() in ssd.py.
I share my code and you can find in '# PyTorch1.5.0 support new-style autograd function' in source. https://github.com/miyamotok0105/pytorch_handbook/blob/master/chapter7/layers/functions/detection.py
Hi, it can work well like below:
Finished loading model!
im_detect: 1/4952 1.888s
im_detect: 2/4952 0.145s
...
Evaluating detections
Writing aeroplane VOC results file
Writing bicycle VOC results file
...
VOC07 metric? Yes
But after that, it will error:
Exception has occurred: KeyError at 317, eval.py
R = class_recs[image_ids[d]]
And here:
class_recs
{}
image_ids
['000002', '000002', '000002', '000002', '000002', '000002', '000003']
d
0
Do you know what here happening and can you help me? For the time being, I opened new issue here
I have not encountered the problem you described, you can try to find the answer in the issues at github, sorry for not being able to help you
| | 封亚炜 | | [email protected] | 签名由网易邮箱大师定制 On 5/28/2020 16:43,Shirui Zhang[email protected] wrote:
Hi, version of colab is PyTorch1.5.0, I modified detection.py and ssd.py. so that it works without warning and error.
Since detection.py have torch.autograd.Function, I delete def init() and add @staticmethod. I also add output = self.detect.apply() in ssd.py.
I share my code and you can find in '# PyTorch1.5.0 support new-style autograd function' in source. https://github.com/miyamotok0105/pytorch_handbook/blob/master/chapter7/layers/functions/detection.py
Hi, it can work well like below:
Finished loading model! im_detect: 1/4952 1.888s im_detect: 2/4952 0.145s ...
Evaluating detections Writing aeroplane VOC results file Writing bicycle VOC results file ...
VOC07 metric? Yes
But after that, it will error: Exception has occurred: KeyError at 317, eval.py R = class_recs[image_ids[d]]
And here:
class_recs {}
image_ids ['000002', '000002', '000002', '000002', '000002', '000002', '000003']
d 0
Do you know what here happening and can you help me?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.
I have not encountered the problem you described, you can try to find the answer in the issues at github, sorry for not being able to help you | | 封亚炜 | | [email protected] | 签名由网易邮箱大师定制 On 5/28/2020 16:43,Shirui Zhang[email protected] wrote: Hi, version of colab is PyTorch1.5.0, I modified detection.py and ssd.py. so that it works without warning and error. Since detection.py have torch.autograd.Function, I delete def init() and add @staticmethod. I also add output = self.detect.apply() in ssd.py. I share my code and you can find in '# PyTorch1.5.0 support new-style autograd function' in source. https://github.com/miyamotok0105/pytorch_handbook/blob/master/chapter7/layers/functions/detection.py Hi, it can work well like below: Finished loading model! im_detect: 1/4952 1.888s im_detect: 2/4952 0.145s ... Evaluating detections Writing aeroplane VOC results file Writing bicycle VOC results file ... VOC07 metric? Yes But after that, it will error: Exception has occurred: KeyError at 317, eval.py R = class_recs[image_ids[d]] And here: class_recs {} image_ids ['000002', '000002', '000002', '000002', '000002', '000002', '000003'] d 0 Do you know what here happening and can you help me? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.
Thanks anyway.
Hi, version of colab is PyTorch1.5.0, I modified detection.py and ssd.py. so that it works without warning and error.
Since detection.py have torch.autograd.Function, I delete def init() and add @staticmethod. I also add output = self.detect.apply() in ssd.py.
I share my code and you can find in '# PyTorch1.5.0 support new-style autograd function' in source. https://github.com/miyamotok0105/pytorch_handbook/blob/master/chapter7/layers/functions/detection.py
Hi, I modified
detection.py
and
ssd.py
as yours.
Then I tried running eval.py, and actually got this problem:
RuntimeError: CUDA out of memory. Tried to allocate 4.08 GiB (GPU 0; 8.00 GiB total capacity; 200.34 MiB already allocated; 5.04 GiB free; 958.00 MiB reserved in total by PyTorch)
The GPU on the machine is 2070 super. In my opinion, its performance should be sufficient.
Then also I tried running eval.py by --cuda False,
and it can run:
...
im_detect: 997/4952 0.320s
im_detect: 998/4952 0.343s
...
Why can't it run on GPU? Do you have any ideas?
Win 10 Python 3.6.8 Pytorch 1.5.1 Cuda V11.0.167
@fywsjz Hello. You can find in line 63, 123. https://github.com/miyamotok0105/pytorch_handbook/blob/master/chapter7/ssd.py
Hi, version of colab is PyTorch1.5.0, I modified detection.py and ssd.py. so that it works without warning and error. Since detection.py have torch.autograd.Function, I delete def init() and add @staticmethod. I also add output = self.detect.apply() in ssd.py. I share my code and you can find in '# PyTorch1.5.0 support new-style autograd function' in source. https://github.com/miyamotok0105/pytorch_handbook/blob/master/chapter7/layers/functions/detection.py
うまく動作する様になりました、ありがとうございます!
thank you so much for solving this error!!
Hi, version of colab is PyTorch1.5.0, I modified detection.py and ssd.py. so that it works without warning and error.
Since detection.py have torch.autograd.Function, I delete def init() and add @staticmethod. I also add output = self.detect.apply() in ssd.py.
I share my code and you can find in '# PyTorch1.5.0 support new-style autograd function' in source. https://github.com/miyamotok0105/pytorch_handbook/blob/master/chapter7/layers/functions/detection.py
Thank you so much!
I got a easy way out:
just mordify the base class of Detect to 'object', and then modify the code in ssd.py:
if self.phase == "test": with torch.no_grad(): output = self.detect.forward( loc.view(loc.size(0), -1, 4), # loc preds self.softmax(conf.view(conf.size(0), -1, self.num_classes)), # conf preds self.priors.type(type(x.data)) # default boxes )
@fywsjz Hello. You can find in line 63, 123. https://github.com/miyamotok0105/pytorch_handbook/blob/master/chapter7/ssd.py
thanks,i solve my issue
Hi, version of colab is PyTorch1.5.0, I modified detection.py and ssd.py. so that it works without warning and error.
Since detection.py have torch.autograd.Function, I delete def init() and add @staticmethod. I also add output = self.detect.apply() in ssd.py.
I share my code and you can find in '# PyTorch1.5.0 support new-style autograd function' in source. https://github.com/miyamotok0105/pytorch_handbook/blob/master/chapter7/layers/functions/detection.py
I have question, in pytorch1.5.0, must implement backward, but the class Detect() has no backward function,why? RuntimeError: You must implement the backward function for custom autograd.Function.
FYI: I heard from my colleague that this error was circumvented by changing
self.detect = Detect(num_classes, 0, 200, 0.01, 0.45)
to
self.detect = Detect(num_classes, 0, 200, 0.01, 0.45).forward
(i.e., just attaching .foward) in ssd.py. https://github.com/amdegroot/ssd.pytorch/blob/master/ssd.py#L48