From 3cd7d84b53724a97c1436f70b6da6975e3d93484 Mon Sep 17 00:00:00 2001 From: comfyanonymous Date: Sun, 26 Feb 2023 04:01:01 -0500 Subject: [PATCH] Fix uni_pc sampler not working with 1 or 2 steps. --- comfy/extra_samplers/uni_pc.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/comfy/extra_samplers/uni_pc.py b/comfy/extra_samplers/uni_pc.py index cc3153bf..e96cfc93 100644 --- a/comfy/extra_samplers/uni_pc.py +++ b/comfy/extra_samplers/uni_pc.py @@ -875,8 +875,9 @@ def sample_unipc(model, noise, image, sigmas, sampling_function, max_denoise, ex model_kwargs=extra_args, ) + order = min(3, len(timesteps) - 1) uni_pc = UniPC(model_fn, ns, predict_x0=True, thresholding=False, noise_mask=noise_mask, masked_image=image, noise=noise, variant=variant) - x = uni_pc.sample(img, timesteps=timesteps, skip_type="time_uniform", method="multistep", order=3, lower_order_final=True) + x = uni_pc.sample(img, timesteps=timesteps, skip_type="time_uniform", method="multistep", order=order, lower_order_final=True) if not to_zero: x /= ns.marginal_alpha(timesteps[-1]) return x