Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnetSkipConnectionBlock Attribute Error #43

Open
ckavak opened this issue Jan 23, 2024 · 4 comments
Open

UnetSkipConnectionBlock Attribute Error #43

ckavak opened this issue Jan 23, 2024 · 4 comments

Comments

@ckavak
Copy link

ckavak commented Jan 23, 2024

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
Copy link

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
Copy link
Collaborator

SantJay commented Apr 24, 2024

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

@Danee-wawawa
Copy link

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
Copy link

dudi709 commented May 2, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants