update argument
This commit is contained in:
@@ -33,15 +33,10 @@ def save_derive_output(df_list, out_loc):
|
||||
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")
|
||||
file_name = os.path.join(out_loc, 'derived_output.csv')
|
||||
if not os.path.exists(out_loc):
|
||||
|
||||
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)
|
||||
os.makedirs(out_loc)
|
||||
df.to_csv(file_name, index=False)
|
||||
|
||||
except Exception as e:
|
||||
@@ -66,7 +61,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'
|
||||
exp_var = 'mov_blink'
|
||||
exp_val = (len(df_)/df_[0])*60
|
||||
|
||||
elif cal_type == 'pct':
|
||||
|
||||
@@ -30,13 +30,14 @@ def common_video(video_file, args, r_config):
|
||||
args: user supplied arguments
|
||||
r_config: raw feature config object
|
||||
"""
|
||||
out_path = os.path.join(args.output_path, 'raw_variables')
|
||||
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)
|
||||
of.process_open_face(video_file, os.path.dirname(video_file), out_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.process_facial(video_file, out_path, args.dbm_group, r_config)
|
||||
pf.process_acoustic(video_file, out_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)
|
||||
pf.process_movement(video_file, out_path, args.dbm_group, r_config, DLIB_SHAPE_MODEL)
|
||||
|
||||
def process_raw_video_file(args, s_config, r_config):
|
||||
"""
|
||||
@@ -47,7 +48,7 @@ def process_raw_video_file(args, s_config, r_config):
|
||||
r_config: raw feature config object
|
||||
"""
|
||||
try:
|
||||
if args.output_raw_path != None:
|
||||
if args.output_path != None:
|
||||
video_file = glob.glob(args.input_path)
|
||||
|
||||
if len(video_file)>0:
|
||||
@@ -70,12 +71,14 @@ def process_raw_audio_file(args, s_config, r_config):
|
||||
r_config: raw feature config object
|
||||
"""
|
||||
try:
|
||||
if args.output_raw_path != None:
|
||||
if args.output_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)
|
||||
|
||||
out_path = os.path.join(args.output_path, 'raw_variables')
|
||||
pf.process_acoustic(audio_file[0], out_path, args.dbm_group, r_config)
|
||||
|
||||
else:
|
||||
logger.info('Enter correct audio(*.wav) file path.')
|
||||
@@ -90,14 +93,14 @@ def process_raw_video_dir(args, s_config, r_config):
|
||||
s_config: service config object
|
||||
r_config: raw feature config object
|
||||
"""
|
||||
if args.output_raw_path != None:
|
||||
if args.output_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...')
|
||||
logger.info('Calculating raw variables...')
|
||||
for vid_file in vid_loc:
|
||||
try:
|
||||
|
||||
@@ -114,18 +117,19 @@ def process_raw_audio_dir(args, s_config, r_config):
|
||||
s_config: service config object
|
||||
r_config: raw feature config object
|
||||
"""
|
||||
if args.output_raw_path != None:
|
||||
if args.output_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...')
|
||||
logger.info('Calculating raw variables...')
|
||||
for audio in audio_loc:
|
||||
try:
|
||||
|
||||
pf.process_acoustic(audio, args.output_raw_path, args.dbm_group, r_config)
|
||||
out_path = os.path.join(args.output_path, 'raw_variables')
|
||||
pf.process_acoustic(audio, out_path, args.dbm_group, r_config)
|
||||
except Exception as e:
|
||||
logger.error('Failed to process wav file.')
|
||||
|
||||
@@ -138,17 +142,18 @@ def process_derive(args, r_config, d_config, input_type):
|
||||
else:
|
||||
input_file = glob.glob(args.input_path + '/*')
|
||||
|
||||
out_raw_path = os.path.join(args.output_path, 'raw_variables')
|
||||
out_derive_path = os.path.join(args.output_path, 'derived_variables')
|
||||
|
||||
logger.info('Calculating derived variables...')
|
||||
feature_df = der.run_derive(input_file, args.output_raw_path, args.output_derived_path, r_config, d_config)
|
||||
feature_df = der.run_derive(input_file, out_raw_path, out_derive_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("--output_path", help="path to the raw and derived variable output", required=True)
|
||||
parser.add_argument("--dbm_group", help="list of feature groups", nargs='+')
|
||||
|
||||
args = parser.parse_args()
|
||||
@@ -173,8 +178,6 @@ if __name__=="__main__":
|
||||
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)
|
||||
|
||||
process_derive(args, r_config, d_config, input_type)
|
||||
exec_time = time.time() - start_time
|
||||
logger.info('Done! Processing time: {} seconds'.format(exec_time))
|
||||
Reference in New Issue
Block a user