MCPcopy Create free account
hub / github.com/VisionXLab/OF-Diff / __init__

Method __init__

ldm/models/diffusion/dpm_solver/dpm_solver.py:320–344  ·  view source on GitHub ↗

Construct a DPM-Solver. We support both the noise prediction model ("predicting epsilon") and the data prediction model ("predicting x0"). If `predict_x0` is False, we use the solver for the noise prediction model (DPM-Solver). If `predict_x0` is True, we use the solver for t

(self, model_fn, noise_schedule, predict_x0=False, thresholding=False, max_val=1.)

Source from the content-addressed store, hash-verified

318
319class DPM_Solver:
320 def __init__(self, model_fn, noise_schedule, predict_x0=False, thresholding=False, max_val=1.):
321 """Construct a DPM-Solver.
322 We support both the noise prediction model ("predicting epsilon") and the data prediction model ("predicting x0").
323 If `predict_x0` is False, we use the solver for the noise prediction model (DPM-Solver).
324 If `predict_x0` is True, we use the solver for the data prediction model (DPM-Solver++).
325 In such case, we further support the "dynamic thresholding" in [1] when `thresholding` is True.
326 The "dynamic thresholding" can greatly improve the sample quality for pixel-space DPMs with large guidance scales.
327 Args:
328 model_fn: A noise prediction model function which accepts the continuous-time input (t in [epsilon, T]):
329 ``
330 def model_fn(x, t_continuous):
331 return noise
332 ``
333 noise_schedule: A noise schedule object, such as NoiseScheduleVP.
334 predict_x0: A `bool`. If true, use the data prediction model; else, use the noise prediction model.
335 thresholding: A `bool`. Valid when `predict_x0` is True. Whether to use the "dynamic thresholding" in [1].
336 max_val: A `float`. Valid when both `predict_x0` and `thresholding` are True. The max value for thresholding.
337
338 [1] Chitwan Saharia, William Chan, Saurabh Saxena, Lala Li, Jay Whang, Emily Denton, Seyed Kamyar Seyed Ghasemipour, Burcu Karagol Ayan, S Sara Mahdavi, Rapha Gontijo Lopes, et al. Photorealistic text-to-image diffusion models with deep language understanding. arXiv preprint arXiv:2205.11487, 2022b.
339 """
340 self.model = model_fn
341 self.noise_schedule = noise_schedule
342 self.predict_x0 = predict_x0
343 self.thresholding = thresholding
344 self.max_val = max_val
345
346 def noise_prediction_fn(self, x, t):
347 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected