MCPcopy Index your code
hub / github.com/MotrixLab/ViMoGen / maybe_corrupt_ref_motion

Function maybe_corrupt_ref_motion

utils.py:164–197  ·  view source on GitHub ↗

Apply mild corruption to ref_motion using the shared utils routine.

(ref_motion: torch.Tensor,
                             ref_motion_mask: torch.Tensor,
                             cfg: dict | None,
                             is_test: bool = False)

Source from the content-addressed store, hash-verified

162
163
164def maybe_corrupt_ref_motion(ref_motion: torch.Tensor,
165 ref_motion_mask: torch.Tensor,
166 cfg: dict | None,
167 is_test: bool = False):
168 """Apply mild corruption to ref_motion using the shared utils routine."""
169 if not cfg or not cfg.get('enable', False):
170 return ref_motion, ref_motion_mask
171
172 device = ref_motion.device
173
174 def _get_value(key: str, default: float):
175 range_key = f'{key}_range'
176 if cfg.get(range_key, None) is not None:
177 return cfg.get(range_key)
178 return cfg.get(key, default)
179
180 corruption_kwargs = dict(
181 corrupt_rate=sample_from_range(_get_value('corrupt_rate', 0.1),
182 device=device),
183 noise_scale=sample_from_range(_get_value('noise_scale', 0.02),
184 device=device),
185 replace_noise_rate=sample_from_range(
186 _get_value('replace_noise_rate', 0.05), device=device),
187 dropout_rate=cfg.get('dropout_rate', 0.0),
188 temporal_dropout_rate=cfg.get('temporal_dropout_rate', 0.0),
189 jitter_strength=cfg.get('jitter_strength', 0.3),
190 )
191 corrupted, corrupted_mask = create_ref_motion(
192 ref_motion,
193 ref_motion_mask,
194 is_test=is_test,
195 **corruption_kwargs,
196 )
197 return corrupted, corrupted_mask

Callers 1

mainFunction · 0.90

Calls 3

sample_from_rangeFunction · 0.85
_get_valueFunction · 0.85
create_ref_motionFunction · 0.85

Tested by

no test coverage detected