autorotate init images using exif orientation tag

This commit is contained in:
Lincoln Stein 2022-10-07 12:05:33 -04:00
parent 70bb7f4a61
commit 3d7bc074cf

View File

@ -848,6 +848,7 @@ class Generate:
print(
f'>> loaded input image of size {image.width}x{image.height}'
)
image = ImageOps.exif_transpose(image)
return image
def _create_init_image(self, image, width, height, fit=True):
@ -856,7 +857,6 @@ class Generate:
image = self._fit_image(image, (width, height))
else:
image = self._squeeze_image(image)
image = np.array(image).astype(np.float32) / 255.0
image = image[None].transpose(0, 3, 1, 2)
image = torch.from_numpy(image)
@ -873,7 +873,6 @@ class Generate:
image = self._fit_image(image, (width, height))
else:
image = self._squeeze_image(image)
image = image.resize((image.width//downsampling, image.height //
downsampling), resample=Image.Resampling.NEAREST)
image = np.array(image)