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
ae36e089
Commit
ae36e089
authored
Jul 26, 2023
by
AUTOMATIC1111
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
alternative solution for infotext issue
parent
d0bf509f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
36 deletions
+32
-36
modules/processing.py
modules/processing.py
+27
-35
modules/scripts.py
modules/scripts.py
+5
-1
No files found.
modules/processing.py
View file @
ae36e089
...
...
@@ -600,8 +600,12 @@ def program_version():
return
res
def
create_infotext
(
p
,
all_prompts
,
all_seeds
,
all_subseeds
,
comments
=
None
,
iteration
=
0
,
position_in_batch
=
0
,
use_main_prompt
=
False
):
index
=
position_in_batch
+
iteration
*
p
.
batch_size
def
create_infotext
(
p
,
all_prompts
,
all_seeds
,
all_subseeds
,
comments
=
None
,
iteration
=
0
,
position_in_batch
=
0
,
use_main_prompt
=
False
,
index
=
None
,
all_negative_prompts
=
None
):
if
index
is
None
:
index
=
position_in_batch
+
iteration
*
p
.
batch_size
if
all_negative_prompts
is
None
:
all_negative_prompts
=
p
.
all_negative_prompts
clip_skip
=
getattr
(
p
,
'clip_skip'
,
opts
.
CLIP_stop_at_last_layers
)
enable_hr
=
getattr
(
p
,
'enable_hr'
,
False
)
...
...
@@ -642,7 +646,7 @@ def create_infotext(p, all_prompts, all_seeds, all_subseeds, comments=None, iter
generation_params_text
=
", "
.
join
([
k
if
k
==
v
else
f
'{k}: {generation_parameters_copypaste.quote(v)}'
for
k
,
v
in
generation_params
.
items
()
if
v
is
not
None
])
prompt_text
=
p
.
prompt
if
use_main_prompt
else
all_prompts
[
index
]
negative_prompt_text
=
f
"
\n
Negative prompt: {
p.all_negative_prompts[index]}"
if
p
.
all_negative_prompts
[
index
]
else
""
negative_prompt_text
=
f
"
\n
Negative prompt: {
all_negative_prompts[index]}"
if
all_negative_prompts
[
index
]
else
""
return
f
"{prompt_text}{negative_prompt_text}
\n
{generation_params_text}"
.
strip
()
...
...
@@ -716,29 +720,6 @@ def process_images_inner(p: StableDiffusionProcessing) -> Processed:
else
:
p
.
all_subseeds
=
[
int
(
subseed
)
+
x
for
x
in
range
(
len
(
p
.
all_prompts
))]
def
infotext
(
iteration
=
0
,
position_in_batch
=
0
,
use_main_prompt
=
False
):
all_prompts
=
p
.
all_prompts
[:]
all_negative_prompts
=
p
.
all_negative_prompts
[:]
all_seeds
=
p
.
all_seeds
[:]
all_subseeds
=
p
.
all_subseeds
[:]
# apply changes to generation data
all_prompts
[
iteration
*
p
.
batch_size
:(
iteration
+
1
)
*
p
.
batch_size
]
=
p
.
prompts
all_negative_prompts
[
iteration
*
p
.
batch_size
:(
iteration
+
1
)
*
p
.
batch_size
]
=
p
.
negative_prompts
all_seeds
[
iteration
*
p
.
batch_size
:(
iteration
+
1
)
*
p
.
batch_size
]
=
p
.
seeds
all_subseeds
[
iteration
*
p
.
batch_size
:(
iteration
+
1
)
*
p
.
batch_size
]
=
p
.
subseeds
# update p.all_negative_prompts in case extensions changed the size of the batch
# create_infotext below uses it
old_negative_prompts
=
p
.
all_negative_prompts
p
.
all_negative_prompts
=
all_negative_prompts
try
:
return
create_infotext
(
p
,
all_prompts
,
all_seeds
,
all_subseeds
,
comments
,
iteration
,
position_in_batch
,
use_main_prompt
)
finally
:
# restore p.all_negative_prompts in case extensions changed the size of the batch
p
.
all_negative_prompts
=
old_negative_prompts
if
os
.
path
.
exists
(
cmd_opts
.
embeddings_dir
)
and
not
p
.
do_not_reload_embeddings
:
model_hijack
.
embedding_db
.
load_textual_inversion_embeddings
()
...
...
@@ -826,9 +807,20 @@ def process_images_inner(p: StableDiffusionProcessing) -> Processed:
if
p
.
scripts
is
not
None
:
p
.
scripts
.
postprocess_batch
(
p
,
x_samples_ddim
,
batch_number
=
n
)
postprocess_batch_list_args
=
scripts
.
PostprocessBatchListArgs
(
list
(
x_samples_ddim
))
p
.
scripts
.
postprocess_batch_list
(
p
,
postprocess_batch_list_args
,
batch_number
=
n
)
x_samples_ddim
=
postprocess_batch_list_args
.
images
batch_params
=
scripts
.
PostprocessBatchListArgs
(
list
(
x_samples_ddim
),
p
.
all_prompts
[
n
*
p
.
batch_size
:(
n
+
1
)
*
p
.
batch_size
],
p
.
all_negative_prompts
[
n
*
p
.
batch_size
:(
n
+
1
)
*
p
.
batch_size
],
p
.
seeds
,
p
.
subseeds
,
)
if
p
.
scripts
is
not
None
:
p
.
scripts
.
postprocess_batch_list
(
p
,
batch_params
,
batch_number
=
n
)
x_samples_ddim
=
batch_params
.
images
def
infotext
(
index
=
0
,
use_main_prompt
=
False
):
return
create_infotext
(
p
,
batch_params
.
prompts
,
batch_params
.
seeds
,
batch_params
.
subseeds
,
use_main_prompt
=
use_main_prompt
,
index
=
index
,
all_negative_prompts
=
batch_params
.
negative_prompts
)
for
i
,
x_sample
in
enumerate
(
x_samples_ddim
):
p
.
batch_index
=
i
...
...
@@ -838,7 +830,7 @@ def process_images_inner(p: StableDiffusionProcessing) -> Processed:
if
p
.
restore_faces
:
if
opts
.
save
and
not
p
.
do_not_save_samples
and
opts
.
save_images_before_face_restoration
:
images
.
save_image
(
Image
.
fromarray
(
x_sample
),
p
.
outpath_samples
,
""
,
p
.
seeds
[
i
],
p
.
prompts
[
i
],
opts
.
samples_format
,
info
=
infotext
(
n
,
i
),
p
=
p
,
suffix
=
"-before-face-restoration"
)
images
.
save_image
(
Image
.
fromarray
(
x_sample
),
p
.
outpath_samples
,
""
,
p
.
seeds
[
i
],
p
.
prompts
[
i
],
opts
.
samples_format
,
info
=
infotext
(
i
),
p
=
p
,
suffix
=
"-before-face-restoration"
)
devices
.
torch_gc
()
...
...
@@ -855,15 +847,15 @@ def process_images_inner(p: StableDiffusionProcessing) -> Processed:
if
p
.
color_corrections
is
not
None
and
i
<
len
(
p
.
color_corrections
):
if
opts
.
save
and
not
p
.
do_not_save_samples
and
opts
.
save_images_before_color_correction
:
image_without_cc
=
apply_overlay
(
image
,
p
.
paste_to
,
i
,
p
.
overlay_images
)
images
.
save_image
(
image_without_cc
,
p
.
outpath_samples
,
""
,
p
.
seeds
[
i
],
p
.
prompts
[
i
],
opts
.
samples_format
,
info
=
infotext
(
n
,
i
),
p
=
p
,
suffix
=
"-before-color-correction"
)
images
.
save_image
(
image_without_cc
,
p
.
outpath_samples
,
""
,
p
.
seeds
[
i
],
p
.
prompts
[
i
],
opts
.
samples_format
,
info
=
infotext
(
i
),
p
=
p
,
suffix
=
"-before-color-correction"
)
image
=
apply_color_correction
(
p
.
color_corrections
[
i
],
image
)
image
=
apply_overlay
(
image
,
p
.
paste_to
,
i
,
p
.
overlay_images
)
if
opts
.
samples_save
and
not
p
.
do_not_save_samples
:
images
.
save_image
(
image
,
p
.
outpath_samples
,
""
,
p
.
seeds
[
i
],
p
.
prompts
[
i
],
opts
.
samples_format
,
info
=
infotext
(
n
,
i
),
p
=
p
)
images
.
save_image
(
image
,
p
.
outpath_samples
,
""
,
p
.
seeds
[
i
],
p
.
prompts
[
i
],
opts
.
samples_format
,
info
=
infotext
(
i
),
p
=
p
)
text
=
infotext
(
n
,
i
)
text
=
infotext
(
i
)
infotexts
.
append
(
text
)
if
opts
.
enable_pnginfo
:
image
.
info
[
"parameters"
]
=
text
...
...
@@ -874,10 +866,10 @@ def process_images_inner(p: StableDiffusionProcessing) -> Processed:
image_mask_composite
=
Image
.
composite
(
image
.
convert
(
'RGBA'
)
.
convert
(
'RGBa'
),
Image
.
new
(
'RGBa'
,
image
.
size
),
images
.
resize_image
(
2
,
p
.
mask_for_overlay
,
image
.
width
,
image
.
height
)
.
convert
(
'L'
))
.
convert
(
'RGBA'
)
if
opts
.
save_mask
:
images
.
save_image
(
image_mask
,
p
.
outpath_samples
,
""
,
p
.
seeds
[
i
],
p
.
prompts
[
i
],
opts
.
samples_format
,
info
=
infotext
(
n
,
i
),
p
=
p
,
suffix
=
"-mask"
)
images
.
save_image
(
image_mask
,
p
.
outpath_samples
,
""
,
p
.
seeds
[
i
],
p
.
prompts
[
i
],
opts
.
samples_format
,
info
=
infotext
(
i
),
p
=
p
,
suffix
=
"-mask"
)
if
opts
.
save_mask_composite
:
images
.
save_image
(
image_mask_composite
,
p
.
outpath_samples
,
""
,
p
.
seeds
[
i
],
p
.
prompts
[
i
],
opts
.
samples_format
,
info
=
infotext
(
n
,
i
),
p
=
p
,
suffix
=
"-mask-composite"
)
images
.
save_image
(
image_mask_composite
,
p
.
outpath_samples
,
""
,
p
.
seeds
[
i
],
p
.
prompts
[
i
],
opts
.
samples_format
,
info
=
infotext
(
i
),
p
=
p
,
suffix
=
"-mask-composite"
)
if
opts
.
return_mask
:
output_images
.
append
(
image_mask
)
...
...
modules/scripts.py
View file @
ae36e089
...
...
@@ -17,8 +17,12 @@ class PostprocessImageArgs:
class
PostprocessBatchListArgs
:
def
__init__
(
self
,
images
):
def
__init__
(
self
,
images
,
prompts
,
negative_prompts
,
seeds
,
subseeds
):
self
.
images
=
images
self
.
prompts
=
prompts
self
.
negative_prompts
=
negative_prompts
self
.
seeds
=
seeds
self
.
subseeds
=
subseeds
class
Script
:
...
...
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