SimSwap icon indicating copy to clipboard operation
SimSwap copied to clipboard

AttributeError: 'EfficientNet' object has no attribute 'act1'

Open Deerzh opened this issue 1 year ago • 7 comments

when I run this command: python train.py --name simswap224_test --batchSize 8 --gpu_ids 1 --dataset vggface2 --Gdeep False an erroe occurred: /home/zhang/anaconda3/envs/Sim/lib/python3.7/site-packages/torch/serialization.py:656: SourceChangeWarning: source code of class 'torch.nn.parallel.data_parallel.DataParallel' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes. warnings.warn(msg, SourceChangeWarning) /home/zhang/anaconda3/envs/Sim/lib/python3.7/site-packages/torch/serialization.py:656: SourceChangeWarning: source code of class 'torch.nn.modules.conv.Conv2d' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes. warnings.warn(msg, SourceChangeWarning) /home/zhang/anaconda3/envs/Sim/lib/python3.7/site-packages/torch/serialization.py:656: SourceChangeWarning: source code of class 'torch.nn.modules.batchnorm.BatchNorm2d' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes. warnings.warn(msg, SourceChangeWarning) /home/zhang/anaconda3/envs/Sim/lib/python3.7/site-packages/torch/serialization.py:656: SourceChangeWarning: source code of class 'torch.nn.modules.activation.PReLU' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes. warnings.warn(msg, SourceChangeWarning) /home/zhang/anaconda3/envs/Sim/lib/python3.7/site-packages/torch/serialization.py:656: SourceChangeWarning: source code of class 'torch.nn.modules.pooling.MaxPool2d' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes. warnings.warn(msg, SourceChangeWarning) /home/zhang/anaconda3/envs/Sim/lib/python3.7/site-packages/torch/serialization.py:656: SourceChangeWarning: source code of class 'torch.nn.modules.container.Sequential' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes. warnings.warn(msg, SourceChangeWarning) /home/zhang/anaconda3/envs/Sim/lib/python3.7/site-packages/torch/serialization.py:656: SourceChangeWarning: source code of class 'torch.nn.modules.pooling.AdaptiveAvgPool2d' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes. warnings.warn(msg, SourceChangeWarning) /home/zhang/anaconda3/envs/Sim/lib/python3.7/site-packages/torch/serialization.py:656: SourceChangeWarning: source code of class 'torch.nn.modules.linear.Linear' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes. warnings.warn(msg, SourceChangeWarning) /home/zhang/anaconda3/envs/Sim/lib/python3.7/site-packages/torch/serialization.py:656: SourceChangeWarning: source code of class 'torch.nn.modules.activation.Sigmoid' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes. warnings.warn(msg, SourceChangeWarning) /home/zhang/anaconda3/envs/Sim/lib/python3.7/site-packages/torch/serialization.py:656: SourceChangeWarning: source code of class 'torch.nn.modules.dropout.Dropout' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes. warnings.warn(msg, SourceChangeWarning) /home/zhang/anaconda3/envs/Sim/lib/python3.7/site-packages/torch/serialization.py:656: SourceChangeWarning: source code of class 'torch.nn.modules.batchnorm.BatchNorm1d' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes. warnings.warn(msg, SourceChangeWarning) Traceback (most recent call last): File "train.py", line 139, in model.initialize(opt) File "/home/zhang/compatibility_analysis/SimSwap/models/projected_model.py", line 57, in initialize self.netD = ProjectedDiscriminator(diffaug=False, interp224=False, **{}) File "/home/zhang/compatibility_analysis/SimSwap/pg_modules/projected_discriminator.py", line 161, in init self.feature_network = F_RandomProj(**backbone_kwargs) File "/home/zhang/compatibility_analysis/SimSwap/pg_modules/projector.py", line 108, in init self.pretrained, self.scratch = _make_projector(im_res=im_res, cout=self.cout, proj_type=self.proj_type, expand=self.expand) File "/home/zhang/compatibility_analysis/SimSwap/pg_modules/projector.py", line 64, in _make_projector pretrained = _make_efficientnet(model) File "/home/zhang/compatibility_analysis/SimSwap/pg_modules/projector.py", line 35, in _make_efficientnet pretrained.layer0 = nn.Sequential(model.conv_stem, model.bn1, model.act1, *model.blocks[0:2]) File "/home/zhang/anaconda3/envs/Sim/lib/python3.7/site-packages/torch/nn/modules/module.py", line 948, in getattr type(self).name, name)) AttributeError: 'EfficientNet' object has no attribute 'act1'

Can you help me solve this issue?

Deerzh avatar Aug 15 '22 04:08 Deerzh

https://github.com/neuralchen/SimSwap/issues/307#issuecomment-1198829625

LAFLAMIE1024 avatar Aug 15 '22 07:08 LAFLAMIE1024

https://github.com/neuralchen/SimSwap/blob/dd1ecdd2a718636d33977ab3097a69a0ecf080d8/pg_modules/projector.py#L35

LAFLAMIE1024 avatar Aug 15 '22 07:08 LAFLAMIE1024

Thank you for you reply, I have run it successfully. But now I have new question, because I just want to run it successfully and finish the train process as fast as possible, so I modify epoch=1 and total_step=500,then an orror occurred: "See the documentation of nn.Upsample for details.".format(mode) ( step: 199, ) G_Loss: 7.392 G_ID: 0.942 G_Rec: 11.906 G_feat_match: 2.901 D_fake: 0.006 D_real: 0.144 D_loss: 0.150 ( step: 399, ) G_Loss: 5.804 G_ID: 1.007 G_Rec: 10.470 G_feat_match: 2.805 D_fake: 0.033 D_real: 0.025 D_loss: 0.058 Traceback (most recent call last): File "train.py", line 290, in wandb.finish() NameError: name 'wandb' is not defined.

Can you help me fixed this issue?

Deerzh avatar Aug 15 '22 08:08 Deerzh

I have solved this problem by the follwing steps: pip install wandb. And add import wandb in train.py

Deerzh avatar Aug 15 '22 08:08 Deerzh

actually no need to install wandb. as the author doesn't use it at all. I just comment it

LAFLAMIE1024 avatar Aug 18 '22 06:08 LAFLAMIE1024

Use: pip3 install -U timm==0.5.4

Semihal avatar Sep 16 '22 14:09 Semihal

https://github.com/neuralchen/SimSwap/issues/426#issuecomment-1672843900

shidalao avatar Aug 10 '23 09:08 shidalao