Skip to content

Commit 21a7bda

Browse files
committed
convert
1 parent 258c7ba commit 21a7bda

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

examples/text_to_image/pipeline_stable_diffusion_img2img_render_text.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +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
36+
w, h = image[0].size
37+
w, h = map(lambda x: x - x % 32, (w, h)) # resize to integer multiple of 32
3838

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
39+
image = [image.convert("RGB") for i in image]
40+
image = [np.array(i.resize((w, h), resample=PIL_INTERPOLATION["lanczos"]))[None, :] for i in image]
41+
image = np.concatenate(image, axis=0)
42+
image = np.array(image).astype(np.float32) / 255.0
4243
#image = image.transpose(0, 3, 1, 2)
43-
#image = 2.0 * image - 1.0
44-
image = image.convert("RGB")
44+
image = 2.0 * image - 1.0
4545
image = torch.from_numpy(image)
4646
elif isinstance(image[0], torch.Tensor):
4747
image = torch.cat(image, dim=0)

0 commit comments

Comments
 (0)