update in controller
This commit is contained in:
@@ -51,6 +51,7 @@ def process_acoustic(video_uri, out_dir, dbm_group, r_config):
|
||||
if dbm_group != None and len(dbm_group)>0 and 'acoustic' not in dbm_group:
|
||||
return
|
||||
|
||||
logger.info('Processing acoustic variables from data in {}'.format(video_uri))
|
||||
logger.info('processing audio intensity....')
|
||||
intensity.run_intensity(video_uri, out_dir, r_config)
|
||||
|
||||
@@ -91,6 +92,7 @@ def process_facial(video_uri, out_dir, dbm_group, r_config):
|
||||
if dbm_group != None and len(dbm_group)>0 and 'facial' not in dbm_group:
|
||||
return
|
||||
|
||||
logger.info('Processing facial variables from data in {}'.format(video_uri))
|
||||
logger.info('processing facial asymmetry....')
|
||||
face_asymmetry.run_face_asymmetry(video_uri, out_dir, r_config)
|
||||
|
||||
@@ -114,6 +116,7 @@ def process_movement(video_uri, out_dir, dbm_group, r_config, dlib_model):
|
||||
if dbm_group != None and len(dbm_group)>0 and 'movement' not in dbm_group:
|
||||
return
|
||||
|
||||
logger.info('Processing movement variables from data in {}'.format(video_uri))
|
||||
logger.info('processing head movement....')
|
||||
head_motion.run_head_movement(video_uri, out_dir, r_config)
|
||||
|
||||
|
||||
@@ -21,29 +21,31 @@ def dict_to_df(feature_dict, file):
|
||||
final_dict = {k: v for d in feature_dict for k, v in d.items()}
|
||||
|
||||
feature_df = pd.DataFrame([final_dict])
|
||||
feature_df['dbm_master_url'] = file
|
||||
feature_df['Filename'] = file
|
||||
|
||||
return feature_df
|
||||
|
||||
def save_derive_output(df_list, feature, out_loc):
|
||||
def save_derive_output(df_list, out_loc):
|
||||
"""
|
||||
Saving derive variable output
|
||||
"""
|
||||
if len(df_list)>0:
|
||||
logger.info("Saving derived variable output for {}".format(feature))
|
||||
|
||||
df = pd.concat(df_list, ignore_index=True)
|
||||
feature_dir = 'derive_' + feature
|
||||
|
||||
now = datetime.now()
|
||||
dt_string = now.strftime("%d_%m_%YT%H:%M:%S")
|
||||
|
||||
out_dir = '{}_{}'.format(out_loc, dt_string)
|
||||
file_name = os.path.join(out_dir, feature_dir + '.csv')
|
||||
|
||||
if not os.path.exists(out_dir):
|
||||
os.makedirs(out_dir)
|
||||
df.to_csv(file_name, index=False)
|
||||
try:
|
||||
if len(df_list)>0:
|
||||
df = df_list[0]
|
||||
|
||||
feature_dir = 'derived_output'
|
||||
now = datetime.now()
|
||||
dt_string = now.strftime("%d_%m_%YT%H:%M:%S")
|
||||
|
||||
out_dir = '{}_{}'.format(out_loc, dt_string)
|
||||
file_name = os.path.join(out_dir, feature_dir + '.csv')
|
||||
|
||||
if not os.path.exists(out_dir):
|
||||
os.makedirs(out_dir)
|
||||
df.to_csv(file_name, index=False)
|
||||
|
||||
except Exception as e:
|
||||
logger.error('Failed to save derived variable csv')
|
||||
|
||||
def feature_output(df_fea, exp_var, cal_type):
|
||||
"""
|
||||
@@ -64,7 +66,7 @@ def feature_output(df_fea, exp_var, cal_type):
|
||||
exp_val = df_.std(axis = 0, skipna = True)
|
||||
|
||||
elif cal_type == 'count':#use case for eye blink
|
||||
exp_var = 'blink_count'
|
||||
exp_var = 'blink'
|
||||
exp_val = (len(df_)/df_[0])*60
|
||||
|
||||
elif cal_type == 'pct':
|
||||
@@ -110,11 +112,12 @@ def compute_feature(raw_df, var_cols, d_cfg_Obj, r_cfg_Obj):
|
||||
|
||||
return feature_dict
|
||||
|
||||
def calc_derive(input_file, input_dir, output_dir, r_cfg_Obj, d_cfg_Obj, feature):
|
||||
def calc_derive(input_file, input_dir, r_cfg_Obj, d_cfg_Obj, feature):
|
||||
"""
|
||||
Calculating derived variable
|
||||
"""
|
||||
df_list = []
|
||||
df = pd.DataFrame()
|
||||
for file in input_file:
|
||||
|
||||
file_name, _ = os.path.splitext(os.path.basename(file))
|
||||
@@ -133,7 +136,9 @@ def calc_derive(input_file, input_dir, output_dir, r_cfg_Obj, d_cfg_Obj, feature
|
||||
feature_df = dict_to_df(feature_dict, file)
|
||||
df_list.append(feature_df)
|
||||
|
||||
save_derive_output(df_list, feature, output_dir)
|
||||
if len(df_list)>0:
|
||||
df = pd.concat(df_list, ignore_index=True)
|
||||
return df
|
||||
|
||||
def run_derive(input_file, input_dir, output_dir, r_config, d_config):
|
||||
"""
|
||||
@@ -144,10 +149,21 @@ def run_derive(input_file, input_dir, output_dir, r_config, d_config):
|
||||
feature_group = d_cfg_Obj['FEATURE_GROUP']
|
||||
|
||||
#Iterating over feature group
|
||||
df_list = []
|
||||
for feature in feature_group:
|
||||
try:
|
||||
|
||||
calc_derive(input_file, input_dir, output_dir, r_cfg_Obj, d_cfg_Obj, feature)
|
||||
df_fea = calc_derive(input_file, input_dir, r_cfg_Obj, d_cfg_Obj, feature)
|
||||
if len(df_fea)>0:
|
||||
|
||||
if len(df_list) == 0:
|
||||
df_list.append(df_fea)
|
||||
else:
|
||||
result = pd.merge(df_list[0], df_fea, how='outer', on=['Filename'])
|
||||
df_list = [result]
|
||||
|
||||
except Exception as e:
|
||||
logger.error('Failed to process derived variables.')
|
||||
|
||||
logger.error('Failed to process derived variables {}'.format(feature))
|
||||
|
||||
logger.info("Saving derived variable output...")
|
||||
save_derive_output(df_list, output_dir)
|
||||
@@ -21,7 +21,7 @@ logger=logging.getLogger()
|
||||
|
||||
gne_dir = 'audio/glottal_noise'
|
||||
ff_dir = 'audio/pitch'
|
||||
csv_ext = '_gne_frame.csv'
|
||||
csv_ext = '_gne.csv'
|
||||
|
||||
def gne_ratio(sound):
|
||||
"""
|
||||
|
||||
@@ -19,7 +19,7 @@ logging.basicConfig(level=logging.INFO)
|
||||
logger=logging.getLogger()
|
||||
|
||||
hnr_dir = 'audio/harmonic_noise'
|
||||
csv_ext = '_hnr_frame.csv'
|
||||
csv_ext = '_hnr.csv'
|
||||
error_txt = 'error: length less than 0.064'
|
||||
|
||||
def hnr_ratio(filepath):
|
||||
|
||||
@@ -21,7 +21,7 @@ logging.basicConfig(level=logging.INFO)
|
||||
logger=logging.getLogger()
|
||||
|
||||
pause_seg_dir = 'audio/pause_segment'
|
||||
csv_ext = '_pause_segment.csv'
|
||||
csv_ext = '_pausechar.csv'
|
||||
|
||||
def get_timing_cues(seg_starts_sec, seg_ends_sec, r_config):
|
||||
"""
|
||||
|
||||
@@ -18,7 +18,7 @@ logging.basicConfig(level=logging.INFO)
|
||||
logger=logging.getLogger()
|
||||
|
||||
vfs_dir = 'audio/voice_frame_score'
|
||||
csv_ext = '_vfs.csv'
|
||||
csv_ext = '_voiceprev.csv'
|
||||
error_txt = 'error: length less than 0.064'
|
||||
|
||||
def audio_pitch_frame(pitch):
|
||||
|
||||
@@ -26,7 +26,7 @@ logging.basicConfig(level=logging.INFO)
|
||||
logger=logging.getLogger()
|
||||
|
||||
movement_expr_dir = 'movement/eye_blink'
|
||||
csv_ext = '_eye_blink.csv'
|
||||
csv_ext = '_eyeblinks.csv'
|
||||
|
||||
def eye_aspect_ratio(eye):
|
||||
"""
|
||||
|
||||
@@ -19,8 +19,8 @@ logger=logging.getLogger()
|
||||
|
||||
h_mov_dir = 'movement/head_movement'
|
||||
h_pose_dir = 'movement/head_pose'
|
||||
h_mov_ext = '_head_movement.csv'
|
||||
h_pose_ext = '_head_pose.csv'
|
||||
h_mov_ext = '_headmov.csv'
|
||||
h_pose_ext = '_headpose.csv'
|
||||
|
||||
def head_pose_dist(of_results):
|
||||
"""
|
||||
|
||||
@@ -26,7 +26,7 @@ logging.basicConfig(level=logging.INFO)
|
||||
logger=logging.getLogger()
|
||||
|
||||
face_asym_dir = 'video/face_asymmetry'
|
||||
csv_ext = '_face_asymmetry.csv'
|
||||
csv_ext = '_facasym.csv'
|
||||
|
||||
cv2_color_purple = (254,19,188)
|
||||
color_blue = (0,0,1.0)
|
||||
|
||||
@@ -20,7 +20,7 @@ logging.basicConfig(level=logging.INFO)
|
||||
logger=logging.getLogger()
|
||||
|
||||
face_au_dir = 'video/face_au'
|
||||
csv_ext = '_face_au.csv'
|
||||
csv_ext = '_facau.csv'
|
||||
|
||||
|
||||
def extract_col_nm_au(cols):
|
||||
|
||||
@@ -20,7 +20,7 @@ logging.basicConfig(level=logging.INFO)
|
||||
logger=logging.getLogger()
|
||||
|
||||
face_expr_dir = 'video/face_expressivity'
|
||||
csv_ext = '_face_expressivity.csv'
|
||||
csv_ext = '_facemo.csv'
|
||||
|
||||
#Openface feature extraction
|
||||
def of_feature(df_of, cfr, f_cfg):
|
||||
|
||||
@@ -20,7 +20,7 @@ logging.basicConfig(level=logging.INFO)
|
||||
logger=logging.getLogger()
|
||||
|
||||
face_lmk_dir = 'video/face_landmark'
|
||||
csv_ext = '_face_landmark.csv'
|
||||
csv_ext = '_faclmk.csv'
|
||||
|
||||
def extract_col_nm_lmk(cols):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user