Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
S
stable-diffusion-webui
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
stable-diffusion-webui
Commits
cb49800c
Commit
cb49800c
authored
Oct 25, 2022
by
timntorres
Committed by
AUTOMATIC1111
Oct 26, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
img2img, use smartphone photos' EXIF orientation
parent
9d82c351
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
0 deletions
+8
-0
img2img.py
modules/img2img.py
+8
-0
No files found.
modules/img2img.py
View file @
cb49800c
...
@@ -39,6 +39,8 @@ def process_batch(p, input_dir, output_dir, args):
...
@@ -39,6 +39,8 @@ def process_batch(p, input_dir, output_dir, args):
break
break
img
=
Image
.
open
(
image
)
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
p
.
init_images
=
[
img
]
*
p
.
batch_size
proc
=
modules
.
scripts
.
scripts_img2img
.
run
(
p
,
*
args
)
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
...
@@ -61,19 +63,25 @@ def img2img(mode: int, prompt: str, negative_prompt: str, prompt_style: str, pro
is_batch
=
mode
==
2
is_batch
=
mode
==
2
if
is_inpaint
:
if
is_inpaint
:
# Drawn mask
if
mask_mode
==
0
:
if
mask_mode
==
0
:
image
=
init_img_with_mask
[
'image'
]
image
=
init_img_with_mask
[
'image'
]
mask
=
init_img_with_mask
[
'mask'
]
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'
)
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'
)
mask
=
ImageChops
.
lighter
(
alpha_mask
,
mask
.
convert
(
'L'
))
.
convert
(
'L'
)
image
=
image
.
convert
(
'RGB'
)
image
=
image
.
convert
(
'RGB'
)
# Uploaded mask
else
:
else
:
image
=
init_img_inpaint
image
=
init_img_inpaint
mask
=
init_mask_inpaint
mask
=
init_mask_inpaint
# No mask
else
:
else
:
image
=
init_img
image
=
init_img
mask
=
None
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]'
assert
0.
<=
denoising_strength
<=
1.
,
'can only work with strength in [0.0, 1.0]'
p
=
StableDiffusionProcessingImg2Img
(
p
=
StableDiffusionProcessingImg2Img
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment