@@ -94,9 +94,9 @@ This is the entire denoising process, and you can use this same pattern to write
9494>> > from PIL import Image
9595>> > import numpy as np
9696
97- >> > image = (input / 2 + 0.5 ).clamp(0 , 1 )
98- >> > image = image.cpu(). permute(0 , 2 , 3 , 1 ). numpy()[ 0 ]
99- >> > image = Image.fromarray(( image * 255 ).round().astype( " uint8 " ) )
97+ >> > image = (input / 2 + 0.5 ).clamp(0 , 1 ).squeeze()
98+ >> > image = ( image.permute(1 , 2 , 0 ) * 255 ).round().to(torch.uint8).cpu(). numpy()
99+ >> > image = Image.fromarray(image)
100100>> > image
101101```
102102
@@ -267,11 +267,11 @@ with torch.no_grad():
267267Lastly, convert the image to a ` PIL.Image ` to see your generated image!
268268
269269``` py
270- >> > image = (image / 2 + 0.5 ).clamp(0 , 1 )
271- >> > image = image.detach().cpu(). permute(0 , 2 , 3 , 1 ).numpy()
270+ >> > image = (image / 2 + 0.5 ).clamp(0 , 1 ).squeeze()
271+ >> > image = ( image.permute(1 , 2 , 0 ) * 255 ).to(torch.uint8).cpu( ).numpy()
272272>> > images = (image * 255 ).round().astype(" uint8" )
273- >> > pil_images = [ Image.fromarray(image) for image in images]
274- >> > pil_images[ 0 ]
273+ >> > image = Image.fromarray(image)
274+ >> > image
275275```
276276
277277<div class =" flex justify-center " >
0 commit comments