1
0
mirror of https://github.com/huggingface/diffusers.git synced 2026-01-27 17:22:53 +03:00

[IF super res] correctly normalize PIL input (#3536)

* [IF super res] correctl normalize PIL input

* 175 -> 127.5
This commit is contained in:
Will Berman
2023-05-26 10:59:44 -07:00
committed by GitHub
parent 1d1f648c6b
commit bdc75e753d
3 changed files with 3 additions and 3 deletions

View File

@@ -759,7 +759,7 @@ class IFImg2ImgSuperResolutionPipeline(DiffusionPipeline):
image = [image]
if isinstance(image[0], PIL.Image.Image):
image = [np.array(i).astype(np.float32) / 255.0 for i in image]
image = [np.array(i).astype(np.float32) / 127.5 - 1.0 for i in image]
image = np.stack(image, axis=0) # to np
image = torch.from_numpy(image.transpose(0, 3, 1, 2))

View File

@@ -795,7 +795,7 @@ class IFInpaintingSuperResolutionPipeline(DiffusionPipeline):
image = [image]
if isinstance(image[0], PIL.Image.Image):
image = [np.array(i).astype(np.float32) / 255.0 for i in image]
image = [np.array(i).astype(np.float32) / 127.5 - 1.0 for i in image]
image = np.stack(image, axis=0) # to np
image = torch.from_numpy(image.transpose(0, 3, 1, 2))

View File

@@ -664,7 +664,7 @@ class IFSuperResolutionPipeline(DiffusionPipeline):
image = [image]
if isinstance(image[0], PIL.Image.Image):
image = [np.array(i).astype(np.float32) / 255.0 for i in image]
image = [np.array(i).astype(np.float32) / 127.5 - 1.0 for i in image]
image = np.stack(image, axis=0) # to np
image = torch.from_numpy(image.transpose(0, 3, 1, 2))