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
7581da5d
Commit
7581da5d
authored
Jan 20, 2024
by
AUTOMATIC1111
Committed by
GitHub
Jan 20, 2024
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14645 from AUTOMATIC1111/infotexts
geninfo from Infotexts
parents
41c2121e
45a51c07
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
22 deletions
+16
-22
modules/processing_scripts/seed.py
modules/processing_scripts/seed.py
+6
-13
modules/ui_common.py
modules/ui_common.py
+10
-9
No files found.
modules/processing_scripts/seed.py
View file @
7581da5d
...
...
@@ -6,6 +6,7 @@ from modules import scripts, ui, errors
from
modules.infotext_utils
import
PasteField
from
modules.shared
import
cmd_opts
from
modules.ui_components
import
ToolButton
from
modules
import
infotext_utils
class
ScriptSeed
(
scripts
.
ScriptBuiltinUI
):
...
...
@@ -77,7 +78,6 @@ class ScriptSeed(scripts.ScriptBuiltinUI):
p
.
seed_resize_from_h
=
seed_resize_from_h
def
connect_reuse_seed
(
seed
:
gr
.
Number
,
reuse_seed
:
gr
.
Button
,
generation_info
:
gr
.
Textbox
,
is_subseed
):
""" Connects a 'reuse (sub)seed' button's click event so that it copies last used
(sub)seed value from generation info the to the seed field. If copying subseed and subseed strength
...
...
@@ -85,21 +85,14 @@ def connect_reuse_seed(seed: gr.Number, reuse_seed: gr.Button, generation_info:
def
copy_seed
(
gen_info_string
:
str
,
index
):
res
=
-
1
try
:
gen_info
=
json
.
loads
(
gen_info_string
)
index
-=
gen_info
.
get
(
'index_of_first_image'
,
0
)
if
is_subseed
and
gen_info
.
get
(
'subseed_strength'
,
0
)
>
0
:
all_subseeds
=
gen_info
.
get
(
'all_subseeds'
,
[
-
1
])
res
=
all_subseeds
[
index
if
0
<=
index
<
len
(
all_subseeds
)
else
0
]
else
:
all_seeds
=
gen_info
.
get
(
'all_seeds'
,
[
-
1
])
res
=
all_seeds
[
index
if
0
<=
index
<
len
(
all_seeds
)
else
0
]
except
json
.
decoder
.
JSONDecodeError
:
infotext
=
gen_info
.
get
(
'infotexts'
)[
index
]
gen_parameters
=
infotext_utils
.
parse_generation_parameters
(
infotext
,
[])
res
=
int
(
gen_parameters
.
get
(
'Variation seed'
if
is_subseed
else
'Seed'
,
-
1
))
except
Exception
:
if
gen_info_string
:
errors
.
report
(
f
"Error
parsing JSON generation info: {gen_info_string}"
)
errors
.
report
(
f
"Error
retrieving seed from generation info: {gen_info_string}"
,
exc_info
=
True
)
return
[
res
,
gr
.
update
()]
...
...
modules/ui_common.py
View file @
7581da5d
...
...
@@ -40,8 +40,9 @@ def save_files(js_data, images, do_make_zip, index):
import
csv
filenames
=
[]
fullfns
=
[]
parsed_infotexts
=
[]
#quick dictionary to class object conversion. Its necessary due apply_filename_pattern requiring it
#
quick dictionary to class object conversion. Its necessary due apply_filename_pattern requiring it
class
MyObject
:
def
__init__
(
self
,
d
=
None
):
if
d
is
not
None
:
...
...
@@ -49,16 +50,14 @@ def save_files(js_data, images, do_make_zip, index):
setattr
(
self
,
key
,
value
)
data
=
json
.
loads
(
js_data
)
p
=
MyObject
(
data
)
path
=
shared
.
opts
.
outdir_save
save_to_dirs
=
shared
.
opts
.
use_save_to_dirs_for_ui
extension
:
str
=
shared
.
opts
.
samples_format
start_index
=
0
only_one
=
False
if
index
>
-
1
and
shared
.
opts
.
save_selected_only
and
(
index
>=
data
[
"index_of_first_image"
]):
# ensures we are looking at a specific non-grid picture, and we have save_selected_only
only_one
=
True
images
=
[
images
[
index
]]
start_index
=
index
...
...
@@ -74,10 +73,12 @@ def save_files(js_data, images, do_make_zip, index):
image
=
image_from_url_text
(
filedata
)
is_grid
=
image_index
<
p
.
index_of_first_image
i
=
0
if
is_grid
else
(
image_index
-
p
.
index_of_first_image
)
p
.
batch_index
=
image_index
-
1
fullfn
,
txt_fullfn
=
modules
.
images
.
save_image
(
image
,
path
,
""
,
seed
=
p
.
all_seeds
[
i
],
prompt
=
p
.
all_prompts
[
i
],
extension
=
extension
,
info
=
p
.
infotexts
[
image_index
],
grid
=
is_grid
,
p
=
p
,
save_to_dirs
=
save_to_dirs
)
parameters
=
parameters_copypaste
.
parse_generation_parameters
(
data
[
"infotexts"
][
image_index
],
[])
parsed_infotexts
.
append
(
parameters
)
fullfn
,
txt_fullfn
=
modules
.
images
.
save_image
(
image
,
path
,
""
,
seed
=
parameters
[
'Seed'
],
prompt
=
parameters
[
'Prompt'
],
extension
=
extension
,
info
=
p
.
infotexts
[
image_index
],
grid
=
is_grid
,
p
=
p
,
save_to_dirs
=
save_to_dirs
)
filename
=
os
.
path
.
relpath
(
fullfn
,
path
)
filenames
.
append
(
filename
)
...
...
@@ -86,12 +87,12 @@ def save_files(js_data, images, do_make_zip, index):
filenames
.
append
(
os
.
path
.
basename
(
txt_fullfn
))
fullfns
.
append
(
txt_fullfn
)
writer
.
writerow
([
data
[
"prompt"
],
data
[
"seed"
],
data
[
"width"
],
data
[
"height"
],
data
[
"sampler_name"
],
data
[
"cfg_scale"
],
data
[
"steps"
],
filenames
[
0
],
data
[
"negative_prompt"
]])
writer
.
writerow
([
parsed_infotexts
[
0
][
'Prompt'
],
parsed_infotexts
[
0
][
'Seed'
],
data
[
"width"
],
data
[
"height"
],
data
[
"sampler_name"
],
data
[
"cfg_scale"
],
data
[
"steps"
],
filenames
[
0
],
parsed_infotexts
[
0
][
'Negative prompt'
]])
# Make Zip
if
do_make_zip
:
zip_fileseed
=
p
.
all_seeds
[
index
-
1
]
if
only_one
else
p
.
all_seeds
[
0
]
namegen
=
modules
.
images
.
FilenameGenerator
(
p
,
zip_fileseed
,
p
.
all_prompts
[
0
],
image
,
True
)
p
.
all_seeds
=
[
parameters
[
'Seed'
]
for
parameters
in
parsed_infotexts
]
namegen
=
modules
.
images
.
FilenameGenerator
(
p
,
parsed_infotexts
[
0
][
'Seed'
],
parsed_infotexts
[
0
][
'Prompt'
],
image
,
True
)
zip_filename
=
namegen
.
apply
(
shared
.
opts
.
grid_zip_filename_pattern
or
"[datetime]_[[model_name]]_[seed]-[seed_last]"
)
zip_filepath
=
os
.
path
.
join
(
path
,
f
"{zip_filename}.zip"
)
...
...
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