当前位置: 代码迷 >> 综合 >> 调用预训练vgg模型参数问题'NoneType' object is not callable
  详细解决方案

调用预训练vgg模型参数问题'NoneType' object is not callable

热度:18   发布时间:2024-01-24 08:20:57.0

调用预训练vgg模型参数问题’NoneType’ object is not callable

报错如下

Traceback (most recent call last):File "train.py", line 50, in <module>init_vgg16('./')File "/home/aistudio/work/utils.py", line 52, in init_vgg16for (src, dst) in zip(vgglua.parameters()[0], vgg.parameters()):
TypeError: 'NoneType' object is not callable

用的DID-MDN 代码,去雨模型,用了vgg16感知损失代码如下

def init_vgg16(model_folder):"""load the vgg16 model feature"""if not os.path.exists(os.path.join(model_folder, 'vgg16.weight')):if not os.path.exists(os.path.join(model_folder, 'vgg16.t7')):os.system('wget http://cs.stanford.edu/people/jcjohns/fast-neural-style/models/vgg16.t7 -O ' + os.path.join(model_folder, 'vgg16.t7'))vgglua = torchfile.load(os.path.join(model_folder, 'vgg16.t7'))vgg = Vgg16()print(type(vgglua))for (src, dst) in zip(vgglua.parameters()[0], vgg.parameters()):dst.data[:] = srctorch.save(vgg.state_dict(), os.path.join(model_folder, 'vgg16.weight'))

因为用了云虚拟机 直接下载vgg16太慢而且不能保存,想预先下载好模型参数这样,但是这个报错求大神。。。。

  相关解决方案