DCPDN icon indicating copy to clipboard operation
DCPDN copied to clipboard

demo error(KeyError: 'module name can\'t contain "."')

Open arpita739 opened this issue 4 years ago • 4 comments

!python demo.py --dataroot ./facades/nat_new4 --valDataroot ./facades/nat_new4 --netG ./models/netG_epoch_8.pth %time ERROR Namespace(annealEvery=400, annealStart=0, batchSize=1, beta1=0.5, dataroot='./facades/nat_new4', dataset='pix2pix', display=5, evalIter=500, exp='sample', imageSize=1024, inputChannelSize=3, lambdaGAN=0.01, lambdaIMG=1, lrD=0.0002, lrG=0.0002, mode='B2A', ndf=64, netD='', netG='./models/netG_epoch_8.pth', ngf=64, niter=400, originalSize=1024, outputChannelSize=3, poolSize=50, valBatchSize=1, valDataroot='./facades/nat_new4', wd=0.0, workers=1) Random Seed: 6918 /usr/local/lib/python3.6/dist-packages/torchvision/transforms/transforms.py:211: UserWarning: The use of the transforms.Scale transform is deprecated, please use transforms.Resize instead. "please use transforms.Resize instead.") Traceback (most recent call last): File "demo.py", line 128, in netG = net.dehaze(inputChannelSize, outputChannelSize, ngf) File "/content/drive/My Drive/DCPDN-master/dehaze22.py", line 537, in init self.tran_est=G(input_nc=3,output_nc=3, nf=64) File "/content/drive/My Drive/DCPDN-master/dehaze22.py", line 88, in init layer2 = blockUNet(nf, nf*2, name, transposed=False, bn=True, relu=False, dropout=False) File "/content/drive/My Drive/DCPDN-master/dehaze22.py", line 56, in blockUNet block.add_module('%s.leakyrelu' % name, nn.LeakyReLU(0.2, inplace=True)) File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 196, in add_module raise KeyError("module name can't contain "."") KeyError: 'module name can't contain "."' CPU times: user 3 µs, sys: 1 µs, total: 4 µs Wall time: 5.72 µs

arpita739 avatar Jun 14 '20 16:06 arpita739

this is cause by pytorch version . you can try 1.13

beijing1214 avatar Jul 09 '20 08:07 beijing1214

@arpita739 could you share the weight download link, i can not download the weight from google

chenyao96 avatar Oct 27 '20 13:10 chenyao96

I avoided this by simply making 'KeyError("module name can't contain "."")' an annotation in torch.nn.modules.module. This semantic requirement of pytorch seems meaningless.

chenkhan avatar Apr 28 '21 09:04 chenkhan

Change '. 'to' _ '

QinuanZhu avatar Sep 16 '21 08:09 QinuanZhu