MCPcopy Create free account
hub / github.com/MotrixLab/ViMoGen / smooth_motion_rep

Function smooth_motion_rep

utils.py:144–161  ·  view source on GitHub ↗

Temporal Gaussian smoothing for motion representation.

(motion_rep, kernel_size: int, sigma: float)

Source from the content-addressed store, hash-verified

142
143
144def smooth_motion_rep(motion_rep, kernel_size: int, sigma: float):
145 """Temporal Gaussian smoothing for motion representation."""
146 assert kernel_size % 2 == 1, 'kernel_size must be odd'
147 data_dim = motion_rep.shape[-1]
148 padding = (kernel_size - 1) // 2
149 kernel = gaussian_kernel(kernel_size,
150 sigma).to(motion_rep.device)[None, None,
151 :].repeat(
152 data_dim, 1, 1)
153 motion_rep_smoothed = torch.nn.functional.conv1d(
154 motion_rep.transpose(0, 1).unsqueeze(0),
155 kernel,
156 padding=padding,
157 groups=data_dim)
158 motion_rep_smoothed = motion_rep_smoothed.squeeze(0).transpose(0, 1)
159 motion_rep_smoothed[:padding] = motion_rep[:padding]
160 motion_rep_smoothed[-padding:] = motion_rep[-padding:]
161 return motion_rep_smoothed
162
163
164def maybe_corrupt_ref_motion(ref_motion: torch.Tensor,

Callers 1

generate_pipeFunction · 0.90

Calls 1

gaussian_kernelFunction · 0.85

Tested by

no test coverage detected