From 517e54bf816ca9b445cc29e7aba4ba1e2f347022 Mon Sep 17 00:00:00 2001 From: Vidya Koesmahargyo Date: Mon, 30 Nov 2020 09:43:09 -0500 Subject: [PATCH] facial tremor testing --- dbm_lib/controller/process_feature.py | 6 ++- .../raw_features/movement/__init__.py | 1 + .../raw_features/video/open_face_process.py | 37 ++++++++++--------- process_data.py | 3 ++ 4 files changed, 29 insertions(+), 18 deletions(-) diff --git a/dbm_lib/controller/process_feature.py b/dbm_lib/controller/process_feature.py index f5112da2..488b835c 100644 --- a/dbm_lib/controller/process_feature.py +++ b/dbm_lib/controller/process_feature.py @@ -7,7 +7,7 @@ created: 2020-20-07 from dbm_lib.dbm_features.raw_features.audio import intensity, pitch_freq, hnr, gne, voice_frame_score, formant_freq from dbm_lib.dbm_features.raw_features.audio import pause_segment, jitter, shimmer, mfcc from dbm_lib.dbm_features.raw_features.video import face_asymmetry, face_au, face_emotion_expressivity, face_landmark -from dbm_lib.dbm_features.raw_features.movement import head_motion, eye_blink, voice_tremor +from dbm_lib.dbm_features.raw_features.movement import head_motion, eye_blink, voice_tremor, facial_tremor import subprocess import logging @@ -120,6 +120,7 @@ def process_movement(video_uri, out_dir, dbm_group, r_config, dlib_model): 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) @@ -129,6 +130,9 @@ def process_movement(video_uri, out_dir, dbm_group, r_config, dlib_model): logger.info('processing voice tremor....') voice_tremor.run_vtremor(video_uri, out_dir, r_config) + logger.info('processing facial tremor....') + face_tremor.fac_tremor_process(video_uri, out_dir, r_config, model_output=True) + def remove_file(file_path): """ removing wav file diff --git a/dbm_lib/dbm_features/raw_features/movement/__init__.py b/dbm_lib/dbm_features/raw_features/movement/__init__.py index dca2f624..03fd8909 100644 --- a/dbm_lib/dbm_features/raw_features/movement/__init__.py +++ b/dbm_lib/dbm_features/raw_features/movement/__init__.py @@ -13,3 +13,4 @@ import os DBMLIB_PATH = os.path.dirname(__file__) DBMLIB_VTREMOR_LIB = os.path.abspath(os.path.join(DBMLIB_PATH, '../../../../resources/libraries/voice_tremor.praat')) +DBMLIB_FTREMOR_CONFIG = os.path.abspath(os.path.join(DBMLIB_PATH, '../resources/features/facial/config.json')) diff --git a/dbm_lib/dbm_features/raw_features/video/open_face_process.py b/dbm_lib/dbm_features/raw_features/video/open_face_process.py index 292e2a98..61828b08 100644 --- a/dbm_lib/dbm_features/raw_features/video/open_face_process.py +++ b/dbm_lib/dbm_features/raw_features/video/open_face_process.py @@ -15,9 +15,9 @@ from dbm_lib.dbm_features.raw_features.util import util as ut logging.basicConfig(level=logging.INFO) logger=logging.getLogger() -def batch_open_face(filepaths,video_url, input_dir, out_dir, of_path): +def batch_open_face(filepaths,video_url, input_dir, out_dir, of_path,video_tracking=False): """ Computes open_face features for the files in filepaths - + Args: ----- filepaths: (itreable[str]) @@ -27,46 +27,49 @@ def batch_open_face(filepaths,video_url, input_dir, out_dir, of_path): input_dir: Path to the input videos out_dir: Path to the processed output of_path: OpenFace source code path - + Returns: -------- (itreable[str]) list of .csv files """ - - suffix = '_OF_features' + if video_tracking: + suffix = '_OF_video_features/' + else: + suffix = '_OF_features' + csv_files = [] - + for fp in filepaths: try: - + _, out_loc, fl_name = ut.filter_path(video_url, out_dir) full_f_name = fl_name + suffix output_directory = os.path.join(out_loc, full_f_name) csv_files.append(ut.compute_open_face_features(fp,output_directory,of_path)) - + except Exception as e: logger.error('Failed to run OpenFace on {}\n{}'.format(fp, e)) - + return csv_files - -def process_open_face(video_uri, input_dir, out_dir, of_path, dbm_group): + +def process_open_face(video_uri, input_dir, out_dir, of_path, dbm_group,video_tracking): """ Processing all patient's for fetching emotion expressivity ------------------- ------------------- Args: video_uri: video path; input_dir : input directory for video's; dbm_group: feature group - out_dir: (str) Output directory for processed output; of_path: OpenFace source code path - + out_dir: (str) Output directory for processed output; of_path: OpenFace source code path + """ try: - + if dbm_group != None and len(dbm_group) == 1 and 'acoustic' in dbm_group: return filepaths = [video_uri] - csv_filepaths = batch_open_face(filepaths, video_uri, input_dir, out_dir, of_path) - + csv_filepaths = batch_open_face(filepaths, video_uri, input_dir, out_dir, of_path,video_tracking) + except Exception as e: - logger.error('Failed to process video file') \ No newline at end of file + logger.error('Failed to process video file') diff --git a/process_data.py b/process_data.py index 31f85fdb..07d8f4af 100644 --- a/process_data.py +++ b/process_data.py @@ -19,6 +19,8 @@ import time logging.basicConfig(level=logging.INFO) logger=logging.getLogger() +#for ftremor +OPENFACE_PATH_VIDEO = '/pkg/OpenFace/build/bin/FaceLandmarkVid' OPENFACE_PATH = 'pkg/OpenFace/build/bin/FeatureExtraction' DLIB_SHAPE_MODEL = 'pkg/shape_detector/shape_predictor_68_face_landmarks.dat' @@ -35,6 +37,7 @@ def common_video(video_file, args, r_config): of.process_open_face(video_file, os.path.dirname(video_file), out_path, OPENFACE_PATH, args.dbm_group) pf.process_facial(video_file, out_path, args.dbm_group, r_config) pf.process_acoustic(video_file, out_path, args.dbm_group, r_config) + of.process_open_face(video_file, os.path.dirname(video_file), out_path, OPENFACE_PATH_VIDEO, args.dbm_group,video_tracking=True) pf.process_movement(video_file, out_path, args.dbm_group, r_config, DLIB_SHAPE_MODEL) pf.remove_file(video_file)