From 652dd2ce8f3624779733bc2f666dea3f40db6d0c Mon Sep 17 00:00:00 2001 From: Omar Sanseviero Date: Tue, 11 Oct 2022 10:21:17 +0200 Subject: [PATCH] Update custom_pipelines.mdx --- .../using-diffusers/custom_pipelines.mdx | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/source/using-diffusers/custom_pipelines.mdx b/docs/source/using-diffusers/custom_pipelines.mdx index 9466f1dcbda6..b52d405581b1 100644 --- a/docs/source/using-diffusers/custom_pipelines.mdx +++ b/docs/source/using-diffusers/custom_pipelines.mdx @@ -91,24 +91,24 @@ class MyPipeline(DiffusionPipeline): # Sample gaussian noise to begin loop image = torch.randn((batch_size, self.unet.in_channels, self.unet.sample_size, self.unet.sample_size)) - image = image.to(self.device) + image = image.to(self.device) - # set step values - self.scheduler.set_timesteps(num_inference_steps) + # set step values + self.scheduler.set_timesteps(num_inference_steps) - for t in self.progress_bar(self.scheduler.timesteps): - # 1. predict noise model_output - model_output = self.unet(image, t).sample + for t in self.progress_bar(self.scheduler.timesteps): + # 1. predict noise model_output + model_output = self.unet(image, t).sample - # 2. predict previous mean of image x_t-1 and add variance depending on eta - # eta corresponds to η in paper and should be between [0, 1] - # do x_t -> x_t-1 - image = self.scheduler.step(model_output, t, image, eta).prev_sample + # 2. predict previous mean of image x_t-1 and add variance depending on eta + # eta corresponds to η in paper and should be between [0, 1] + # do x_t -> x_t-1 + image = self.scheduler.step(model_output, t, image, eta).prev_sample - image = (image / 2 + 0.5).clamp(0, 1) - image = image.cpu().permute(0, 2, 3, 1).numpy() + image = (image / 2 + 0.5).clamp(0, 1) + image = image.cpu().permute(0, 2, 3, 1).numpy() - return image + return image ``` Now you can upload this short file under the name `pipeline.py` in your preferred [model repository](https://huggingface.co/docs/hub/models-uploading). For Stable Diffusion pipelines, you may also [join the community organisation for shared pipelines](https://huggingface.co/organizations/sd-diffusers-pipelines-library/share/BUPyDUuHcciGTOKaExlqtfFcyCZsVFdrjr) to upload yours.