autorotate init images using exif orientation tag

This commit is contained in:
Lincoln Stein 2022-10-07 12:05:33 -04:00
parent 45cc867b0c
commit b296933ba0

View File

@ -849,6 +849,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):
@ -857,7 +858,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)
@ -874,7 +874,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)