diff options
author | timntorres <timothynarcisotorres@gmail.com> | 2022-10-25 08:39:59 +0000 |
---|---|---|
committer | AUTOMATIC1111 <16777216c@gmail.com> | 2022-10-26 07:10:57 +0000 |
commit | cb49800c08a9f6619733250401952e5571dc12f8 (patch) | |
tree | d6974d4e39dbbf7c274b618042f9d76479a0421e /modules/img2img.py | |
parent | 9d82c351ac36d1511f5f65b24443c60250ee3e9e (diff) | |
download | stable-diffusion-webui-gfx803-cb49800c08a9f6619733250401952e5571dc12f8.tar.gz stable-diffusion-webui-gfx803-cb49800c08a9f6619733250401952e5571dc12f8.tar.bz2 stable-diffusion-webui-gfx803-cb49800c08a9f6619733250401952e5571dc12f8.zip |
img2img, use smartphone photos' EXIF orientation
Diffstat (limited to 'modules/img2img.py')
-rw-r--r-- | modules/img2img.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/modules/img2img.py b/modules/img2img.py index 8d9f7cf9..9c0cf23e 100644 --- a/modules/img2img.py +++ b/modules/img2img.py @@ -39,6 +39,8 @@ def process_batch(p, input_dir, output_dir, args): break
img = Image.open(image)
+ # Use the EXIF orientation of photos taken by smartphones.
+ img = ImageOps.exif_transpose(img)
p.init_images = [img] * p.batch_size
proc = modules.scripts.scripts_img2img.run(p, *args)
@@ -61,19 +63,25 @@ def img2img(mode: int, prompt: str, negative_prompt: str, prompt_style: str, pro is_batch = mode == 2
if is_inpaint:
+ # Drawn mask
if mask_mode == 0:
image = init_img_with_mask['image']
mask = init_img_with_mask['mask']
alpha_mask = ImageOps.invert(image.split()[-1]).convert('L').point(lambda x: 255 if x > 0 else 0, mode='1')
mask = ImageChops.lighter(alpha_mask, mask.convert('L')).convert('L')
image = image.convert('RGB')
+ # Uploaded mask
else:
image = init_img_inpaint
mask = init_mask_inpaint
+ # No mask
else:
image = init_img
mask = None
+ # Use the EXIF orientation of photos taken by smartphones.
+ image = ImageOps.exif_transpose(image)
+
assert 0. <= denoising_strength <= 1., 'can only work with strength in [0.0, 1.0]'
p = StableDiffusionProcessingImg2Img(
|