simple-faster-rcnn-pytorch
simple-faster-rcnn-pytorch copied to clipboard
RuntimeError: Legacy autograd function with non-static forward method is deprecated.
RuntimeError: Legacy autograd function with non-static forward method is deprecated. Please use new-style autograd function with static forward method. (Example: https://pytorch.org/docs/stable/autograd.html#torch.autograd.Function)
升级了torch和torchvision版本,又降低了torch和torchvision版本都不行 求解决办法
遇到同样问题 怎么解决的?
其实这个就是torch版本的问题, specify torchvision==0.4.0就可以解决
pip uninstall torchvision
pip uninstall torch
pip install torchvision==0.4.0
torchvision==0.4.0会自动安装1.2版本的pytorch,安装好之后重启一下environment就可以运行了
感谢 tobyatgithub 的帮助
I changed RoIPooling2D here to:
class RoIPooling2D(t.nn.Module):
def __init__(self, outh, outw, spatial_scale):
super(RoIPooling2D, self).__init__()
self.outh, self.outw, self.spatial_scale = outh, outw, spatial_scale
def forward(self, x, rois):
return roi_pool(x, rois, (self.outh, self.outw), self.spatial_scale)
I also did from torchvision.ops import roi_pool in the same file. This looks to me solve the problem.
I changed
RoIPooling2Dhere to:class RoIPooling2D(t.nn.Module): def __init__(self, outh, outw, spatial_scale): super(RoIPooling2D, self).__init__() self.outh, self.outw, self.spatial_scale = outh, outw, spatial_scale def forward(self, x, rois): return roi_pool(x, rois, (self.outh, self.outw), self.spatial_scale)I also did
from torchvision.ops import roi_poolin the same file. This looks to me solve the problem.
Problem solved, thank you!