Created
March 24, 2019 14:28
-
-
Save munthe/f087020946887122c181ece750a5bf33 to your computer and use it in GitHub Desktop.
Convert AUs from OpenFace FeatureExtraction to emotions using model from wikipedia.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# coding: utf-8 | |
# In[1]: | |
import pandas as pd | |
import numpy as np | |
import matplotlib | |
import matplotlib.pylab as plt | |
import matplotlib.animation as animation | |
get_ipython().run_line_magic('matplotlib', 'inline') | |
get_ipython().run_line_magic('matplotlib', 'notebook') | |
import seaborn as sns | |
sns.set(context="talk") | |
# In[2]: | |
sti = "./processed/3zmhiYso.csv" | |
df = pd.read_csv(sti) # | |
df = df.set_index(" timestamp") | |
# In[3]: | |
def get_ausr(ints): | |
return [" AU%02d_r"% i for i in ints] | |
def get_ausc(ints): | |
return [" AU%02d_c"% i for i in ints] | |
# In[4]: | |
# .values tager værdierne ud til de specifikke AUs for hver følelse, som dereter bliver summereret rækkevis. | |
df["happiness"] = df[get_ausr([6,12])].values.mean(1) | |
df["sadnes"] = df[get_ausr([1,4,15])].values.mean(1) | |
df["surprise"] = df[get_ausr([1,2,5,26])].values.mean(1) | |
df["fear"] = df[get_ausr([1,2,4,5,7,20,26])].values.mean(1) | |
df["anger"] = df[get_ausr([1,2])].values.mean(1) | |
df["disgust"] = df[get_ausr([1,15])].values.mean(1) | |
df["contempt"] = df[get_ausr([12,14])].values.mean(1) | |
# In[5]: | |
df[ | |
["happiness","sadnes","surprise","fear","anger","disgust","contempt"] | |
].rolling(100).mean().plot(figsize=(20,10)) | |
# In[6]: | |
df[get_ausr([1,2,4,5,7,9,12,14,15,20,23,26])[:]].rolling(100).mean().plot(figsize=(20,10)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment