首页 > 解决方案 > 如何让 anonymizing_video_by_DSFD 运行

问题描述

我的目标是使用这个 GitHub 存储库来模糊我输入视频的面孔。

目前的进展和问题:我已经克隆了repo,然后熟悉了它。但是,当我尝试让它运行时,我不断收到错误消息,例如:

Traceback (most recent call last):
  File "demo.py", line 261, in <module> 
    test_oneimage()
  File "demo.py", line 230, in test_oneimage
    det0 = infer(net, img, transform, thresh, cuda, shrink)
  File "demo.py", line 107, in infer
    y = net(x)  # forward pass
  File "/home/lakeside/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/lakeside/Desktop/Anonymizing_video_by_DSFD/face_ssd.py", line 342, in forward
    output = self.detect(
  File "/home/lakeside/.local/lib/python3.8/site-packages/torch/autograd/function.py", line 159, in __call__
    raise RuntimeError(
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)

然后我尝试搜索解决此问题的解决方案,我尝试在 forward 方法之前添加@staticmethod并使用类似:

y = net.apply(x)

但后来它给了我错误:

demo.py:103: UserWarning: volatile was removed and now has no effect. Use `with torch.no_grad():` instead.
  x = Variable(x.unsqueeze(0), volatile=True)
Traceback (most recent call last):
  File "demo.py", line 261, in <module>
    test_oneimage()
  File "demo.py", line 230, in test_oneimage
    det0 = infer(net, img, transform, thresh, cuda, shrink)
  File "demo.py", line 107, in infer
    y = net.apply(x)  # forward pass
  File "/home/lakeside/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 473, in apply
    module.apply(fn)
  File "/home/lakeside/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 473, in apply
    module.apply(fn)
  File "/home/lakeside/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 474, in apply
    fn(self)
TypeError: 'Tensor' object is not callable

我试图弄清楚这一点,但到目前为止还没有运气。我在这个 Reddit 帖子上看到有人成功地让它工作。

标签: pythoncomputer-visionpytorchresnet

解决方案


推荐阅读