MCPcopy Create free account
hub / github.com/OpenImagingLab/4DSloMo / check

Method check

FixModel.py:331–351  ·  view source on GitHub ↗
(self, dit: WanModel, x, t_mod)

Source from the content-addressed store, hash-verified

329 self.coefficients = self.coefficients_dict[model_id]
330
331 def check(self, dit: WanModel, x, t_mod):
332 modulated_inp = t_mod.clone()
333 if self.step == 0 or self.step == self.num_inference_steps - 1:
334 should_calc = True
335 self.accumulated_rel_l1_distance = 0
336 else:
337 coefficients = self.coefficients
338 rescale_func = np.poly1d(coefficients)
339 self.accumulated_rel_l1_distance += rescale_func(((modulated_inp-self.previous_modulated_input).abs().mean() / self.previous_modulated_input.abs().mean()).cpu().item())
340 if self.accumulated_rel_l1_distance < self.rel_l1_thresh:
341 should_calc = False
342 else:
343 should_calc = True
344 self.accumulated_rel_l1_distance = 0
345 self.previous_modulated_input = modulated_inp
346 self.step += 1
347 if self.step == self.num_inference_steps:
348 self.step = 0
349 if should_calc:
350 self.previous_hidden_states = x.clone()
351 return not should_calc
352
353 def store(self, hidden_states):
354 self.previous_residual = hidden_states - self.previous_hidden_states

Callers 1

model_fn_wan_videoFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected