QUestion about inference
DaddyWesker opened this issue · comments
Hello.
THanks for your code. I've tried to run your code on webcam and for that i've needed to load model properly from pretrained weights. I've took a look into your train_emotions-pytorch
and sought that you're loading model as
model=timm.create_model('tf_efficientnet_b0_ns', pretrained=False)
model.classifier=torch.nn.Identity()
model.load_state_dict(torch.load('../models/pretrained_faces/state_vggface2_enet0_new.pt'))
Then you're adding model.classifier=nn.Sequential(nn.Linear(in_features=1280, out_features=num_classes))
and training your model. If i got it right, you're providing pre-trained weights at the models/affectnet_emotions
folder. But question is, how to load them? I've thought it should be something like this
model=timm.create_model('tf_efficientnet_b0_ns', pretrained=False)
model.classifier=nn.Sequential(nn.Linear(in_features=1280, out_features=8))
model.load_state_dict(torch.load('../models/affectnet_emotions/enet_b0_8_best_afew.pt'))
But no, i've got an error. AttributeError: 'EfficientNet' object has no attribute 'copy'
. So my guess is wrong then. Should i load it some different way? THanks in advance.
Hm. THanks. It works. Strange, i thought it won't work without model class with just "torch.load". But i guess i won't comply about that =)