From 982dc10e640ac87fe470845d4ccbd5ed6f7d7d49 Mon Sep 17 00:00:00 2001 From: Sean Sube Date: Wed, 12 Apr 2023 23:44:08 -0500 Subject: [PATCH] fix(api): make pix2pix work with scheduler with float sigma --- api/onnx_web/diffusers/pipelines/pix2pix.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/api/onnx_web/diffusers/pipelines/pix2pix.py b/api/onnx_web/diffusers/pipelines/pix2pix.py index 94a3e3ce..180dc007 100644 --- a/api/onnx_web/diffusers/pipelines/pix2pix.py +++ b/api/onnx_web/diffusers/pipelines/pix2pix.py @@ -323,7 +323,12 @@ class OnnxStableDiffusionInstructPix2PixPipeline(DiffusionPipeline): raise ValueError( f"Unexpected latents shape, got {latents.shape}, expected {latents_shape}" ) - latents = latents * self.scheduler.init_noise_sigma.numpy() + + init_noise_sigma = self.scheduler.init_noise_sigma + if torch.is_tensor(init_noise_sigma): + init_noise_sigma = init_noise_sigma.numpy() + + latents = latents * init_noise_sigma # 7. Check that shapes of latents and image match the UNet channels num_channels_image = image_latents.shape[1]