Skip to content
Snippets Groups Projects

Slightly Flawed Set-Up for First Reprocess

parent 96eccc5f
Branches clean
No related tags found
No related merge requests found
...@@ -24,15 +24,17 @@ def parse_args(): ...@@ -24,15 +24,17 @@ def parse_args():
default=str("/vol/vssp/LF_datasets/multiview/smile-ii/PARTICIPANTS"), default=str("/vol/vssp/LF_datasets/multiview/smile-ii/PARTICIPANTS"),
help="Directory with all the SMILE-II Video.") help="Directory with all the SMILE-II Video.")
parser.add_argument('--annotation_file', '-a' , type=str, parser.add_argument('--annotation_file', '-a' , type=str,
default=str("/vol/research/signFaces/non_manual_annotations/clean_annotations_l1.json"), default=str("/vol/research/signFaces/non_manual_annotations/clean_annotations_l2.json"),
help="Directory with all the SMILE-II Video.") help="Directory with all the SMILE-II Video.")
parser.add_argument('--output_file', '-o' , type=str, parser.add_argument('--output_file', '-o' , type=str,
default=str("/vol/research/signFaces/SMILE-II-Reprocessed/L1.pkl"), default=str("/vol/research/signFaces/SMILE-II-Reprocessed/L2-Flipped.pkl"),
help="Location to save the output file.") help="Location to save the output file.")
parser.add_argument('--checkpoint', '-c' , type=str, parser.add_argument('--checkpoint', '-c' , type=str,
default=None, default=None,
help="Location to save the output file.") help="Location to save the output file.")
parser.add_argument('--flip', '-f', action="store_true",
help="Flip the video before processing.")
parser.add_argument('--model_name', '-m', type=str, parser.add_argument('--model_name', '-m', type=str,
default='EMOCA_v2_lr_mse_20', default='EMOCA_v2_lr_mse_20',
choices=["EMOCA_v2_lr_mse_20", "EMOCA_v2_lr_cos_1.5. EMOCA, EMOCA_v2_mp"], choices=["EMOCA_v2_lr_mse_20", "EMOCA_v2_lr_cos_1.5. EMOCA, EMOCA_v2_mp"],
...@@ -54,6 +56,8 @@ def parse_args(): ...@@ -54,6 +56,8 @@ def parse_args():
face_detector, emoca_instance = None, None face_detector, emoca_instance = None, None
flip = False
def setup(path_to_models, model_name, mode): def setup(path_to_models, model_name, mode):
global face_detector, emoca_instance global face_detector, emoca_instance
with tempfile.TemporaryDirectory() as temp_dir: with tempfile.TemporaryDirectory() as temp_dir:
...@@ -70,14 +74,16 @@ def processing_function(cap: cv2.VideoCapture, remaining_frames: int): ...@@ -70,14 +74,16 @@ def processing_function(cap: cv2.VideoCapture, remaining_frames: int):
""" """
Reconstructs a video with the EMOCA model. Reconstructs a video with the EMOCA model.
""" """
global face_detector, emoca_instance global face_detector, emoca_instance, flip
# Run the EMOCA model on each frame # Run the EMOCA model on each frame
data = np.zeros((remaining_frames), dtype=dict) data = np.zeros((remaining_frames), dtype=dict)
for idx in tqdm(range(remaining_frames)): for idx in tqdm(range(remaining_frames), leave=False):
# Read from Capture # Read from Capture
ret, frame = cap.read() ret, frame = cap.read()
if not ret: if not ret:
break break
if flip:
frame = cv2.flip(frame, 1)
# Run detection # Run detection
detection_images, detection_centers, detection_sizes, \ detection_images, detection_centers, detection_sizes, \
...@@ -114,11 +120,13 @@ def processing_function(cap: cv2.VideoCapture, remaining_frames: int): ...@@ -114,11 +120,13 @@ def processing_function(cap: cv2.VideoCapture, remaining_frames: int):
return data return data
def main(): def main():
args = parse_args() global flip
args = parse_args()
video_root = Path(args.video_root_dir) video_root = Path(args.video_root_dir)
annotations_path = Path(args.annotation_file) annotations_path = Path(args.annotation_file)
output_file = Path(args.output_file) output_file = Path(args.output_file)
checkpoint = Path(args.checkpoint) if args.checkpoint is not None else None checkpoint = Path(args.checkpoint) if args.checkpoint is not None else None
flip = args.flip
annotations = json.load(annotations_path.open("r")) annotations = json.load(annotations_path.open("r"))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment