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
6fa20d51
Commit
6fa20d51
authored
Sep 23, 2022
by
AUTOMATIC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prevent saving settings with bogus values
parent
79e7c392
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
20 deletions
+22
-20
modules/shared.py
modules/shared.py
+11
-12
modules/txt2img.py
modules/txt2img.py
+1
-3
modules/ui.py
modules/ui.py
+10
-5
No files found.
modules/shared.py
View file @
6fa20d51
...
...
@@ -219,6 +219,7 @@ options_templates.update(options_section(('ui', "User interface"), {
class
Options
:
data
=
None
data_labels
=
options_templates
typemap
=
{
int
:
float
}
def
__init__
(
self
):
self
.
data
=
{
k
:
v
.
default
for
k
,
v
in
self
.
data_labels
.
items
()}
...
...
@@ -244,25 +245,23 @@ class Options:
with
open
(
filename
,
"w"
,
encoding
=
"utf8"
)
as
file
:
json
.
dump
(
self
.
data
,
file
)
def
load
(
self
,
filename
):
with
open
(
filename
,
"r"
,
encoding
=
"utf8"
)
as
file
:
self
.
data
=
json
.
load
(
file
)
typemap
=
{
int
:
float
}
def
same_type
(
x
,
y
):
def
same_type
(
self
,
x
,
y
):
if
x
is
None
or
y
is
None
:
return
True
type_x
=
typemap
.
get
(
type
(
x
),
type
(
x
))
type_y
=
typemap
.
get
(
type
(
y
),
type
(
y
))
type_x
=
self
.
typemap
.
get
(
type
(
x
),
type
(
x
))
type_y
=
self
.
typemap
.
get
(
type
(
y
),
type
(
y
))
return
type_x
==
type_y
def
load
(
self
,
filename
):
with
open
(
filename
,
"r"
,
encoding
=
"utf8"
)
as
file
:
self
.
data
=
json
.
load
(
file
)
bad_settings
=
0
for
k
,
v
in
self
.
data
.
items
():
info
=
self
.
data_labels
.
get
(
k
,
None
)
if
info
is
not
None
and
not
same_type
(
info
.
default
,
v
):
if
info
is
not
None
and
not
s
elf
.
s
ame_type
(
info
.
default
,
v
):
print
(
f
"Warning: bad setting value: {k}: {v} ({type(v).__name__}; expected {type(info.default).__name__})"
,
file
=
sys
.
stderr
)
bad_settings
+=
1
...
...
modules/txt2img.py
View file @
6fa20d51
...
...
@@ -37,9 +37,7 @@ def txt2img(prompt: str, negative_prompt: str, prompt_style: str, prompt_style2:
print
(
f
"
\n
txt2img: {prompt}"
,
file
=
shared
.
progress_print_out
)
processed
=
modules
.
scripts
.
scripts_txt2img
.
run
(
p
,
*
args
)
if
processed
is
not
None
:
pass
else
:
if
processed
is
None
:
processed
=
process_images
(
p
)
shared
.
total_tqdm
.
clear
()
...
...
modules/ui.py
View file @
6fa20d51
...
...
@@ -831,7 +831,11 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo):
components
=
[]
def
run_settings
(
*
args
):
up
=
[]
changed
=
0
for
key
,
value
,
comp
in
zip
(
opts
.
data_labels
.
keys
(),
args
,
components
):
if
not
opts
.
same_type
(
value
,
opts
.
data_labels
[
key
]
.
default
):
return
f
"Bad value for setting {key}: {value}; expecting {type(opts.data_labels[key].default).__name__}"
for
key
,
value
,
comp
in
zip
(
opts
.
data_labels
.
keys
(),
args
,
components
):
comp_args
=
opts
.
data_labels
[
key
]
.
component_args
...
...
@@ -841,14 +845,15 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo):
oldval
=
opts
.
data
.
get
(
key
,
None
)
opts
.
data
[
key
]
=
value
if
oldval
!=
value
and
opts
.
data_labels
[
key
]
.
onchange
is
not
None
:
if
oldval
!=
value
:
if
opts
.
data_labels
[
key
]
.
onchange
is
not
None
:
opts
.
data_labels
[
key
]
.
onchange
()
up
.
append
(
comp
.
update
(
value
=
value
))
changed
+=
1
opts
.
save
(
shared
.
config_filename
)
return
'Settings appli
ed.'
return
f
'{changed} settings chang
ed.'
with
gr
.
Blocks
(
analytics_enabled
=
False
)
as
settings_interface
:
settings_submit
=
gr
.
Button
(
value
=
"Apply settings"
,
variant
=
'primary'
)
...
...
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