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

AttributeError: 'ACE' object has no attribute 'fc_mu105' #46

Open
infinityrgb opened this issue May 4, 2022 · 6 comments
Open

AttributeError: 'ACE' object has no attribute 'fc_mu105' #46

infinityrgb opened this issue May 4, 2022 · 6 comments

Comments

@infinityrgb
Copy link

Traceback (most recent call last):
File "train.py", line 47, in
trainer.run_generator_one_step(data_i)
File "/d6295745ef534beab3ce2490bedcd8ab/lxy/inkpaint/SEAN/trainers/pix2pix_trainer.py", line 35, in run_generator_one_step
g_losses, generated = self.pix2pix_model(data, mode='generator')
File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 541, in call
result = self.forward(*input, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/torch/nn/parallel/data_parallel.py", line 150, in forward
return self.module(*inputs[0], **kwargs[0])
File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 541, in call
result = self.forward(*input, **kwargs)
File "/d6295745ef534beab3ce2490bedcd8ab/lxy/inkpaint/SEAN/models/pix2pix_model.py", line 45, in forward
input_semantics, real_image)
File "/d6295745ef534beab3ce2490bedcd8ab/lxy/inkpaint/SEAN/models/pix2pix_model.py", line 144, in compute_generator_loss
input_semantics, real_image, compute_kld_loss=self.opt.use_vae)
File "/d6295745ef534beab3ce2490bedcd8ab/lxy/inkpaint/SEAN/models/pix2pix_model.py", line 196, in generate_fake
fake_image = self.netG(input_semantics, real_image)
File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 541, in call
result = self.forward(*input, **kwargs)
File "/d6295745ef534beab3ce2490bedcd8ab/lxy/inkpaint/SEAN/models/networks/generator.py", line 84, in forward
x = self.head_0(x, seg, style_codes, obj_dic=obj_dic)
File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 541, in call
result = self.forward(*input, **kwargs)
File "/d6295745ef534beab3ce2490bedcd8ab/lxy/inkpaint/SEAN/models/networks/architecture.py", line 75, in forward
dx = self.ace_0(x, seg, style_codes, obj_dic)
File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 541, in call
result = self.forward(*input, **kwargs)
File "/d6295745ef534beab3ce2490bedcd8ab/lxy/inkpaint/SEAN/models/networks/normalization.py", line 157, in forward
middle_mu = F.relu(self.getattr('fc_mu' + str(j))(style_codes[i][j]))
File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 585, in getattr
type(self).name, name))
AttributeError: 'ACE' object has no attribute 'fc_mu105'

I have meet this question, someone can help me?

@zmehdiz97
Copy link

zmehdiz97 commented Jul 1, 2022

You probably have less than 105 labels in you datset. Try --label_nc 104

@omaralvarez
Copy link

I have the same issue, when changing the number of labels from the default 19 to 42 it errors out similarly, looks like label_nc changes are not properly supported:

middle_mu = F.relu(self.__getattr__('fc_mu' + str(j))(style_codes[i][j])) File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1130, in __getattr__ raise AttributeError("'{}' object has no attribute '{}'".format( AttributeError: 'ACE' object has no attribute 'fc_mu19'

I have double and triple checked that my dataset is properly formatted according to the author guidelines.

@omaralvarez
Copy link

Yes, exactly, you need to modify the code in normalization.py for it to work with more labels. I'll try to make a pull request to fix it.

@fido20160817
Copy link

Yes, exactly, you need to modify the code in normalization.py for it to work with more labels. I'll try to make a pull request to fix it.

How to change? can you give me some tips?

@omaralvarez
Copy link

omaralvarez commented Jun 5, 2023

As you can see in:

self.fc_mu0 = nn.Linear(style_length, style_length)
self.fc_mu1 = nn.Linear(style_length, style_length)
self.fc_mu2 = nn.Linear(style_length, style_length)
self.fc_mu3 = nn.Linear(style_length, style_length)
self.fc_mu4 = nn.Linear(style_length, style_length)
self.fc_mu5 = nn.Linear(style_length, style_length)
self.fc_mu6 = nn.Linear(style_length, style_length)
self.fc_mu7 = nn.Linear(style_length, style_length)
self.fc_mu8 = nn.Linear(style_length, style_length)
self.fc_mu9 = nn.Linear(style_length, style_length)
self.fc_mu10 = nn.Linear(style_length, style_length)
self.fc_mu11 = nn.Linear(style_length, style_length)
self.fc_mu12 = nn.Linear(style_length, style_length)
self.fc_mu13 = nn.Linear(style_length, style_length)
self.fc_mu14 = nn.Linear(style_length, style_length)
self.fc_mu15 = nn.Linear(style_length, style_length)
self.fc_mu16 = nn.Linear(style_length, style_length)
self.fc_mu17 = nn.Linear(style_length, style_length)
self.fc_mu18 = nn.Linear(style_length, style_length)

There are only 19 fc_muXX, if you want more classes you need to add more, if not it will error out. There are more hardcoded things throughout the repo, so be on the lookout, I wish I could enumerate every single one, but it has been a while since I dealt with this codebase.

@fido20160817
Copy link

fido20160817 commented Jun 6, 2023

As you can see in:

self.fc_mu0 = nn.Linear(style_length, style_length)
self.fc_mu1 = nn.Linear(style_length, style_length)
self.fc_mu2 = nn.Linear(style_length, style_length)
self.fc_mu3 = nn.Linear(style_length, style_length)
self.fc_mu4 = nn.Linear(style_length, style_length)
self.fc_mu5 = nn.Linear(style_length, style_length)
self.fc_mu6 = nn.Linear(style_length, style_length)
self.fc_mu7 = nn.Linear(style_length, style_length)
self.fc_mu8 = nn.Linear(style_length, style_length)
self.fc_mu9 = nn.Linear(style_length, style_length)
self.fc_mu10 = nn.Linear(style_length, style_length)
self.fc_mu11 = nn.Linear(style_length, style_length)
self.fc_mu12 = nn.Linear(style_length, style_length)
self.fc_mu13 = nn.Linear(style_length, style_length)
self.fc_mu14 = nn.Linear(style_length, style_length)
self.fc_mu15 = nn.Linear(style_length, style_length)
self.fc_mu16 = nn.Linear(style_length, style_length)
self.fc_mu17 = nn.Linear(style_length, style_length)
self.fc_mu18 = nn.Linear(style_length, style_length)

There are only 19 fc_muXX, if you want more classes you need to add more, if not it will error out. There are more hardcoded things throughout the repo, so be on the lookout, I wish I could enumerate every single one, but it has been a while since I dealt with this codebase.

I see. I used following codes to help generate these sentences and paste them to 'normalization.py' and set the num of classes ahead.

generated_list_txt=open('more_fc_mu.txt', mode='a+')
for i in range(151):
  generated_list_txt.writelines(f'self.fc_mu{i} = nn.Linear(style_length, style_length)' + '\n') 

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