train error in colab TypeError: 'ResNet' object is not subscriptable #416

Open
opened 2023-05-29 14:58:27 +02:00 by desertzk · 6 comments
desertzk commented 2023-05-29 14:58:27 +02:00 (Migrated from github.com)

Traceback (most recent call last):
File "/content/SimSwap/train.py", line 139, in
model.initialize(opt)
File "/content/SimSwap/models/projected_model.py", line 49, in initialize
self.netArc = netArc_checkpoint['model'].module
TypeError: 'ResNet' object is not subscriptable

Traceback (most recent call last): File "/content/SimSwap/train.py", line 139, in <module> model.initialize(opt) File "/content/SimSwap/models/projected_model.py", line 49, in initialize self.netArc = netArc_checkpoint['model'].module TypeError: 'ResNet' object is not subscriptable
JulesLiu commented 2023-05-30 20:49:17 +02:00 (Migrated from github.com)

If I remember it correctly, I used the solution by the wonderful guy's (@WondererGuy) in #404 , and solved.

Quote: "in projected_model.py , you can fix ' self.netArc = netArc_checkpoint['model'].module' to ' self.netArc = netArc_checkpoint' , i think due to new 'arcface_checkpoint.tar' which author update to solve SGD problem makes ResNet not subscriptable anymore. My fix is inspired from author change in fs_model.py in update of SGD problem from ' self.netArc = netArc_checkpoint['model'].module' to 'self.netArc = netArc_checkpoint' , also train.py depends on projected_model.py so i change projected_model.py like i showed. I still new to this so might not be right, but it helps me overcome this bug , hope it helps you too. p/s: im using unzipped vggface2_crop_arcfacealign_224.tar to train"

If I remember it correctly, I used the solution by the wonderful guy's (@WondererGuy) in #404 , and solved. Quote: "in projected_model.py , you can fix ' self.netArc = netArc_checkpoint['model'].module' to ' self.netArc = netArc_checkpoint' , i think due to new 'arcface_checkpoint.tar' which author update to solve SGD problem makes ResNet not subscriptable anymore. My fix is inspired from author change in fs_model.py in update of SGD problem from ' self.netArc = netArc_checkpoint['model'].module' to 'self.netArc = netArc_checkpoint' , also train.py depends on projected_model.py so i change projected_model.py like i showed. I still new to this so might not be right, but it helps me overcome this bug , hope it helps you too. p/s: im using unzipped vggface2_crop_arcfacealign_224.tar to train"
desertzk commented 2023-05-31 15:37:05 +02:00 (Migrated from github.com)

Thanks JulesLiu that works but the follow error comes
'EfficientNet' object has no attribute 'act1'
File "D:\pythonworkspace\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 "D:\pythonworkspace\SimSwap\pg_modules\projector.py", line 64, in _make_projector
pretrained = _make_efficientnet(model)
File "D:\pythonworkspace\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 "D:\pythonworkspace\SimSwap\pg_modules\projected_discriminator.py", line 161, in init
self.feature_network = F_RandomProj(**backbone_kwargs)
File "D:\pythonworkspace\SimSwap\models\projected_model.py", line 58, in initialize
self.netD = ProjectedDiscriminator(diffaug=False, interp224=False, **{})
File "D:\pythonworkspace\SimSwap\train.py", line 139, in
model.initialize(opt)
AttributeError: 'EfficientNet' object has no attribute 'act1'

I think maybe the model are changed.

Thanks JulesLiu that works but the follow error comes 'EfficientNet' object has no attribute 'act1' File "D:\pythonworkspace\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 "D:\pythonworkspace\SimSwap\pg_modules\projector.py", line 64, in _make_projector pretrained = _make_efficientnet(model) File "D:\pythonworkspace\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 "D:\pythonworkspace\SimSwap\pg_modules\projected_discriminator.py", line 161, in __init__ self.feature_network = F_RandomProj(**backbone_kwargs) File "D:\pythonworkspace\SimSwap\models\projected_model.py", line 58, in initialize self.netD = ProjectedDiscriminator(diffaug=False, interp224=False, **{}) File "D:\pythonworkspace\SimSwap\train.py", line 139, in <module> model.initialize(opt) AttributeError: 'EfficientNet' object has no attribute 'act1' I think maybe the model are changed.
JulesLiu commented 2023-05-31 22:51:44 +02:00 (Migrated from github.com)

Thanks JulesLiu that works but the follow error comes 'EfficientNet' object has no attribute 'act1' File "D:\pythonworkspace\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 "D:\pythonworkspace\SimSwap\pg_modules\projector.py", line 64, in _make_projector pretrained = _make_efficientnet(model) File "D:\pythonworkspace\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 "D:\pythonworkspace\SimSwap\pg_modules\projected_discriminator.py", line 161, in init self.feature_network = F_RandomProj(**backbone_kwargs) File "D:\pythonworkspace\SimSwap\models\projected_model.py", line 58, in initialize self.netD = ProjectedDiscriminator(diffaug=False, interp224=False, **{}) File "D:\pythonworkspace\SimSwap\train.py", line 139, in model.initialize(opt) AttributeError: 'EfficientNet' object has no attribute 'act1'

I think maybe the model are changed.

With pleasure. And that's what happened to me, solved one error, then a new one, for now I'm stuck at no images were loaded/recognized. For this act1 error, you may check #307 .

> Thanks JulesLiu that works but the follow error comes 'EfficientNet' object has no attribute 'act1' File "D:\pythonworkspace\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 "D:\pythonworkspace\SimSwap\pg_modules\projector.py", line 64, in _make_projector pretrained = _make_efficientnet(model) File "D:\pythonworkspace\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 "D:\pythonworkspace\SimSwap\pg_modules\projected_discriminator.py", line 161, in **init** self.feature_network = F_RandomProj(**backbone_kwargs) File "D:\pythonworkspace\SimSwap\models\projected_model.py", line 58, in initialize self.netD = ProjectedDiscriminator(diffaug=False, interp224=False, **{}) File "D:\pythonworkspace\SimSwap\train.py", line 139, in model.initialize(opt) AttributeError: 'EfficientNet' object has no attribute 'act1' > > I think maybe the model are changed. With pleasure. And that's what happened to me, solved one error, then a new one, for now I'm stuck at no images were loaded/recognized. For this act1 error, you may check #307 .
desertzk commented 2023-06-01 15:16:46 +02:00 (Migrated from github.com)

thanks for the help I solve it.but I don't encount no images load problem. the training start I think maybe you can check dataset path.

thanks for the help I solve it.but I don't encount no images load problem. the training start I think maybe you can check dataset path.
MicheleDaVinci commented 2023-06-18 16:15:19 +02:00 (Migrated from github.com)

Hello there are problems with the training both locally and in colab, I hope it will be solved as soon as possible thanks in advance good work.

Screenshot 2023-06-18

Hello there are problems with the training both locally and in colab, I hope it will be solved as soon as possible thanks in advance good work. ![Screenshot 2023-06-18](https://github.com/neuralchen/SimSwap/assets/136981250/7f346484-d9f8-4054-b561-18d07a740fb9)
shidalao commented 2023-08-10 11:07:34 +02:00 (Migrated from github.com)
https://github.com/neuralchen/SimSwap/issues/426#issuecomment-1672843900
Sign in to join this conversation.