av-savchenko / face-emotion-recognition

Efficient face emotion recognition in photos and videos

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Questions for souce code of enet_b2_8.pt

LamQuynhf opened this issue · comments

Could you please share with me the source code to inference with the enet_b2_8.pt model (trained on 8 classes)?

My example src/train_emotions-pytorch.ipynb contains all parts necessary to use the model with 8 classes. You just need to change several lines:

  1. In the 7th cell, uncomment the line
    train_dir,test_dir=AFFECT_TRAIN_ALIGNED_DATA_DIR,AFFECT_VAL_ALIGNED_DATA_DIR

and comment the line
train_dir,test_dir=AFFECT_TRAIN_SEVEN_ALIGNED_DATA_DIR,AFFECT_VAL_SEVEN_ALIGNED_DATA_DIR

  1. Replace
    if True: # 7 emotions
    to
    if False: # 7 emotions

and that's all. You can use the inference code in teh "Example usage" section.

Note, that if you do not have an access to AffectNet dataset, you could ignore the first item and simply run the following assignment right after loading enet2_8.pt model:

idx_to_class={0: 'Anger', 1: 'Contempt', 2: 'Disgust', 3: 'Fear', 4: 'Happiness', 5: 'Neutral', 6: 'Sadness', 7: 'Surprise'}

I hope I will add the simplified inference code soon when I complete several experiments with engagement prediction

Sample inference code is added to display_emotions.ipynb