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
5a6387e1
Commit
5a6387e1
authored
Nov 19, 2022
by
AUTOMATIC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make it possible to change models etc by editing options using API
parent
84a6f211
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
22 deletions
+24
-22
modules/api/api.py
modules/api/api.py
+3
-4
modules/shared.py
modules/shared.py
+17
-0
modules/ui.py
modules/ui.py
+4
-18
No files found.
modules/api/api.py
View file @
5a6387e1
...
...
@@ -253,9 +253,8 @@ class Api:
return
options
def
set_config
(
self
,
req
:
Dict
[
str
,
Any
]):
for
o
in
req
:
setattr
(
shared
.
opts
,
o
,
req
[
o
])
for
k
,
v
in
req
.
items
():
shared
.
opts
.
set
(
k
,
v
)
shared
.
opts
.
save
(
shared
.
config_filename
)
return
...
...
@@ -264,7 +263,7 @@ class Api:
return
vars
(
shared
.
cmd_opts
)
def
get_samplers
(
self
):
return
[{
"name"
:
sampler
[
0
],
"aliases"
:
sampler
[
2
],
"options"
:
sampler
[
3
]}
for
sampler
in
sd_samplers
.
all_samplers
]
return
[{
"name"
:
sampler
[
0
],
"aliases"
:
sampler
[
2
],
"options"
:
sampler
[
3
]}
for
sampler
in
sd_samplers
.
all_samplers
]
def
get_upscalers
(
self
):
upscalers
=
[]
...
...
modules/shared.py
View file @
5a6387e1
...
...
@@ -437,6 +437,23 @@ class Options:
return
super
(
Options
,
self
)
.
__getattribute__
(
item
)
def
set
(
self
,
key
,
value
):
"""sets an option and calls its onchange callback, returning True if the option changed and False otherwise"""
oldval
=
self
.
data
.
get
(
key
,
None
)
if
oldval
==
value
:
return
False
try
:
setattr
(
self
,
key
,
value
)
except
RuntimeError
:
return
False
if
self
.
data_labels
[
key
]
.
onchange
is
not
None
:
self
.
data_labels
[
key
]
.
onchange
()
return
True
def
save
(
self
,
filename
):
assert
not
cmd_opts
.
freeze_settings
,
"saving settings is disabled"
...
...
modules/ui.py
View file @
5a6387e1
...
...
@@ -1484,16 +1484,9 @@ def create_ui(wrap_gradio_gpu_call):
if
comp
==
dummy_component
:
continue
oldval
=
opts
.
data
.
get
(
key
,
None
)
try
:
setattr
(
opts
,
key
,
value
)
except
RuntimeError
:
continue
if
oldval
!=
value
:
if
opts
.
data_labels
[
key
]
.
onchange
is
not
None
:
opts
.
data_labels
[
key
]
.
onchange
()
if
opts
.
set
(
key
,
value
):
changed
.
append
(
key
)
try
:
opts
.
save
(
shared
.
config_filename
)
except
RuntimeError
:
...
...
@@ -1504,15 +1497,8 @@ def create_ui(wrap_gradio_gpu_call):
if
not
opts
.
same_type
(
value
,
opts
.
data_labels
[
key
]
.
default
):
return
gr
.
update
(
visible
=
True
),
opts
.
dumpjson
()
oldval
=
opts
.
data
.
get
(
key
,
None
)
try
:
setattr
(
opts
,
key
,
value
)
except
Exception
:
return
gr
.
update
(
value
=
oldval
),
opts
.
dumpjson
()
if
oldval
!=
value
:
if
opts
.
data_labels
[
key
]
.
onchange
is
not
None
:
opts
.
data_labels
[
key
]
.
onchange
()
if
not
opts
.
set
(
key
,
value
):
return
gr
.
update
(
value
=
getattr
(
opts
,
key
)),
opts
.
dumpjson
()
opts
.
save
(
shared
.
config_filename
)
...
...
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