InsightFace-v2 icon indicating copy to clipboard operation
InsightFace-v2 copied to clipboard

Attribute error in torch.nn.modules.module while applying the pretrained error.

Open mshakeelt opened this issue 4 years ago • 2 comments

I am applying the pretrained models on the images and encounted the following error, "torch.nn.modules.module.ModuleAttributeError: 'DataParallel' object has no attribute 'src_device_obj'". So far I am unable to resolve the error so please help me. Python version is 3.8.5 (I have also tried on 3.6) and torch version is 1.6.0. Thanks.

mshakeelt avatar Nov 22 '20 22:11 mshakeelt

What is it that you are doing that causes this error? by the way, last time I checked 1.5.1 was working fine and 1.6 caused my loss to go to nans! so apart from this, keep this in mind in case you faced nans!

Coderx7 avatar Dec 05 '20 16:12 Coderx7

Well, I was trying to generate feature vectors for images. In readme it is written to use megaface,py in which the model is being loaded like this ,

checkpoint = 'BEST_checkpoint.tar' print('loading model: {}...'.format(checkpoint)) checkpoint = torch.load(checkpoint) model = checkpoint['model'].to(device)

I was trying that, and was getting the error. but in lfw_eval.py the model is loaded differently, checkpoint = 'BEST_checkpoint.tar' checkpoint = torch.load(checkpoint) model = checkpoint['model'].module model = model.to(device) model.eval()

Well, this works now and I am able to apply the model. Thanks!

mshakeelt avatar Dec 06 '20 23:12 mshakeelt