neuralchen / SimSwap

An arbitrary face-swapping framework on images and videos with one single trained model!
Other
4.41k stars 872 forks source link

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

Open desertzk opened 1 year ago

desertzk commented 1 year ago

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

JulesLiu commented 1 year ago

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 1 year ago

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.

JulesLiu commented 1 year ago

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 1 year ago

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 1 year ago

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

shidalao commented 1 year ago

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