Skip to content

Commit ba09b47

Browse files
committed
feat(appearance): remove dependency on pose vq
1 parent 906e165 commit ba09b47

File tree

5 files changed

+6565
-4
lines changed

5 files changed

+6565
-4
lines changed

pose_anonymization/appearance.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
from pose_format.numpy import NumPyPoseBody
66
from pose_format.utils.generic import pose_normalization_info
77

8+
from pose_anonymization.data import load_mean_and_std, load_pose_header
9+
810

911
def normalize_pose_size(pose: Pose):
1012
new_width = 200
@@ -58,8 +60,6 @@ def change_appearace(pose: Pose, appearance: np.ndarray):
5860

5961
@lru_cache(maxsize=1)
6062
def get_mean_appearance():
61-
# pylint: disable=import-outside-toplevel
62-
from sign_vq.data.normalize import load_mean_and_std, load_pose_header
6363
mean, _ = load_mean_and_std()
6464

6565
data = mean.reshape((1, 1, -1, 3)) * 1000

pose_anonymization/data/__init__.py

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from functools import lru_cache
2+
from pathlib import Path
3+
4+
import numpy as np
5+
from pose_format import PoseHeader
6+
from pose_format.utils.reader import BufferReader
7+
8+
CURRENT_DIR = Path(__file__).parent
9+
10+
11+
@lru_cache(maxsize=1)
12+
def load_pose_header():
13+
with open(CURRENT_DIR / "header.poseheader", "rb") as f:
14+
return PoseHeader.read(BufferReader(f.read()))
15+
16+
17+
@lru_cache(maxsize=1)
18+
def load_mean_and_std():
19+
import json
20+
with open(CURRENT_DIR / "pose_normalization.json", "r", encoding="utf-8") as f:
21+
data = json.load(f)
22+
23+
mean, std = [], []
24+
for component in data.values():
25+
for point in component.values():
26+
mean.append(point["mean"])
27+
std.append(point["std"])
28+
29+
# when std is 0, set std to 1
30+
std = np.array(std)
31+
std[std == 0] = 1
32+
33+
return np.array(mean), std
13.9 KB
Binary file not shown.

0 commit comments

Comments
 (0)