Skip to content

Commit 757babf

Browse files
authored
Fix indentation in the code example (#802)
Update custom_pipelines.mdx
1 parent e895952 commit 757babf

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

docs/source/using-diffusers/custom_pipelines.mdx

+13-13
Original file line numberDiff line numberDiff line change
@@ -91,24 +91,24 @@ class MyPipeline(DiffusionPipeline):
9191
# Sample gaussian noise to begin loop
9292
image = torch.randn((batch_size, self.unet.in_channels, self.unet.sample_size, self.unet.sample_size))
9393

94-
image = image.to(self.device)
94+
image = image.to(self.device)
9595

96-
# set step values
97-
self.scheduler.set_timesteps(num_inference_steps)
96+
# set step values
97+
self.scheduler.set_timesteps(num_inference_steps)
9898

99-
for t in self.progress_bar(self.scheduler.timesteps):
100-
# 1. predict noise model_output
101-
model_output = self.unet(image, t).sample
99+
for t in self.progress_bar(self.scheduler.timesteps):
100+
# 1. predict noise model_output
101+
model_output = self.unet(image, t).sample
102102

103-
# 2. predict previous mean of image x_t-1 and add variance depending on eta
104-
# eta corresponds to η in paper and should be between [0, 1]
105-
# do x_t -> x_t-1
106-
image = self.scheduler.step(model_output, t, image, eta).prev_sample
103+
# 2. predict previous mean of image x_t-1 and add variance depending on eta
104+
# eta corresponds to η in paper and should be between [0, 1]
105+
# do x_t -> x_t-1
106+
image = self.scheduler.step(model_output, t, image, eta).prev_sample
107107

108-
image = (image / 2 + 0.5).clamp(0, 1)
109-
image = image.cpu().permute(0, 2, 3, 1).numpy()
108+
image = (image / 2 + 0.5).clamp(0, 1)
109+
image = image.cpu().permute(0, 2, 3, 1).numpy()
110110

111-
return image
111+
return image
112112
```
113113

114114
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.

0 commit comments

Comments
 (0)