MCPcopy Index your code
hub / github.com/VisionXLab/OF-Diff / apply_model

Method apply_model

ldm/models/diffusion/ddpm.py:858–873  ·  view source on GitHub ↗
(self, x_noisy, t, cond, return_ids=False)

Source from the content-addressed store, hash-verified

856 return self.p_losses(x, c, t, *args, **kwargs)
857
858 def apply_model(self, x_noisy, t, cond, return_ids=False):
859 if isinstance(cond, dict):
860 # hybrid case, cond is expected to be a dict
861 pass
862 else:
863 if not isinstance(cond, list):
864 cond = [cond]
865 key = 'c_concat' if self.model.conditioning_key == 'concat' else 'c_crossattn'
866 cond = {key: cond}
867
868 x_recon = self.model(x_noisy, t, **cond)
869
870 if isinstance(x_recon, tuple) and not return_ids:
871 return x_recon[0]
872 else:
873 return x_recon
874
875 def _predict_eps_from_xstart(self, x_t, t, pred_xstart):
876 return (extract_into_tensor(self.sqrt_recip_alphas_cumprod, t, x_t.shape) * x_t - pred_xstart) / \

Callers 6

p_lossesMethod · 0.95
p_mean_varianceMethod · 0.95
p_sample_ddimMethod · 0.45
encodeMethod · 0.45
get_model_outputMethod · 0.45
sampleMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected