Skip to content

Commit 4e3538e

Browse files
committed
feat(appearance): simplify appearance removal, make sign-vq option
1 parent a6d3708 commit 4e3538e

File tree

11 files changed

+19
-12
lines changed

11 files changed

+19
-12
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ anonymized_pose = remove_appearance(pose)
3636

3737
Currently implemented in this repository.
3838

39-
Using the mean and standard deviation of sign language poses calculated by
39+
Using the mean of sign language poses calculated by
4040
[`sign-language-processing/sign-vq`](https://github.com/sign-language-processing/sign-vq),
4141
we can anonymize a pose sequence by assuming the first frame is only the appearance of the person,
42-
and remove it from the rest of the frames.
42+
and remove it from the rest of the frames, then add the mean.
4343

4444
(Example generated using `./scripts/create_example.sh`, transferred to `assets/example/interpreter.pose`)
4545

assets/example/anonymized/essen.pose

0 Bytes
Binary file not shown.

assets/example/anonymized/kinder.pose

0 Bytes
Binary file not shown.

assets/example/anonymized/kleine.pose

0 Bytes
Binary file not shown.

assets/example/anonymized/pizza.pose

0 Bytes
Binary file not shown.

assets/example/interpreter/essen.pose

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

assets/example/interpreter/pizza.pose

0 Bytes
Binary file not shown.

pose_anonymization/appearance.py

+16-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import numpy as np
22
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
44

55

66
def normalize_pose_size(pose: Pose):
@@ -11,9 +11,17 @@ def normalize_pose_size(pose: Pose):
1111
pose.header.dimensions.height = pose.header.dimensions.width = int(new_width * shift * 2)
1212

1313

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+
1423
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)
1725

1826
if include_end_frame:
1927
# 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):
4654

4755
pose.body.data = new_pose_data
4856

49-
pose = unnormalize_mean_std(pose)
50-
for component in hand_components:
51-
unshift_hand(pose, component)
52-
5357
normalize_pose_size(pose)
5458

5559
return pose
5660

5761

5862
def remove_appearance(pose: Pose, include_end_frame=False):
5963
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)
6169

6270

6371
def transfer_appearance(pose: Pose, appearance_pose: Pose, include_end_frame=False):

pyproject.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ authors = [
88
readme = "README.md"
99
dependencies = [
1010
"pose-format",
11-
"sign_vq @ git+https://github.com/sign-language-processing/sign-vq"
12-
11+
# "sign_vq @ git+https://github.com/sign-language-processing/sign-vq" # For pose anonymization, not transfer
1312
]
1413

1514
[project.optional-dependencies]

0 commit comments

Comments
 (0)