kaiwang960112 / Challenge-condition-FER-dataset

This is our collected datasets for challenge condition facial expression recognition
252 stars 62 forks source link

Problems when inferring #41

Open DaddyWesker opened 3 years ago

DaddyWesker commented 3 years ago

Hello.

THanks for your code. I've tried to use your uploaded model "ijba_res18_naive.pth.tar" to infer using script FERplus_dir/test_rank_loss_attention.py, but i've got error on the line

model.load_state_dict(checkpoint['state_dict'])

Here is the error

RuntimeError: Error(s) in loading state_dict for DataParallel:
    Missing key(s) in state_dict: "module.alpha.0.weight", "module.alpha.0.bias", "module.beta.0.weight", "module.beta.0.bias". 
    Unexpected key(s) in state_dict: "module.feature.weight", "module.feature.bias". 
    size mismatch for module.fc.weight: copying a param with shape torch.Size([87020, 256]) from checkpoint, the shape in current model is torch.Size([8, 512]).
    size mismatch for module.fc.bias: copying a param with shape torch.Size([87020]) from checkpoint, the shape in current model is torch.Size([8]).

Probably i'm doing something wrong and this file "ijba_res18_naive.pth.tar" should be used somewhere else. Will be glad to hear some advises.

DaddyWesker commented 3 years ago

Well, i've looked on the train_attention_rank_loss.py and have found how to load model. So, i'm loading it like this now

model = resnet18(end2end=True)
model = torch.nn.DataParallel(model).cuda()
checkpoint = torch.load('/home/SingularityNet/EmotionRecognition/Challenge-condition-FER-dataset/ijba_res18_naive.pth.tar')
pretrained_state_dict = checkpoint['state_dict']
model_state_dict = model.state_dict()
for key in pretrained_state_dict:
    if ((key == 'module.fc.weight') | (key == 'module.fc.bias')):
        pass
    else:
        model_state_dict[key] = pretrained_state_dict[key]
model.load_state_dict(model_state_dict, strict=False)
model.eval()

If i got it right, i need then send 6 concatenated images to the model. And it should be images of different cropped parts of the one image. SHould they (parts) be random crops? Also, what is the image_size? I've got images 640x480 and, if i got it right, resulting tensor in my case should be [1, 3, 480, 640, 6]? Or something else?

kaiwang960112 commented 3 years ago

Can you send the problem to my gmail? @.***

DaddyWesker @.***>于2021年7月27日 周二下午4:43写道:

Well, i've looked on the train_attention_rank_loss.py and have found how to load model. So, i'm loading it like this now

model = resnet18(end2end=True) model = torch.nn.DataParallel(model).cuda() checkpoint = torch.load('/home/SingularityNet/EmotionRecognition/Challenge-condition-FER-dataset/ijba_res18_naive.pth.tar') pretrained_state_dict = checkpoint['state_dict'] model_state_dict = model.state_dict() for key in pretrained_state_dict: if ((key == 'module.fc.weight') | (key == 'module.fc.bias')): pass else: model_state_dict[key] = pretrained_state_dict[key] model.load_state_dict(model_state_dict, strict=False) model.eval()

If i got it right, i need then send 6 concatenated images to the model. And it should be images of different cropped parts of the one image. SHould they (parts) be random crops? Also, what is the image_size? I've got images 640x480 and, if i got it right, resulting tensor in my case should be [1, 3, 480, 640, 6]? Or something else?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kaiwang960112/Challenge-condition-FER-dataset/issues/41#issuecomment-887328429, or unsubscribe https://github.com/notifications/unsubscribe-auth/AI6LK4B7KRTZNF5NF4CBEITTZZWU5ANCNFSM5A7NPT3Q .

DaddyWesker commented 3 years ago

@kaiwang960112 What is your gmail? And what should i send? Just everything i've stated here or something else?

kaiwang960112 commented 3 years ago

Yes my email is @.***

DaddyWesker @.***>于2021年7月27日 周二下午5:49写道:

@kaiwang960112 https://github.com/kaiwang960112 What is your gmail? And what should i send? Just everything i've stated here or something else?

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/kaiwang960112/Challenge-condition-FER-dataset/issues/41#issuecomment-887372726, or unsubscribe https://github.com/notifications/unsubscribe-auth/AI6LK4FQFDFTN4J3GL3LDFLTZZ6LHANCNFSM5A7NPT3Q .

DaddyWesker commented 3 years ago

@kaiwang960112 "Yes my email is @ . " I'm seeing only symbol instead of gmail. image