MCPcopy Create free account
hub / github.com/MotrixLab/insactor / Normalize

Class Normalize

diffplanner/datasets/pipelines/transforms.py:101–125  ·  view source on GitHub ↗

Normalize motion sequences. Args: mean_path (str): Path of mean file. std_path (str): Path of std file.

Source from the content-addressed store, hash-verified

99
100@PIPELINES.register_module()
101class Normalize(object):
102 """Normalize motion sequences.
103
104 Args:
105 mean_path (str): Path of mean file.
106 std_path (str): Path of std file.
107 """
108
109 def __init__(self, mean_path, std_path, eps=1e-9):
110 self.mean = np.load(mean_path)
111 self.std = np.load(std_path)
112 self.eps = eps
113
114 def __call__(self, results):
115 motion = results['motion']
116 if motion.shape[-1] < self.mean.shape[0]:
117 # print('Warning: padding motion')
118 motion = np.concatenate([motion, np.zeros_like(motion[..., :self.mean.shape[0]-motion.shape[-1]])], axis=-1)
119 elif motion.shape[-1] > self.mean.shape[0]:
120 motion = motion[..., :self.mean.shape[0]]
121 motion = (motion - self.mean) / (self.std + self.eps)
122 results['motion'] = motion
123 results['motion_norm_mean'] = self.mean
124 results['motion_norm_std'] = self.std
125 return results

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected