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
06186582
Commit
06186582
authored
Sep 21, 2022
by
AUTOMATIC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prevent outpainting mk2 from breaking on different image resolutions.
parent
1ebb5cc6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
7 deletions
+14
-7
outpainting_mk_2.py
scripts/outpainting_mk_2.py
+14
-7
No files found.
scripts/outpainting_mk_2.py
View file @
06186582
...
@@ -197,6 +197,7 @@ class Script(scripts.Script):
...
@@ -197,6 +197,7 @@ class Script(scripts.Script):
if
left
>
0
:
if
left
>
0
:
left
=
left
*
(
target_w
-
init_img
.
width
)
//
(
left
+
right
)
left
=
left
*
(
target_w
-
init_img
.
width
)
//
(
left
+
right
)
if
right
>
0
:
if
right
>
0
:
right
=
target_w
-
init_img
.
width
-
left
right
=
target_w
-
init_img
.
width
-
left
...
@@ -208,7 +209,7 @@ class Script(scripts.Script):
...
@@ -208,7 +209,7 @@ class Script(scripts.Script):
init_image
=
p
.
init_images
[
0
]
init_image
=
p
.
init_images
[
0
]
state
.
job_count
=
(
1
if
left
>
0
else
0
)
+
(
1
if
right
>
0
else
0
)
+
(
1
if
up
>
0
else
0
)
+
(
1
if
down
>
0
else
0
)
state
.
job_count
=
(
1
if
left
>
0
else
0
)
+
(
1
if
right
>
0
else
0
)
+
(
1
if
up
>
0
else
0
)
+
(
1
if
down
>
0
else
0
)
def
expand
(
init
,
expand_pixels
,
is_left
=
False
,
is_right
=
False
,
is_top
=
False
,
is_bottom
=
False
):
def
expand
(
init
,
expand_pixels
,
is_left
=
False
,
is_right
=
False
,
is_top
=
False
,
is_bottom
=
False
):
is_horiz
=
is_left
or
is_right
is_horiz
=
is_left
or
is_right
...
@@ -216,15 +217,20 @@ class Script(scripts.Script):
...
@@ -216,15 +217,20 @@ class Script(scripts.Script):
pixels_horiz
=
expand_pixels
if
is_horiz
else
0
pixels_horiz
=
expand_pixels
if
is_horiz
else
0
pixels_vert
=
expand_pixels
if
is_vert
else
0
pixels_vert
=
expand_pixels
if
is_vert
else
0
img
=
Image
.
new
(
"RGB"
,
(
init
.
width
+
pixels_horiz
,
init
.
height
+
pixels_vert
))
res_w
=
init
.
width
+
pixels_horiz
res_h
=
init
.
height
+
pixels_vert
process_res_w
=
math
.
ceil
(
res_w
/
64
)
*
64
process_res_h
=
math
.
ceil
(
res_h
/
64
)
*
64
img
=
Image
.
new
(
"RGB"
,
(
process_res_w
,
process_res_h
))
img
.
paste
(
init
,
(
pixels_horiz
if
is_left
else
0
,
pixels_vert
if
is_top
else
0
))
img
.
paste
(
init
,
(
pixels_horiz
if
is_left
else
0
,
pixels_vert
if
is_top
else
0
))
mask
=
Image
.
new
(
"RGB"
,
(
init
.
width
+
pixels_horiz
,
init
.
height
+
pixels_vert
),
"white"
)
mask
=
Image
.
new
(
"RGB"
,
(
process_res_w
,
process_res_h
),
"white"
)
draw
=
ImageDraw
.
Draw
(
mask
)
draw
=
ImageDraw
.
Draw
(
mask
)
draw
.
rectangle
((
draw
.
rectangle
((
expand_pixels
+
mask_blur
if
is_left
else
0
,
expand_pixels
+
mask_blur
if
is_left
else
0
,
expand_pixels
+
mask_blur
if
is_top
else
0
,
expand_pixels
+
mask_blur
if
is_top
else
0
,
mask
.
width
-
expand_pixels
-
mask_blur
if
is_right
else
mask
.
width
,
mask
.
width
-
expand_pixels
-
mask_blur
if
is_right
else
res_w
,
mask
.
height
-
expand_pixels
-
mask_blur
if
is_bottom
else
mask
.
height
,
mask
.
height
-
expand_pixels
-
mask_blur
if
is_bottom
else
res_h
,
),
fill
=
"black"
)
),
fill
=
"black"
)
np_image
=
(
np
.
asarray
(
img
)
/
255.0
)
.
astype
(
np
.
float64
)
np_image
=
(
np
.
asarray
(
img
)
/
255.0
)
.
astype
(
np
.
float64
)
...
@@ -255,8 +261,8 @@ class Script(scripts.Script):
...
@@ -255,8 +261,8 @@ class Script(scripts.Script):
draw
.
rectangle
((
draw
.
rectangle
((
expand_pixels
+
mask_blur
*
2
if
is_left
else
0
,
expand_pixels
+
mask_blur
*
2
if
is_left
else
0
,
expand_pixels
+
mask_blur
*
2
if
is_top
else
0
,
expand_pixels
+
mask_blur
*
2
if
is_top
else
0
,
mask
.
width
-
expand_pixels
-
mask_blur
*
2
if
is_right
else
mask
.
width
,
mask
.
width
-
expand_pixels
-
mask_blur
*
2
if
is_right
else
res_w
,
mask
.
height
-
expand_pixels
-
mask_blur
*
2
if
is_bottom
else
mask
.
height
,
mask
.
height
-
expand_pixels
-
mask_blur
*
2
if
is_bottom
else
res_h
,
),
fill
=
"black"
)
),
fill
=
"black"
)
p
.
latent_mask
=
latent_mask
p
.
latent_mask
=
latent_mask
...
@@ -268,6 +274,7 @@ class Script(scripts.Script):
...
@@ -268,6 +274,7 @@ class Script(scripts.Script):
initial_seed_and_info
[
1
]
=
proc
.
info
initial_seed_and_info
[
1
]
=
proc
.
info
out
.
paste
(
proc_img
,
(
0
if
is_left
else
out
.
width
-
proc_img
.
width
,
0
if
is_top
else
out
.
height
-
proc_img
.
height
))
out
.
paste
(
proc_img
,
(
0
if
is_left
else
out
.
width
-
proc_img
.
width
,
0
if
is_top
else
out
.
height
-
proc_img
.
height
))
out
=
out
.
crop
((
0
,
0
,
res_w
,
res_h
))
return
out
return
out
img
=
init_image
img
=
init_image
...
...
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