bupt-ai-cz / LLVIP

LLVIP: A Visible-infrared Paired Dataset for Low-light Vision
610 stars 65 forks source link

UnetSkipConnectionBlock Attribute Error #43

Open ckavak opened 6 months ago

ckavak commented 6 months ago

Hello,

I am trying to run pix2pix model and getting this error:

python test.py --dataroot ./datasets/ --model pix2pix --direction AtoB --preprocess scale_width_and_crop --load_size 320 --crop_size 256

dataset [AlignedDataset] was created initialize network with normal model [Pix2PixModel] was created loading the model from ./checkpoints\experiment_name\latest_net_G.pth Traceback (most recent call last): File "D:\LLVIP-main\LLVIP-main\pix2pixGAN\test.py", line 47, in model.setup(opt) # regular setup: load and print networks; create schedulers File "D:\LLVIP-main\LLVIP-main\pix2pixGAN\models\base_model.py", line 88, in setup self.load_networks(load_suffix) File "D:\LLVIP-main\LLVIP-main\pix2pixGAN\models\base_model.py", line 198, in load_networks self.patch_instance_norm_state_dict(state_dict, net, key.split('.')) File "D:\LLVIP-main\LLVIP-main\pix2pixGAN\models\base_model.py", line 174, in patch_instance_norm_state_dict self.patch_instance_norm_state_dict(state_dict, getattr(module, key), keys, i + 1) File "D:\LLVIP-main\LLVIP-main\pix2pixGAN\models\base_model.py", line 174, in patch_instance_norm_state_dict self.patch_instance_norm_state_dict(state_dict, getattr(module, key), keys, i + 1) File "D:\LLVIP-main\LLVIP-main\pix2pixGAN\pix2pix_env\lib\site-packages\torch\nn\modules\module.py", line 1695, in getattr raise AttributeError(f"'{type(self).name__}' object has no attribute '{name}'") AttributeError: 'UnetSkipConnectionBlock' object has no attribute '1'

Danee-wawawa commented 2 months ago

Hi, I meet the same problem as you. I also encountered this error when I used the pre-trained model provided by the author as following. I would like to ask if you solved this problem later?

1713842931789
SantJay commented 2 months ago

Hello, you can try using a generator with resnet9 as the backbone network. This setting can be modified in the testing script.

Danee-wawawa commented 2 months ago

I don't think this is a solution because the '--netG' default setting in base_options.py is 'resnet_9blocks' as following: https://github.com/bupt-ai-cz/LLVIP/blob/main/pix2pixGAN/options/base_options.py#L35

I solved this problem in another way. I use the BCI code from another open-source project of your team and the pretrained model you provided, and this combination can run. Is this solution correct?

dudi709 commented 2 months ago

You need to add --netG resnet_9blocks to your command line, the default value in base_option.py is set to be resnet_9blocks but for some reason, the code accepts unet_256 as a default value. python test.py --dataroot ./datasets/LLVIP --name LLVIP --model pix2pix --direction AtoB --gpu_ids 0 --preprocess scale_width_and_crop --load_size 320 --crop_size 256 --netG resnet_9blocks works well for me.