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
6603f63b
Commit
6603f63b
authored
Nov 06, 2022
by
Han Lin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes LDSR upscaler producing black bars
parent
2f47724b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
+11
-3
ldsr_model_arch.py
modules/ldsr_model_arch.py
+11
-3
No files found.
modules/ldsr_model_arch.py
View file @
6603f63b
...
@@ -101,8 +101,8 @@ class LDSR:
...
@@ -101,8 +101,8 @@ class LDSR:
down_sample_rate
=
target_scale
/
4
down_sample_rate
=
target_scale
/
4
wd
=
width_og
*
down_sample_rate
wd
=
width_og
*
down_sample_rate
hd
=
height_og
*
down_sample_rate
hd
=
height_og
*
down_sample_rate
width_downsampled_pre
=
int
(
wd
)
width_downsampled_pre
=
int
(
np
.
ceil
(
wd
)
)
height_downsampled_pre
=
int
(
hd
)
height_downsampled_pre
=
int
(
np
.
ceil
(
hd
)
)
if
down_sample_rate
!=
1
:
if
down_sample_rate
!=
1
:
print
(
print
(
...
@@ -110,7 +110,12 @@ class LDSR:
...
@@ -110,7 +110,12 @@ class LDSR:
im_og
=
im_og
.
resize
((
width_downsampled_pre
,
height_downsampled_pre
),
Image
.
LANCZOS
)
im_og
=
im_og
.
resize
((
width_downsampled_pre
,
height_downsampled_pre
),
Image
.
LANCZOS
)
else
:
else
:
print
(
f
"Down sample rate is 1 from {target_scale} / 4 (Not downsampling)"
)
print
(
f
"Down sample rate is 1 from {target_scale} / 4 (Not downsampling)"
)
logs
=
self
.
run
(
model
[
"model"
],
im_og
,
diffusion_steps
,
eta
)
# pad width and height to multiples of 64, pads with the edge values of image to avoid artifacts
pad_w
,
pad_h
=
np
.
max
(((
2
,
2
),
np
.
ceil
(
np
.
array
(
im_og
.
size
)
/
64
)
.
astype
(
int
)),
axis
=
0
)
*
64
-
im_og
.
size
im_padded
=
Image
.
fromarray
(
np
.
pad
(
np
.
array
(
im_og
),
((
0
,
pad_h
),
(
0
,
pad_w
),
(
0
,
0
)),
mode
=
'edge'
))
logs
=
self
.
run
(
model
[
"model"
],
im_padded
,
diffusion_steps
,
eta
)
sample
=
logs
[
"sample"
]
sample
=
logs
[
"sample"
]
sample
=
sample
.
detach
()
.
cpu
()
sample
=
sample
.
detach
()
.
cpu
()
...
@@ -120,6 +125,9 @@ class LDSR:
...
@@ -120,6 +125,9 @@ class LDSR:
sample
=
np
.
transpose
(
sample
,
(
0
,
2
,
3
,
1
))
sample
=
np
.
transpose
(
sample
,
(
0
,
2
,
3
,
1
))
a
=
Image
.
fromarray
(
sample
[
0
])
a
=
Image
.
fromarray
(
sample
[
0
])
# remove padding
a
=
a
.
crop
((
0
,
0
)
+
tuple
(
np
.
array
(
im_og
.
size
)
*
4
))
del
model
del
model
gc
.
collect
()
gc
.
collect
()
torch
.
cuda
.
empty_cache
()
torch
.
cuda
.
empty_cache
()
...
...
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