Skip to content

Commit 258c7ba

Browse files
committed
convert
1 parent ec87400 commit 258c7ba

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

examples/text_to_image/pipeline_stable_diffusion_img2img_render_text.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,15 @@ def preprocess(image):
3333
image = [image]
3434

3535
if isinstance(image[0], PIL.Image.Image):
36-
w, h = image[0].size
37-
w, h = map(lambda x: x - x % 32, (w, h)) # resize to integer multiple of 32
38-
39-
image = [np.array(i.resize((w, h), resample=PIL_INTERPOLATION["lanczos"]))[None, :] for i in image]
40-
image = np.concatenate(image, axis=0)
41-
image = np.array(image).astype(np.float32) / 255.0
42-
image = image.transpose(0, 3, 1, 2)
43-
image = 2.0 * image - 1.0
36+
#w, h = image[0].size
37+
#w, h = map(lambda x: x - x % 32, (w, h)) # resize to integer multiple of 32
38+
39+
#image = [np.array(i.resize((w, h), resample=PIL_INTERPOLATION["lanczos"]))[None, :] for i in image]
40+
#image = np.concatenate(image, axis=0)
41+
#image = np.array(image).astype(np.float32) / 255.0
42+
#image = image.transpose(0, 3, 1, 2)
43+
#image = 2.0 * image - 1.0
44+
image = image.convert("RGB")
4445
image = torch.from_numpy(image)
4546
elif isinstance(image[0], torch.Tensor):
4647
image = torch.cat(image, dim=0)

0 commit comments

Comments
 (0)