diff --git a/dbm_lib/config/config_raw_feature.py b/dbm_lib/config/config_raw_feature.py index bee0643a..666fb534 100644 --- a/dbm_lib/config/config_raw_feature.py +++ b/dbm_lib/config/config_raw_feature.py @@ -194,9 +194,6 @@ class ConfigRawReader(object): self.neu_exp = config['raw_feature']['neu_exp'] self.cai_exp = config['raw_feature']['cai_exp'] self.com_exp = config['raw_feature']['com_exp'] - self.com_lower_exp = config['raw_feature']['com_lower_exp'] - self.com_upper_exp = config['raw_feature']['com_upper_exp'] - self.pai_exp = config['raw_feature']['pai_exp'] self.hap_exp_full = config['raw_feature']['hap_exp_full'] self.sad_exp_full = config['raw_feature']['sad_exp_full'] self.sur_exp_full = config['raw_feature']['sur_exp_full'] @@ -209,10 +206,6 @@ class ConfigRawReader(object): self.neu_exp_full = config['raw_feature']['neu_exp_full'] self.cai_exp_full = config['raw_feature']['cai_exp_full'] self.com_exp_full = config['raw_feature']['com_exp_full'] - self.com_lower_exp_full = config['raw_feature']['com_lower_exp_full'] - self.com_upper_exp_full = config['raw_feature']['com_upper_exp_full'] - self.pai_exp_full = config['raw_feature']['pai_exp_full'] - self.fac_AsymMaskMouth = config['raw_feature']['fac_AsymMaskMouth'] self.fac_AsymMaskEye = config['raw_feature']['fac_AsymMaskEye'] self.fac_AsymMaskEyebrow = config['raw_feature']['fac_AsymMaskEyebrow'] @@ -229,7 +222,7 @@ class ConfigRawReader(object): self.mov_Hpose_Yaw = config['raw_feature']['mov_Hpose_Yaw'] self.mov_Hpose_Roll = config['raw_feature']['mov_Hpose_Roll'] self.mov_Hpose_Dist = config['raw_feature']['mov_Hpose_Dist'] - + self.mov_freq_trem_freq = config['raw_feature']['mov_freq_trem_freq'] self.mov_freq_trem_index = config['raw_feature']['mov_freq_trem_index'] self.mov_freq_trem_pindex = config['raw_feature']['mov_freq_trem_pindex'] @@ -276,4 +269,3 @@ class ConfigRawReader(object): self.nlp_wordsPerMin = config['raw_feature']['nlp_wordsPerMin'] self.nlp_totalTime = config['raw_feature']['nlp_totalTime'] - diff --git a/dbm_lib/dbm_features/raw_features/util/video_util.py b/dbm_lib/dbm_features/raw_features/util/video_util.py index 4c0b4f42..013c073c 100644 --- a/dbm_lib/dbm_features/raw_features/util/video_util.py +++ b/dbm_lib/dbm_features/raw_features/util/video_util.py @@ -11,32 +11,32 @@ from dbm_lib.dbm_features.raw_features.util import util as ut def smooth(x,window_len=11,window='hanning'): """smooth the data using a window with requested size. - + This method is based on the convolution of a scaled window with the signal. - The signal is prepared by introducing reflected copies of the signal + The signal is prepared by introducing reflected copies of the signal (with the window size) in both ends so that transient parts are minimized in the begining and end part of the output signal. - + input: - x: the input signal + x: the input signal window_len: the dimension of the smoothing window; should be an odd integer window: the type of window from 'flat', 'hanning', 'hamming', 'bartlett', 'blackman' flat window will produce a moving average smoothing. output: the smoothed signal - + example: t=linspace(-2,2,0.1) x=sin(t)+randn(len(t))*0.1 y=smooth(x) - - see also: - + + see also: + numpy.hanning, numpy.hamming, numpy.bartlett, numpy.blackman, numpy.convolve scipy.signal.lfilter - + TODO: the window parameter could be the window itself if an array instead of a string NOTE: length(output) != length(input), to correct this: return y[(window_len/2-1):-(window_len/2)] instead of just y. """ @@ -62,7 +62,7 @@ def filter_by_confidence_and_thresh(x, fea, thresh): return x[fea] else: return np.NaN - + def add_au_emotion(x, emotion,emotion_type,exp_type): """ computing individula emotion expressivity matrix @@ -79,20 +79,20 @@ def add_au_emotion(x, emotion,emotion_type,exp_type): if x[au_c_label]==1 and (not np.isnan(x[au_r_label])): #there are data with face in, but au_c=0 sum_r += x[au_r_label] cnt += 6 - if exp_type=='full' and x[au_c_label]==0: #Logic to compute emotion expressivity when all AU's are present - cnt = 0 + if exp_type=='full' and x[au_c_label]==0: #Logic to compute emotion expressivity when all AU's are present + cnt = 0 break - if cnt > 0: + if cnt > 0: sum_r /= cnt else: sum_r = 0 - v_emo = x[emotion_type] + sum_r + v_emo = x[emotion_type] + sum_r else: v_emo = np.NaN error_reason = 'confidence less than 80%' - + return v_emo, error_reason - + def add_au_occ(x, emotion,emotion_type): """ computing individula emotion presence @@ -107,14 +107,14 @@ def add_au_occ(x, emotion,emotion_type): au_c_label = " AU{:02d}_c".format(au) if x[au_c_label]==1: #there are data with face in, but au_c=0 au_pres.append(1) - + if len(au_pres) == len(emotion): em_pres = 1 else: em_pres = np.NaN error_reason = 'confidence less than 80%' return em_pres, error_reason - + def emotion_exp(em_au,of,em_col,err_col): """ Computing individual emotion expressivity and adding it to dataframe @@ -122,14 +122,14 @@ def emotion_exp(em_au,of,em_col,err_col): for emotion in em_au: of[[em_col[0],err_col]]=of.apply(add_au_emotion, args=(emotion,em_col[0],'partial',), axis=1, result_type='expand') of[[em_col[1],err_col]]=of.apply(add_au_emotion, args=(emotion,em_col[1],'full',), axis=1, result_type='expand') - + def emotion_pres(em_au,of,em_col,err_col): """ Computing individual emotion expressivity and adding it to dataframe """ for emotion in em_au: of[[em_col,err_col]]=of.apply(add_au_occ, args=(emotion,em_col,), axis=1, result_type='expand') - + def calc_of_for_video(of,face_cfg,fe_cfg): """ Creating dataframe for emotion expressivity @@ -142,7 +142,7 @@ def calc_of_for_video(of,face_cfg,fe_cfg): fe_cfg.com_exp_full] of[new_cols] = pd.DataFrame([[0] * len(new_cols)], index=of.index) of[fe_cfg.err_reason] = 'Pass' - + #Composite happiness expressivity emotion_exp(face_cfg.happiness,of,[fe_cfg.hap_exp,fe_cfg.hap_exp_full],fe_cfg.err_reason) #Composite sadness expressivity @@ -167,12 +167,6 @@ def calc_of_for_video(of,face_cfg,fe_cfg): emotion_exp(face_cfg.cai,of,[fe_cfg.cai_exp,fe_cfg.cai_exp_full],fe_cfg.err_reason) #Composite Expressivity emotion_exp(face_cfg.ACTION_UNITS,of,[fe_cfg.com_exp,fe_cfg.com_exp_full],fe_cfg.err_reason) - #Composite lower face expressivity - emotion_exp(face_cfg.LOWER_ACTION_UNITS,of,[fe_cfg.com_lower_exp,fe_cfg.com_lower_exp_full],fe_cfg.err_reason) - #Composite upper face Expressivity - emotion_exp(face_cfg.UPPER_ACTION_UNITS,of,[fe_cfg.com_upper_exp,fe_cfg.com_upper_exp_full],fe_cfg.err_reason) - #Composite pain expressivity - emotion_exp(face_cfg.pain,of,[fe_cfg.pai_exp,fe_cfg.pai_exp_full],fe_cfg.err_reason) #AU happiness presence emotion_pres(face_cfg.happiness,of,fe_cfg.happ_occ,fe_cfg.err_reason) #AU Sad presence diff --git a/dbm_lib/dbm_features/raw_features/video/face_config/face_config_reader.py b/dbm_lib/dbm_features/raw_features/video/face_config/face_config_reader.py index a612ed69..4d882976 100644 --- a/dbm_lib/dbm_features/raw_features/video/face_config/face_config_reader.py +++ b/dbm_lib/dbm_features/raw_features/video/face_config/face_config_reader.py @@ -18,20 +18,18 @@ class ConfigFaceReader(object): Args: service_config_yml (None, optional): yml file defined service configuration """ - + if service_config_yml is None: service_config = DBMLIB_FACE_CONFIG else: service_config = service_config_yml - + with open(service_config, 'r') as ymlfile: config = yaml.load(ymlfile) self.ACTION_UNITS = config['cdx_face_config']['ACTION_UNITS'] self.NEG_ACTION_UNITS = config['cdx_face_config']['NEG_ACTION_UNITS'] self.POS_ACTION_UNITS = config['cdx_face_config']['POS_ACTION_UNITS'] - self.NET_ACTION_UNITS = config['cdx_face_config']['NET_ACTION_UNITS'] - self.LOWER_ACTION_UNITS = config['cdx_face_config']['LOWER_ACTION_UNITS'] - self.UPPER_ACTION_UNITS = config['cdx_face_config']['UPPER_ACTION_UNITS'] + self.NET_ACTION_UNITS = config['cdx_face_config']['NET_ACTION_UNITS'] self.happiness = config['cdx_face_config']['happiness'] self.sadness = config['cdx_face_config']['sadness'] self.surprise = config['cdx_face_config']['surprise'] @@ -39,7 +37,6 @@ class ConfigFaceReader(object): self.anger = config['cdx_face_config']['anger'] self.disgust = config['cdx_face_config']['disgust'] self.contempt = config['cdx_face_config']['contempt'] - self.pain = config['cdx_face_config']['pain'] self.cai = config['cdx_face_config']['CAI'] self.SELECTED_FEATURES = config['cdx_face_config']['SELECTED_FEATURES'].split(',') self.face_expr_dir = config['cdx_face_config']['face_expr_dir'] @@ -47,7 +44,7 @@ class ConfigFaceReader(object): self.AU_fl = config['cdx_face_config']['AU_filters'] self.au_int = config['cdx_face_config']['au_intensity'] self.au_prs = config['cdx_face_config']['au_presence'] - + def get_action_unit(self): """Summary Returns: @@ -137,4 +134,4 @@ class ConfigFaceReader(object): Returns: TYPE: end point """ - return self.cai + return self.cai \ No newline at end of file diff --git a/resources/features/derived_feature.yml b/resources/features/derived_feature.yml index 090b652a..e0f51bb8 100644 --- a/resources/features/derived_feature.yml +++ b/resources/features/derived_feature.yml @@ -36,11 +36,9 @@ derive_feature: 'fac_AU06pres', 'fac_AU07pres', 'fac_AU09pres', 'fac_AU10pres', 'fac_AU12pres', 'fac_AU14pres', 'fac_AU15pres', 'fac_AU17pres', 'fac_AU20pres', 'fac_AU23pres', 'fac_AU25pres', 'fac_AU26pres', 'fac_AU28pres', 'fac_AU45pres'] FAC_EXP: ['hap_exp', 'sad_exp', 'sur_exp', 'fea_exp', 'ang_exp', 'dis_exp', 'con_exp', 'happ_occ', 'sad_occ', - 'sur_occ', 'fea_occ', 'ang_occ', 'dis_occ', 'con_occ', 'pos_exp', 'neg_exp', 'com_exp','com_lower_exp','com_upper_exp', 'hap_exp_full', + 'sur_occ', 'fea_occ', 'ang_occ', 'dis_occ', 'con_occ', 'pos_exp', 'neg_exp', 'com_exp', 'hap_exp_full', 'sad_exp_full', 'sur_exp_full','fea_exp_full', 'ang_exp_full', 'dis_exp_full', 'con_exp_full', 'pos_exp_full', - 'neg_exp_full', 'com_exp_full','com_lower_exp_full','com_upper_exp_full', 'pai_exp', 'pai_exp_full'] - - + 'neg_exp_full', 'com_exp_full'] FAC_LMK: ['fac_LMK00disp', 'fac_LMK01disp', 'fac_LMK02disp', 'fac_LMK03disp', 'fac_LMK04disp', 'fac_LMK05disp', 'fac_LMK06disp', 'fac_LMK07disp', 'fac_LMK08disp', 'fac_LMK09disp', 'fac_LMK10disp', 'fac_LMK11disp', 'fac_LMK12disp', 'fac_LMK13disp', 'fac_LMK14disp', 'fac_LMK15disp', 'fac_LMK16disp', @@ -147,9 +145,6 @@ derive_feature: neg_exp: ['mean', 'std', 'pct'] neu_exp: ['mean', 'std', 'pct'] com_exp: ['mean', 'std', 'pct'] - com_lower_exp: ['mean','std','pct'] - com_upper_exp: ['mean','std','pct'] - pai_exp: ['mean','std','pct'] hap_exp_full: ['mean', 'std'] sad_exp_full: ['mean', 'std'] sur_exp_full: ['mean', 'std'] @@ -161,9 +156,6 @@ derive_feature: neg_exp_full: ['mean', 'std'] neu_exp_full: ['mean', 'std'] com_exp_full: ['mean', 'std'] - com_lower_exp_full: ['mean','std'] - com_upper_exp_full: ['mean', 'std'] - pai_exp_full: ['mean','std'] #Facial Landmarks fac_LMK00disp: ['mean', 'std'] diff --git a/resources/features/raw_feature.yml b/resources/features/raw_feature.yml index 72a0d069..78a4ae7b 100644 --- a/resources/features/raw_feature.yml +++ b/resources/features/raw_feature.yml @@ -26,10 +26,6 @@ raw_feature: neu_exp: neu_exp cai_exp: cai_exp com_exp: fac_comintsoft - com_lower_exp: fac_comlowintsoft - com_upper_exp: fac_comuppintsoft - pai_exp: fac_paiintsoft - hap_exp_full: fac_hapinthard sad_exp_full: fac_sadinthard sur_exp_full: fac_surinthard @@ -42,9 +38,6 @@ raw_feature: neu_exp_full: neu_exp_full cai_exp_full: cai_exp_full com_exp_full: fac_cominthard - com_lower_exp_full: fac_comlowinthard - com_upper_exp_full: fac_comuppinthard - pai_exp_full: fac_paiinthard #Facial asymmetry fac_AsymMaskMouth: fac_asymmaskmouth diff --git a/resources/services/face_util.yml b/resources/services/face_util.yml index d4fe6274..d398cdf1 100644 --- a/resources/services/face_util.yml +++ b/resources/services/face_util.yml @@ -1,7 +1,5 @@ cdx_face_config: ACTION_UNITS: [[6, 12],[1, 4, 15],[1, 2, 5, 26],[1, 2, 4, 5, 7, 20, 26],[4, 5, 7, 23],[9, 15],[12, 14]] - LOWER_ACTION_UNITS: [[12], [15], [26], [20, 26], [23], [15], [12, 14]] - UPPER_ACTION_UNITS: [[6], [1, 4], [1, 2, 5], [1, 2, 4, 5, 7], [4, 5, 7], [9]] NEG_ACTION_UNITS: [[1, 4, 15], [1, 2, 4, 5, 7, 20, 26], [4, 5, 7, 23], [9, 15], [12, 14]] POS_ACTION_UNITS: [[6, 12]] NET_ACTION_UNITS: [[1, 2, 5, 26]] @@ -12,17 +10,16 @@ cdx_face_config: anger: [[4, 5, 7, 23]] disgust: [[9, 15]] contempt: [[12, 14]] - pain: [[4, 6, 7, 9, 10, 12, 20, 26]] CAI: [[6, 12],[1, 4, 15],[2, 5, 26],[7, 20, 26],[23],[9],[12, 14]] SELECTED_FEATURES: AU,POSE face_expr_dir: /video/face_expressivity face_asym_dir: /video/face_asymmetry - AU_filters: ['frame', ' face_id', ' timestamp', ' confidence', ' success', ' AU01_r',' AU02_r',' AU04_r',' AU05_r', - ' AU06_r', ' AU07_r', ' AU09_r', ' AU10_r', ' AU12_r', ' AU14_r', ' AU15_r', ' AU17_r', ' AU20_r', - ' AU25_r', ' AU26_r', ' AU45_r', ' AU01_c', ' AU02_c', ' AU04_c', ' AU05_c', ' AU06_c', ' AU07_c', + AU_filters: ['frame', ' face_id', ' timestamp', ' confidence', ' success', ' AU01_r',' AU02_r',' AU04_r',' AU05_r', + ' AU06_r', ' AU07_r', ' AU09_r', ' AU10_r', ' AU12_r', ' AU14_r', ' AU15_r', ' AU17_r', ' AU20_r', + ' AU25_r', ' AU26_r', ' AU45_r', ' AU01_c', ' AU02_c', ' AU04_c', ' AU05_c', ' AU06_c', ' AU07_c', ' AU10_c', ' AU12_c', ' AU14_c', ' AU15_c', ' AU17_c', ' AU20_c', ' AU23_c', ' AU25_c', ' AU26_c', ' AU28_c', ' AU45_c',' AU09_c',' AU23_r' ] - au_intensity: [' AU01_r',' AU02_r',' AU04_r',' AU05_r', ' AU06_r', ' AU07_r', ' AU09_r', ' AU10_r', ' AU12_r', + au_intensity: [' AU01_r',' AU02_r',' AU04_r',' AU05_r', ' AU06_r', ' AU07_r', ' AU09_r', ' AU10_r', ' AU12_r', ' AU14_r', ' AU15_r', ' AU17_r', ' AU20_r',' AU23_r', ' AU25_r', ' AU26_r', ' AU45_r'] - au_presence: [' AU01_c', ' AU02_c', ' AU04_c', ' AU05_c', ' AU06_c', ' AU07_c', ' AU09_c', ' AU10_c', ' AU12_c', - ' AU14_c', ' AU15_c', ' AU17_c', ' AU20_c', ' AU23_c', ' AU25_c', ' AU26_c', ' AU45_c'] + au_presence: [' AU01_c', ' AU02_c', ' AU04_c', ' AU05_c', ' AU06_c', ' AU07_c', ' AU09_c', ' AU10_c', ' AU12_c', + ' AU14_c', ' AU15_c', ' AU17_c', ' AU20_c', ' AU23_c', ' AU25_c', ' AU26_c', ' AU45_c'] \ No newline at end of file