MCPcopy Create free account
hub / github.com/Francis-Rings/FlashPortrait / get_emo_feature

Function get_emo_feature

fast_infer.py:513–542  ·  view source on GitHub ↗
(video_path, face_aligner, pd_fpg_motion, device=torch.device("cuda"))

Source from the content-addressed store, hash-verified

511 return 0
512
513def get_emo_feature(video_path, face_aligner, pd_fpg_motion, device=torch.device("cuda")):
514 pd_fpg_motion = pd_fpg_motion.to(device)
515 cap = cv2.VideoCapture(video_path)
516 fps = cap.get(cv2.CAP_PROP_FPS)
517 frame_list = []
518 ret, frame = cap.read()
519 while ret:
520 resized_frame = frame
521 frame_list.append(resized_frame.copy())
522 ret, frame = cap.read()
523 cap.release()
524 num_frames = len(frame_list)
525 num_frames = find_replacement(num_frames)
526 frame_list = frame_list[:num_frames]
527 landmark_list = det_landmarks(face_aligner, frame_list)[1]
528 emo_list = get_drive_expression_pd_fgc(pd_fpg_motion, frame_list, landmark_list, device)
529 emo_feat_list = []
530 head_emo_feat_list = []
531 for emo in emo_list:
532 headpose_emb = emo["headpose_emb"]
533 eye_embed = emo["eye_embed"]
534 emo_embed = emo["emo_embed"]
535 mouth_feat = emo["mouth_feat"]
536 emo_feat = torch.cat([eye_embed, emo_embed, mouth_feat], dim=1)
537 head_emo_feat = torch.cat([headpose_emb, emo_feat], dim=1)
538 emo_feat_list.append(emo_feat)
539 head_emo_feat_list.append(head_emo_feat)
540 emo_feat_all = torch.cat(emo_feat_list, dim=0)
541 head_emo_feat_all = torch.cat(head_emo_feat_list, dim=0)
542 return emo_feat_all, head_emo_feat_all, fps, num_frames
543
544with torch.no_grad():
545 image_start = clip_image = Image.open(validation_image_start).convert("RGB")

Callers 1

fast_infer.pyFile · 0.70

Calls 3

det_landmarksFunction · 0.90
find_replacementFunction · 0.70

Tested by

no test coverage detected