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

Open
opened 2022-08-15 06:02:06 +02:00 by Deerzh · 7 comments
Deerzh commented 2022-08-15 06:02:06 +02:00 (Migrated from github.com)

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?

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 <module> 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?
MARCOCHEUNG0124 commented 2022-08-15 09:15:33 +02:00 (Migrated from github.com)
https://github.com/neuralchen/SimSwap/issues/307#issuecomment-1198829625
MARCOCHEUNG0124 commented 2022-08-15 09:20:30 +02:00 (Migrated from github.com)
https://github.com/neuralchen/SimSwap/blob/dd1ecdd2a718636d33977ab3097a69a0ecf080d8/pg_modules/projector.py#L35
Deerzh commented 2022-08-15 10:24:36 +02:00 (Migrated from github.com)

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?

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 <module> wandb.finish() NameError: name 'wandb' is not defined. Can you help me fixed this issue?
Deerzh commented 2022-08-15 10:56:05 +02:00 (Migrated from github.com)

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

> I have solved this problem by the follwing steps: pip install wandb. And add import wandb in train.py
MARCOCHEUNG0124 commented 2022-08-18 08:51:14 +02:00 (Migrated from github.com)

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

actually no need to install wandb. as the author doesn't use it at all. I just comment it
Semihal commented 2022-09-16 16:38:12 +02:00 (Migrated from github.com)

Use: pip3 install -U timm==0.5.4

Use: `pip3 install -U timm==0.5.4`
shidalao commented 2023-08-10 11:10:00 +02:00 (Migrated from github.com)
https://github.com/neuralchen/SimSwap/issues/426#issuecomment-1672843900
Sign in to join this conversation.