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
c8c73eae
Commit
c8c73eae
authored
Aug 24, 2023
by
AUTOMATIC1111
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix incorrect save/display of new values in Defaults page in settings
parent
935d9d89
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
4 deletions
+13
-4
modules/ui_loadsave.py
modules/ui_loadsave.py
+13
-4
No files found.
modules/ui_loadsave.py
View file @
c8c73eae
...
...
@@ -7,6 +7,10 @@ from modules import errors
from
modules.ui_components
import
ToolButton
def
radio_choices
(
comp
):
# gradio 3.41 changes choices from list of values to list of pairs
return
[
x
[
0
]
if
isinstance
(
x
,
tuple
)
else
x
for
x
in
getattr
(
comp
,
'choices'
,
[])]
class
UiLoadsave
:
"""allows saving and restoring default values for gradio components"""
...
...
@@ -28,6 +32,8 @@ class UiLoadsave:
self
.
error_loading
=
True
errors
.
display
(
e
,
"loading settings"
)
def
add_component
(
self
,
path
,
x
):
"""adds component to the registry of tracked components"""
...
...
@@ -73,7 +79,7 @@ class UiLoadsave:
apply_field
(
x
,
'step'
)
if
type
(
x
)
==
gr
.
Radio
:
apply_field
(
x
,
'value'
,
lambda
val
:
val
in
x
.
choices
)
apply_field
(
x
,
'value'
,
lambda
val
:
val
in
radio_choices
(
x
)
)
if
type
(
x
)
==
gr
.
Checkbox
:
apply_field
(
x
,
'value'
)
...
...
@@ -86,10 +92,11 @@ class UiLoadsave:
if
type
(
x
)
==
gr
.
Dropdown
:
def
check_dropdown
(
val
):
choices
=
radio_choices
(
x
)
if
getattr
(
x
,
'multiselect'
,
False
):
return
all
(
value
in
x
.
choices
for
value
in
val
)
return
all
(
value
in
choices
for
value
in
val
)
else
:
return
val
in
x
.
choices
return
val
in
choices
apply_field
(
x
,
'value'
,
check_dropdown
,
getattr
(
x
,
'init_field'
,
None
))
...
...
@@ -146,12 +153,14 @@ class UiLoadsave:
for
(
path
,
component
),
new_value
in
zip
(
self
.
component_mapping
.
items
(),
values
):
old_value
=
current_ui_settings
.
get
(
path
)
choices
=
getattr
(
component
,
'choices'
,
None
)
choices
=
radio_choices
(
component
)
if
isinstance
(
new_value
,
int
)
and
choices
:
if
new_value
>=
len
(
choices
):
continue
new_value
=
choices
[
new_value
]
if
isinstance
(
new_value
,
tuple
):
new_value
=
new_value
[
0
]
if
new_value
==
old_value
:
continue
...
...
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