Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Stable Diffusion Webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
novelai-storage
Stable Diffusion Webui
Commits
9c674080
Commit
9c674080
authored
Nov 02, 2022
by
timntorres
Committed by
GitHub
Nov 02, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow saving "before-highres-fix. (#4150)
* Save image/s before doing highres fix.
parent
4a8cf01f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
5 deletions
+18
-5
modules/processing.py
modules/processing.py
+15
-2
modules/sd_samplers.py
modules/sd_samplers.py
+2
-3
modules/shared.py
modules/shared.py
+1
-0
No files found.
modules/processing.py
View file @
9c674080
...
...
@@ -521,7 +521,11 @@ def process_images_inner(p: StableDiffusionProcessing) -> Processed:
shared
.
state
.
job
=
f
"Batch {n+1} out of {p.n_iter}"
with
devices
.
autocast
():
samples_ddim
=
p
.
sample
(
conditioning
=
c
,
unconditional_conditioning
=
uc
,
seeds
=
seeds
,
subseeds
=
subseeds
,
subseed_strength
=
p
.
subseed_strength
)
# Only Txt2Img needs an extra argument, n, when saving intermediate images pre highres fix.
if
isinstance
(
p
,
StableDiffusionProcessingTxt2Img
):
samples_ddim
=
p
.
sample
(
conditioning
=
c
,
unconditional_conditioning
=
uc
,
seeds
=
seeds
,
subseeds
=
subseeds
,
subseed_strength
=
p
.
subseed_strength
,
n
=
n
)
else
:
samples_ddim
=
p
.
sample
(
conditioning
=
c
,
unconditional_conditioning
=
uc
,
seeds
=
seeds
,
subseeds
=
subseeds
,
subseed_strength
=
p
.
subseed_strength
)
samples_ddim
=
samples_ddim
.
to
(
devices
.
dtype_vae
)
x_samples_ddim
=
decode_first_stage
(
p
.
sd_model
,
samples_ddim
)
...
...
@@ -649,7 +653,7 @@ class StableDiffusionProcessingTxt2Img(StableDiffusionProcessing):
self
.
truncate_x
=
int
(
self
.
firstphase_width
-
firstphase_width_truncated
)
//
opt_f
self
.
truncate_y
=
int
(
self
.
firstphase_height
-
firstphase_height_truncated
)
//
opt_f
def
sample
(
self
,
conditioning
,
unconditional_conditioning
,
seeds
,
subseeds
,
subseed_strength
):
def
sample
(
self
,
conditioning
,
unconditional_conditioning
,
seeds
,
subseeds
,
subseed_strength
,
n
=
0
):
self
.
sampler
=
sd_samplers
.
create_sampler_with_index
(
sd_samplers
.
samplers
,
self
.
sampler_index
,
self
.
sd_model
)
if
not
self
.
enable_hr
:
...
...
@@ -685,6 +689,15 @@ class StableDiffusionProcessingTxt2Img(StableDiffusionProcessing):
samples
=
self
.
sd_model
.
get_first_stage_encoding
(
self
.
sd_model
.
encode_first_stage
(
decoded_samples
))
# Save a copy of the image/s before doing highres fix, if applicable.
if
opts
.
save
and
not
self
.
do_not_save_samples
and
opts
.
save_images_before_highres_fix
:
for
i
in
range
(
self
.
batch_size
):
# This batch's ith image.
img
=
sd_samplers
.
sample_to_image
(
samples
,
i
)
# Index that accounts for both batch size and batch count.
ind
=
i
+
self
.
batch_size
*
n
images
.
save_image
(
img
,
self
.
outpath_samples
,
""
,
self
.
all_seeds
[
ind
],
self
.
all_prompts
[
ind
],
opts
.
samples_format
,
suffix
=
f
"-before-highres-fix"
)
shared
.
state
.
nextjob
()
self
.
sampler
=
sd_samplers
.
create_sampler_with_index
(
sd_samplers
.
samplers
,
self
.
sampler_index
,
self
.
sd_model
)
...
...
modules/sd_samplers.py
View file @
9c674080
...
...
@@ -93,9 +93,8 @@ def single_sample_to_image(sample):
return
Image
.
fromarray
(
x_sample
)
def
sample_to_image
(
samples
):
return
single_sample_to_image
(
samples
[
0
])
def
sample_to_image
(
samples
,
index
=
0
):
return
single_sample_to_image
(
samples
[
index
])
def
samples_to_image_grid
(
samples
):
return
images
.
image_grid
([
single_sample_to_image
(
sample
)
for
sample
in
samples
])
...
...
modules/shared.py
View file @
9c674080
...
...
@@ -255,6 +255,7 @@ options_templates.update(options_section(('saving-images', "Saving images/grids"
"enable_pnginfo"
:
OptionInfo
(
True
,
"Save text information about generation parameters as chunks to png files"
),
"save_txt"
:
OptionInfo
(
False
,
"Create a text file next to every image with generation parameters."
),
"save_images_before_face_restoration"
:
OptionInfo
(
False
,
"Save a copy of image before doing face restoration."
),
"save_images_before_highres_fix"
:
OptionInfo
(
False
,
"Save a copy of image before applying highres fix."
),
"jpeg_quality"
:
OptionInfo
(
80
,
"Quality for saved jpeg images"
,
gr
.
Slider
,
{
"minimum"
:
1
,
"maximum"
:
100
,
"step"
:
1
}),
"export_for_4chan"
:
OptionInfo
(
True
,
"If PNG image is larger than 4MB or any dimension is larger than 4000, downscale and save copy as JPG"
),
...
...
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