update in controller
This commit is contained in:
@@ -30,4 +30,4 @@ RUN pip install --upgrade pip
|
||||
RUN pip install -r requirements.txt
|
||||
RUN echo "Requirement txt done!"
|
||||
|
||||
CMD [ "python", "./process_dir.py" ]
|
||||
CMD [ "python", "./process_data.py" ]
|
||||
@@ -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,20 +21,19 @@ 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
|
||||
"""
|
||||
try:
|
||||
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
|
||||
df = df_list[0]
|
||||
|
||||
feature_dir = 'derived_output'
|
||||
now = datetime.now()
|
||||
dt_string = now.strftime("%d_%m_%YT%H:%M:%S")
|
||||
|
||||
@@ -45,6 +44,9 @@ def save_derive_output(df_list, feature, out_loc):
|
||||
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):
|
||||
"""
|
||||
Computing mean value of dataframe columns
|
||||
@@ -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)
|
||||
except Exception as e:
|
||||
logger.error('Failed to process derived variables.')
|
||||
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 {}'.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):
|
||||
"""
|
||||
|
||||
180
process_data.py
Normal file
180
process_data.py
Normal file
@@ -0,0 +1,180 @@
|
||||
"""
|
||||
file_name: process_file
|
||||
project_name: DBM
|
||||
created: 2020-20-07
|
||||
"""
|
||||
|
||||
from dbm_lib.config import config_reader, config_raw_feature, config_derive_feature
|
||||
from dbm_lib.controller import process_feature as pf
|
||||
from dbm_lib.dbm_features.raw_features.video import open_face_process as of
|
||||
from dbm_lib.dbm_features.derived_features import derive as der
|
||||
|
||||
import pandas as pd
|
||||
import os
|
||||
import argparse
|
||||
import logging
|
||||
import glob
|
||||
import time
|
||||
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
logger=logging.getLogger()
|
||||
|
||||
OPENFACE_PATH = 'pkg/OpenFace/build/bin/FeatureExtraction'
|
||||
DLIB_SHAPE_MODEL = 'pkg/shape_detector/shape_predictor_68_face_landmarks.dat'
|
||||
|
||||
def common_video(video_file, args, r_config):
|
||||
"""
|
||||
Common function for video feature processing
|
||||
Args:
|
||||
video_file: video file path
|
||||
args: user supplied arguments
|
||||
r_config: raw feature config object
|
||||
"""
|
||||
pf.audio_to_wav(video_file)
|
||||
of.process_open_face(video_file, os.path.dirname(video_file), args.output_raw_path, OPENFACE_PATH, args.dbm_group)
|
||||
|
||||
pf.process_facial(video_file, args.output_raw_path, args.dbm_group, r_config)
|
||||
pf.process_acoustic(video_file, args.output_raw_path, args.dbm_group, r_config)
|
||||
pf.remove_file(video_file)
|
||||
pf.process_movement(video_file, args.output_raw_path, args.dbm_group, r_config, DLIB_SHAPE_MODEL)
|
||||
|
||||
def process_raw_video_file(args, s_config, r_config):
|
||||
"""
|
||||
Processing video file
|
||||
Args:
|
||||
args: user supplied arguments
|
||||
s_config: service config object
|
||||
r_config: raw feature config object
|
||||
"""
|
||||
try:
|
||||
if args.output_raw_path != None:
|
||||
video_file = glob.glob(args.input_path)
|
||||
|
||||
if len(video_file)>0:
|
||||
logger.info('Calculating raw variables...')
|
||||
common_video(video_file[0], args, r_config)
|
||||
|
||||
else:
|
||||
logger.info('Enter correct video(*.mp4) file path.')
|
||||
|
||||
except Exception as e:
|
||||
logger.error('Failed to process mp4 file.')
|
||||
pf.remove_file(video_file[0])
|
||||
|
||||
def process_raw_audio_file(args, s_config, r_config):
|
||||
"""
|
||||
Processing audio file
|
||||
Args:
|
||||
args: user supplied arguments
|
||||
s_config: service config object
|
||||
r_config: raw feature config object
|
||||
"""
|
||||
try:
|
||||
if args.output_raw_path != None:
|
||||
audio_file = glob.glob(args.input_path)
|
||||
|
||||
if len(audio_file)>0:
|
||||
logger.info('Calculating raw variables...')
|
||||
pf.process_acoustic(audio_file[0], args.output_raw_path, args.dbm_group, r_config)
|
||||
|
||||
else:
|
||||
logger.info('Enter correct audio(*.wav) file path.')
|
||||
except Exception as e:
|
||||
logger.error('Failed to process wav file.')
|
||||
|
||||
def process_raw_video_dir(args, s_config, r_config):
|
||||
"""
|
||||
Processing video file
|
||||
Args:
|
||||
args: user supplied arguments
|
||||
s_config: service config object
|
||||
r_config: raw feature config object
|
||||
"""
|
||||
if args.output_raw_path != None:
|
||||
vid_loc = glob.glob(args.input_path + '/*.mp4')
|
||||
|
||||
if len(vid_loc) == 0:
|
||||
logger.info('Directory does not have any MP4 files.')
|
||||
return
|
||||
|
||||
logger.info('Calculating mp4 raw variables...')
|
||||
for vid_file in vid_loc:
|
||||
try:
|
||||
|
||||
common_video(vid_file, args, r_config)
|
||||
except Exception as e:
|
||||
logger.error('Failed to process mp4 file.')
|
||||
pf.remove_file(vid_file)
|
||||
|
||||
def process_raw_audio_dir(args, s_config, r_config):
|
||||
"""
|
||||
Processing audio file
|
||||
Args:
|
||||
args: user supplied arguments
|
||||
s_config: service config object
|
||||
r_config: raw feature config object
|
||||
"""
|
||||
if args.output_raw_path != None:
|
||||
audio_loc = glob.glob(args.input_path + '/*.wav')
|
||||
|
||||
if len(audio_loc) == 0:
|
||||
logger.info('Directory does not have any WAV files.')
|
||||
return
|
||||
|
||||
logger.info('Calculating wav raw variables...')
|
||||
for audio in audio_loc:
|
||||
try:
|
||||
|
||||
pf.process_acoustic(audio, args.output_raw_path, args.dbm_group, r_config)
|
||||
except Exception as e:
|
||||
logger.error('Failed to process wav file.')
|
||||
|
||||
def process_derive(args, r_config, d_config, input_type):
|
||||
"""
|
||||
Processing dbm derived variables
|
||||
"""
|
||||
if input_type == 'file':
|
||||
input_file = glob.glob(args.input_path)
|
||||
else:
|
||||
input_file = glob.glob(args.input_path + '/*')
|
||||
|
||||
logger.info('Calculating derived variables...')
|
||||
feature_df = der.run_derive(input_file, args.output_raw_path, args.output_derived_path, r_config, d_config)
|
||||
|
||||
if __name__=="__main__":
|
||||
start_time = time.time()
|
||||
parser = argparse.ArgumentParser(description="Process video/audio......")
|
||||
|
||||
parser.add_argument("--input_path", help="path to the input files", required=True)
|
||||
|
||||
parser.add_argument("--output_raw_path", help="path to the raw variable output", required=True)
|
||||
parser.add_argument("--output_derived_path", help="path to the derived variable output")
|
||||
parser.add_argument("--dbm_group", help="list of feature groups", nargs='+')
|
||||
|
||||
args = parser.parse_args()
|
||||
s_config = config_reader.ConfigReader()
|
||||
r_config = config_raw_feature.ConfigRawReader()
|
||||
d_config = config_derive_feature.ConfigDeriveReader()
|
||||
|
||||
_, file_ext = os.path.splitext(os.path.basename(args.input_path))
|
||||
|
||||
if file_ext:
|
||||
input_type = 'file'
|
||||
if file_ext.lower() == '.mp4':
|
||||
process_raw_video_file(args, s_config, r_config)
|
||||
|
||||
elif file_ext.lower() == '.wav':
|
||||
process_raw_audio_file(args, s_config, r_config)
|
||||
|
||||
else:
|
||||
logger.error('No WAV or MP4 files detected in input path')
|
||||
else:
|
||||
input_type = 'dir'
|
||||
process_raw_video_dir(args, s_config, r_config)
|
||||
process_raw_audio_dir(args, s_config, r_config)
|
||||
|
||||
if args.output_derived_path != None:
|
||||
process_derive(args, r_config, d_config, input_type)
|
||||
|
||||
exec_time = time.time() - start_time
|
||||
logger.info('Done! Processing time: {} seconds'.format(exec_time))
|
||||
107
process_dir.py
107
process_dir.py
@@ -1,107 +0,0 @@
|
||||
"""
|
||||
file_name: process_dir
|
||||
project_name: DBM
|
||||
created: 2020-20-07
|
||||
"""
|
||||
|
||||
from dbm_lib.config import config_reader, config_raw_feature, config_derive_feature
|
||||
from dbm_lib.controller import process_feature as pf
|
||||
from dbm_lib.dbm_features.raw_features.video import open_face_process as of
|
||||
from dbm_lib.dbm_features.derived_features import derive as der
|
||||
|
||||
import pandas as pd
|
||||
import os
|
||||
import argparse
|
||||
import logging
|
||||
import glob
|
||||
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
logger=logging.getLogger()
|
||||
|
||||
OPENFACE_PATH = 'pkg/OpenFace/build/bin/FeatureExtraction'
|
||||
DLIB_SHAPE_MODEL = 'pkg/shape_detector/shape_predictor_68_face_landmarks.dat'
|
||||
|
||||
def process_raw_video(args, s_config, r_config):
|
||||
"""
|
||||
Processing video file
|
||||
Args:
|
||||
args: user supplied arguments
|
||||
s_config: service config object
|
||||
r_config: raw feature config object
|
||||
"""
|
||||
if args.output_raw_path != None:
|
||||
vid_loc = glob.glob(args.input_path + '/*.mp4')
|
||||
|
||||
if len(vid_loc) == 0:
|
||||
logger.info('Directory does not have any mp4 files.')
|
||||
return
|
||||
|
||||
logger.info('Processing mp4 files.')
|
||||
for vid_file in vid_loc:
|
||||
try:
|
||||
|
||||
pf.audio_to_wav(vid_file)
|
||||
of.process_open_face(vid_file, os.path.dirname(vid_file), args.output_raw_path, OPENFACE_PATH, args.dbm_group)
|
||||
|
||||
pf.process_facial(vid_file, args.output_raw_path, args.dbm_group, r_config)
|
||||
pf.process_acoustic(vid_file, args.output_raw_path, args.dbm_group, r_config)
|
||||
pf.remove_file(vid_file)
|
||||
pf.process_movement(vid_file, args.output_raw_path, args.dbm_group, r_config, DLIB_SHAPE_MODEL)
|
||||
|
||||
except Exception as e:
|
||||
logger.error('Failed to process mp4 file.')
|
||||
pf.remove_file(vid_file)
|
||||
|
||||
def process_raw_audio(args, s_config, r_config):
|
||||
"""
|
||||
Processing audio file
|
||||
Args:
|
||||
args: user supplied arguments
|
||||
s_config: service config object
|
||||
r_config: raw feature config object
|
||||
"""
|
||||
if args.output_raw_path != None:
|
||||
audio_loc = glob.glob(args.input_path + '/*.wav')
|
||||
|
||||
if len(audio_loc) == 0:
|
||||
logger.info('Directory does not have any wav files.')
|
||||
return
|
||||
|
||||
for audio in audio_loc:
|
||||
try:
|
||||
|
||||
logger.info('Processing wav files.')
|
||||
pf.process_acoustic(audio, args.output_raw_path, args.dbm_group, r_config)
|
||||
|
||||
except Exception as e:
|
||||
logger.error('Failed to process wav file.')
|
||||
|
||||
def process_derive(args, r_config, d_config):
|
||||
"""
|
||||
Processing dbm derived variables
|
||||
Args:
|
||||
s_config: service config object
|
||||
"""
|
||||
input_file = glob.glob(args.input_path + '/*')
|
||||
feature_df = der.run_derive(input_file, args.output_raw_path, args.output_derived_path, r_config, d_config)
|
||||
|
||||
if __name__=="__main__":
|
||||
parser = argparse.ArgumentParser(description="Process video/audio......")
|
||||
|
||||
parser.add_argument("--input_path", help="path to the input directory", required=True)
|
||||
|
||||
parser.add_argument("--output_raw_path", help="dir path to the raw variable output", required=True)
|
||||
parser.add_argument("--output_derived_path", help="dir path to the derived variable output")
|
||||
parser.add_argument("--dbm_group", help="list of feature groups", nargs='+')
|
||||
|
||||
args = parser.parse_args()
|
||||
s_config = config_reader.ConfigReader()
|
||||
r_config = config_raw_feature.ConfigRawReader()
|
||||
d_config = config_derive_feature.ConfigDeriveReader()
|
||||
|
||||
process_raw_video(args, s_config, r_config)
|
||||
process_raw_audio(args, s_config, r_config)
|
||||
|
||||
if args.output_derived_path != None:
|
||||
process_derive(args, r_config, d_config)
|
||||
|
||||
107
process_file.py
107
process_file.py
@@ -1,107 +0,0 @@
|
||||
"""
|
||||
file_name: process_file
|
||||
project_name: DBM
|
||||
created: 2020-20-07
|
||||
"""
|
||||
|
||||
from dbm_lib.config import config_reader, config_raw_feature, config_derive_feature
|
||||
from dbm_lib.controller import process_feature as pf
|
||||
from dbm_lib.dbm_features.raw_features.video import open_face_process as of
|
||||
from dbm_lib.dbm_features.derived_features import derive as der
|
||||
|
||||
import pandas as pd
|
||||
import os
|
||||
import argparse
|
||||
import logging
|
||||
import glob
|
||||
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
logger=logging.getLogger()
|
||||
|
||||
OPENFACE_PATH = 'pkg/OpenFace/build/bin/FeatureExtraction'
|
||||
DLIB_SHAPE_MODEL = 'pkg/shape_detector/shape_predictor_68_face_landmarks.dat'
|
||||
|
||||
def process_raw_video(args, s_config, r_config):
|
||||
"""
|
||||
Processing video file
|
||||
Args:
|
||||
args: user supplied arguments
|
||||
s_config: service config object
|
||||
r_config: raw feature config object
|
||||
"""
|
||||
try:
|
||||
if args.output_raw_path != None:
|
||||
video_file = glob.glob(args.input_path)
|
||||
|
||||
if len(video_file)>0:
|
||||
pf.audio_to_wav(video_file[0])
|
||||
of.process_open_face(video_file[0], os.path.dirname(video_file[0]), args.output_raw_path,
|
||||
OPENFACE_PATH, args.dbm_group)
|
||||
|
||||
pf.process_facial(video_file[0], args.output_raw_path, args.dbm_group, r_config)
|
||||
pf.process_acoustic(video_file[0], args.output_raw_path, args.dbm_group, r_config)
|
||||
pf.remove_file(video_file[0])
|
||||
pf.process_movement(video_file[0], args.output_raw_path, args.dbm_group, r_config, DLIB_SHAPE_MODEL)
|
||||
|
||||
else:
|
||||
logger.info('Enter correct video(*.mp4) file path.')
|
||||
|
||||
except Exception as e:
|
||||
logger.error('Failed to process mp4 file.')
|
||||
pf.remove_file(video_file[0])
|
||||
|
||||
def process_raw_audio(args, s_config, r_config):
|
||||
"""
|
||||
Processing audio file
|
||||
Args:
|
||||
args: user supplied arguments
|
||||
s_config: service config object
|
||||
r_config: raw feature config object
|
||||
"""
|
||||
try:
|
||||
if args.output_raw_path != None:
|
||||
audio_file = glob.glob(args.input_path)
|
||||
|
||||
if len(audio_file)>0:
|
||||
pf.process_acoustic(audio_file[0], args.output_raw_path, args.dbm_group, r_config)
|
||||
else:
|
||||
logger.info('Enter correct audio(*.wav) file path.')
|
||||
except Exception as e:
|
||||
logger.error('Failed to process wav file.')
|
||||
|
||||
def process_derive(args, r_config, d_config):
|
||||
"""
|
||||
Processing dbm derived variables
|
||||
"""
|
||||
input_file = glob.glob(args.input_path)
|
||||
feature_df = der.run_derive(input_file, args.output_raw_path, args.output_derived_path, r_config, d_config)
|
||||
|
||||
|
||||
if __name__=="__main__":
|
||||
parser = argparse.ArgumentParser(description="Process video/audio......")
|
||||
|
||||
parser.add_argument("--input_path", help="path to the input files", required=True)
|
||||
|
||||
parser.add_argument("--output_raw_path", help="path to the raw variable output", required=True)
|
||||
parser.add_argument("--output_derived_path", help="path to the derived variable output")
|
||||
parser.add_argument("--dbm_group", help="list of feature groups", nargs='+')
|
||||
|
||||
args = parser.parse_args()
|
||||
s_config = config_reader.ConfigReader()
|
||||
r_config = config_raw_feature.ConfigRawReader()
|
||||
d_config = config_derive_feature.ConfigDeriveReader()
|
||||
|
||||
_, file_ext = os.path.splitext(os.path.basename(args.input_path))
|
||||
|
||||
if file_ext.lower() == '.mp4':
|
||||
process_raw_video(args, s_config, r_config)
|
||||
|
||||
elif file_ext.lower() == '.wav':
|
||||
process_raw_audio(args, s_config, r_config)
|
||||
|
||||
else:
|
||||
logger.info('Pipeline accepts mp4 or wav file only.')
|
||||
|
||||
if args.output_derived_path != None:
|
||||
process_derive(args, r_config, d_config)
|
||||
|
||||
@@ -5,23 +5,23 @@ derive_feature:
|
||||
'ACO_JITTER','ACO_SHIMMER', 'ACO_PAUSE', 'ACO_VFS', 'ACO_MFCC', 'MOV_HM', 'MOV_HP', 'EYE_BLINK']
|
||||
|
||||
#Feature group output file extensions
|
||||
FAC_ASYM_LOC: _face_asymmetry
|
||||
FAC_AU_LOC: _face_au
|
||||
FAC_EXP_LOC: _face_expressivity
|
||||
FAC_LMK_LOC: _face_landmark
|
||||
FAC_ASYM_LOC: _facasym
|
||||
FAC_AU_LOC: _facau
|
||||
FAC_EXP_LOC: _facemo
|
||||
FAC_LMK_LOC: _faclmk
|
||||
ACO_INT_LOC: _intensity
|
||||
ACO_FF_LOC: _pitch
|
||||
ACO_HNR_LOC: _hnr_frame
|
||||
ACO_GNE_LOC: _gne_frame
|
||||
ACO_HNR_LOC: _hnr
|
||||
ACO_GNE_LOC: _gne
|
||||
ACO_FM_LOC: _formant
|
||||
ACO_JITTER_LOC: _jitter
|
||||
ACO_SHIMMER_LOC: _shimmer
|
||||
ACO_PAUSE_LOC: _pause_segment
|
||||
ACO_VFS_LOC: _vfs
|
||||
ACO_PAUSE_LOC: _pausechar
|
||||
ACO_VFS_LOC: _voiceprev
|
||||
ACO_MFCC_LOC: _mfcc
|
||||
MOV_HM_LOC: _head_movement
|
||||
MOV_HP_LOC: _head_pose
|
||||
EYE_BLINK_LOC: _eye_blink
|
||||
MOV_HM_LOC: _headmov
|
||||
MOV_HP_LOC: _headpose
|
||||
EYE_BLINK_LOC: _eyeblinks
|
||||
|
||||
#Facial category feature group
|
||||
FAC_ASYM: ['fac_AsymMaskMouth', 'fac_AsymMaskEyebrow', 'fac_AsymMaskEye', 'fac_AsymMaskCom']
|
||||
|
||||
Reference in New Issue
Block a user