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
9d5948e5
Commit
9d5948e5
authored
Dec 13, 2022
by
space-nuko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correctly restore hypernetwork from hash
parent
70774282
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
+30
-0
generation_parameters_copypaste.py
modules/generation_parameters_copypaste.py
+30
-0
No files found.
modules/generation_parameters_copypaste.py
View file @
9d5948e5
...
@@ -14,6 +14,7 @@ re_param_code = r'\s*([\w ]+):\s*("(?:\\|\"|[^\"])+"|[^,]*)(?:,|$)'
...
@@ -14,6 +14,7 @@ re_param_code = r'\s*([\w ]+):\s*("(?:\\|\"|[^\"])+"|[^,]*)(?:,|$)'
re_param
=
re
.
compile
(
re_param_code
)
re_param
=
re
.
compile
(
re_param_code
)
re_params
=
re
.
compile
(
r"^(?:"
+
re_param_code
+
"){3,}$"
)
re_params
=
re
.
compile
(
r"^(?:"
+
re_param_code
+
"){3,}$"
)
re_imagesize
=
re
.
compile
(
r"^(\d+)x(\d+)$"
)
re_imagesize
=
re
.
compile
(
r"^(\d+)x(\d+)$"
)
re_hypernet_hash
=
re
.
compile
(
"
\
(([0-9a-f]+)
\
)$"
)
type_of_gr_update
=
type
(
gr
.
update
())
type_of_gr_update
=
type
(
gr
.
update
())
paste_fields
=
{}
paste_fields
=
{}
bind_list
=
[]
bind_list
=
[]
...
@@ -139,6 +140,30 @@ def run_bind():
...
@@ -139,6 +140,30 @@ def run_bind():
)
)
def
find_hypernetwork_key
(
hypernet_name
,
hypernet_hash
=
None
):
"""Determines the config parameter name to use for the hypernet based on the parameters in the infotext.
Example: an infotext provides "Hypernet: ke-ta" and "Hypernet hash: 1234abcd". For the "Hypernet" config
parameter this means there should be an entry that looks like "ke-ta-10000(1234abcd)" to set it to.
If the infotext has no hash, then a hypernet with the same name and the most steps will be selected instead.
"""
hypernet_name
=
hypernet_name
.
lower
()
if
hypernet_hash
is
not
None
:
# Try to match the hash in the name
for
hypernet_key
in
shared
.
hypernetworks
.
keys
():
result
=
re_hypernet_hash
.
search
(
hypernet_key
)
if
result
is
not
None
and
result
[
1
]
==
hypernet_hash
:
return
hypernet_key
else
:
# Fall back to a hypernet with the same name
for
hypernet_key
in
shared
.
hypernetworks
.
keys
():
if
hypernet_key
.
lower
()
.
startswith
(
hypernet_name
):
return
hypernet_key
return
None
def
parse_generation_parameters
(
x
:
str
):
def
parse_generation_parameters
(
x
:
str
):
"""parses generation parameters string, the one you see in text field under the picture in UI:
"""parses generation parameters string, the one you see in text field under the picture in UI:
```
```
...
@@ -188,6 +213,11 @@ Steps: 20, Sampler: Euler a, CFG scale: 7, Seed: 965400086, Size: 512x512, Model
...
@@ -188,6 +213,11 @@ Steps: 20, Sampler: Euler a, CFG scale: 7, Seed: 965400086, Size: 512x512, Model
if
"Clip skip"
not
in
res
:
if
"Clip skip"
not
in
res
:
res
[
"Clip skip"
]
=
"1"
res
[
"Clip skip"
]
=
"1"
if
"Hypernet"
in
res
:
hypernet_name
=
res
[
"Hypernet"
]
hypernet_hash
=
res
.
get
(
"Hypernet hash"
,
None
)
res
[
"Hypernet"
]
=
find_hypernetwork_key
(
hypernet_name
,
hypernet_hash
)
return
res
return
res
...
...
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