python - 如何让 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 帖子上看到有人成功地让它工作。
解决方案
推荐阅读
- python - 为什么 python 在不同设备上读取字典的方式不同,为什么不是从上到下?
- javascript - 适合弹出窗口在可视区域中的范围(传单)
- c# - 条件自动映射器不适用于 MapFrom
- firebase - ReferenceError:找不到变量:在 Expo 上使用 Firebase 时的 IDBIndex
- meteor - 有没有办法在使用 React 集成创建的流星项目中使用 Meteor's Blaze?
- sql-server - SQL Server - 如何根据插入为重复或类似内容设置行 ID。选择查询
- angular - 根据角度检查单选更改货币
- java - 在 maven 构建步骤中设置 JAVA_OPTS 以注入 JaCoCo 代理
- active-directory - ActiveMQ 共享访问的 AD 凭据
- typescript - 如何在 TypeScript 的这个复杂类型定义中提取泛型类型?