1
1
import numpy as np
2
2
from pose_format import Pose
3
- from sign_vq . data . normalize import pre_process_mediapipe , normalize_mean_std , unnormalize_mean_std , unshift_hand
3
+ from pose_format . utils . generic import reduce_holistic , correct_wrists , pose_normalization_info
4
4
5
5
6
6
def normalize_pose_size (pose : Pose ):
@@ -11,9 +11,17 @@ def normalize_pose_size(pose: Pose):
11
11
pose .header .dimensions .height = pose .header .dimensions .width = int (new_width * shift * 2 )
12
12
13
13
14
+ def reduce_pose (pose : Pose ):
15
+ # Remove legs, simplify face
16
+ pose = reduce_holistic (pose )
17
+ # Align hand wrists with body wrists
18
+ correct_wrists (pose )
19
+ # Adjust pose based on shoulder positions
20
+ return pose .normalize (pose_normalization_info (pose .header ))
21
+
22
+
14
23
def get_pose_apperance (pose : Pose , include_end_frame = False ):
15
- pose = pre_process_mediapipe (pose )
16
- pose = normalize_mean_std (pose )
24
+ pose = reduce_pose (pose )
17
25
18
26
if include_end_frame :
19
27
# Assuming the first and last frames are indicative of the signer's appearance
@@ -46,18 +54,18 @@ def change_appearace(pose: Pose, appearance: np.ndarray):
46
54
47
55
pose .body .data = new_pose_data
48
56
49
- pose = unnormalize_mean_std (pose )
50
- for component in hand_components :
51
- unshift_hand (pose , component )
52
-
53
57
normalize_pose_size (pose )
54
58
55
59
return pose
56
60
57
61
58
62
def remove_appearance (pose : Pose , include_end_frame = False ):
59
63
pose , appearance = get_pose_apperance (pose , include_end_frame )
60
- return change_appearace (pose , appearance )
64
+ # pylint: disable=import-outside-toplevel
65
+ from sign_vq .data .normalize import load_mean_and_std
66
+ mean , _ = load_mean_and_std ()
67
+
68
+ return change_appearace (pose , appearance - mean )
61
69
62
70
63
71
def transfer_appearance (pose : Pose , appearance_pose : Pose , include_end_frame = False ):
0 commit comments