Skip to content

Commit aa3c46d

Browse files
LagPixelLOLasomoza
andauthored
[Doc] Improved level of clarity for latents_to_rgb. (huggingface#9529)
Fixed latents_to_rgb doc. Co-authored-by: Álvaro Somoza <[email protected]>
1 parent c76e884 commit aa3c46d

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

docs/source/en/using-diffusers/callback.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,13 @@ def latents_to_rgb(latents):
171171
weights = (
172172
(60, -60, 25, -70),
173173
(60, -5, 15, -50),
174-
(60, 10, -5, -35)
174+
(60, 10, -5, -35),
175175
)
176176

177177
weights_tensor = torch.t(torch.tensor(weights, dtype=latents.dtype).to(latents.device))
178178
biases_tensor = torch.tensor((150, 140, 130), dtype=latents.dtype).to(latents.device)
179179
rgb_tensor = torch.einsum("...lxy,lr -> ...rxy", latents, weights_tensor) + biases_tensor.unsqueeze(-1).unsqueeze(-1)
180-
image_array = rgb_tensor.clamp(0, 255)[0].byte().cpu().numpy()
181-
image_array = image_array.transpose(1, 2, 0)
180+
image_array = rgb_tensor.clamp(0, 255).byte().cpu().numpy().transpose(1, 2, 0)
182181

183182
return Image.fromarray(image_array)
184183
```
@@ -189,7 +188,7 @@ def latents_to_rgb(latents):
189188
def decode_tensors(pipe, step, timestep, callback_kwargs):
190189
latents = callback_kwargs["latents"]
191190

192-
image = latents_to_rgb(latents)
191+
image = latents_to_rgb(latents[0])
193192
image.save(f"{step}.png")
194193

195194
return callback_kwargs

0 commit comments

Comments
 (0)