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
964b63c0
Commit
964b63c0
authored
Oct 17, 2022
by
AUTOMATIC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add api() function to return webui() to how it was
parent
71d42bb4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
38 deletions
+41
-38
webui.py
webui.py
+41
-38
No files found.
webui.py
View file @
964b63c0
...
@@ -87,59 +87,62 @@ def initialize():
...
@@ -87,59 +87,62 @@ def initialize():
shared
.
opts
.
onchange
(
"sd_hypernetwork"
,
wrap_queued_call
(
lambda
:
modules
.
hypernetworks
.
hypernetwork
.
load_hypernetwork
(
shared
.
opts
.
sd_hypernetwork
)))
shared
.
opts
.
onchange
(
"sd_hypernetwork"
,
wrap_queued_call
(
lambda
:
modules
.
hypernetworks
.
hypernetwork
.
load_hypernetwork
(
shared
.
opts
.
sd_hypernetwork
)))
shared
.
opts
.
onchange
(
"sd_hypernetwork_strength"
,
modules
.
hypernetworks
.
hypernetwork
.
apply_strength
)
shared
.
opts
.
onchange
(
"sd_hypernetwork_strength"
,
modules
.
hypernetworks
.
hypernetwork
.
apply_strength
)
def
webui
():
initialize
()
# make the program just exit at ctrl+c without waiting for anything
# make the program just exit at ctrl+c without waiting for anything
def
sigint_handler
(
sig
,
frame
):
def
sigint_handler
(
sig
,
frame
):
print
(
f
'Interrupted with signal {sig} in {frame}'
)
print
(
f
'Interrupted with signal {sig} in {frame}'
)
os
.
_exit
(
0
)
os
.
_exit
(
0
)
signal
.
signal
(
signal
.
SIGINT
,
sigint_handler
)
signal
.
signal
(
signal
.
SIGINT
,
sigint_handler
)
if
cmd_opts
.
api
:
from
modules.api.api
import
Api
api
=
Api
()
api
.
launch
(
server_name
=
"0.0.0.0"
if
cmd_opts
.
listen
else
"127.0.0.1"
,
port
=
cmd_opts
.
port
if
cmd_opts
.
port
else
7861
)
else
:
def
api
()
while
1
:
initialize
()
demo
=
modules
.
ui
.
create_ui
(
wrap_gradio_gpu_call
=
wrap_gradio_gpu_call
)
from
modules.api.api
import
Api
api
=
Api
()
api
.
launch
(
server_name
=
"0.0.0.0"
if
cmd_opts
.
listen
else
"127.0.0.1"
,
port
=
cmd_opts
.
port
if
cmd_opts
.
port
else
7861
)
app
,
local_url
,
share_url
=
demo
.
launch
(
share
=
cmd_opts
.
share
,
server_name
=
"0.0.0.0"
if
cmd_opts
.
listen
else
None
,
server_port
=
cmd_opts
.
port
,
debug
=
cmd_opts
.
gradio_debug
,
auth
=
[
tuple
(
cred
.
split
(
':'
))
for
cred
in
cmd_opts
.
gradio_auth
.
strip
(
'"'
)
.
split
(
','
)]
if
cmd_opts
.
gradio_auth
else
None
,
inbrowser
=
cmd_opts
.
autolaunch
,
prevent_thread_lock
=
True
)
app
.
add_middleware
(
GZipMiddleware
,
minimum_size
=
1000
)
def
webui
():
initialize
()
while
1
:
while
1
:
demo
=
modules
.
ui
.
create_ui
(
wrap_gradio_gpu_call
=
wrap_gradio_gpu_call
)
app
,
local_url
,
share_url
=
demo
.
launch
(
share
=
cmd_opts
.
share
,
server_name
=
"0.0.0.0"
if
cmd_opts
.
listen
else
None
,
server_port
=
cmd_opts
.
port
,
debug
=
cmd_opts
.
gradio_debug
,
auth
=
[
tuple
(
cred
.
split
(
':'
))
for
cred
in
cmd_opts
.
gradio_auth
.
strip
(
'"'
)
.
split
(
','
)]
if
cmd_opts
.
gradio_auth
else
None
,
inbrowser
=
cmd_opts
.
autolaunch
,
prevent_thread_lock
=
True
)
app
.
add_middleware
(
GZipMiddleware
,
minimum_size
=
1000
)
while
1
:
time
.
sleep
(
0.5
)
if
getattr
(
demo
,
'do_restart'
,
False
):
time
.
sleep
(
0.5
)
demo
.
close
()
time
.
sleep
(
0.5
)
time
.
sleep
(
0.5
)
if
getattr
(
demo
,
'do_restart'
,
False
):
break
time
.
sleep
(
0.5
)
demo
.
close
()
time
.
sleep
(
0.5
)
break
sd_samplers
.
set_samplers
()
sd_samplers
.
set_samplers
()
print
(
'Reloading Custom Scripts'
)
print
(
'Reloading Custom Scripts'
)
modules
.
scripts
.
reload_scripts
(
os
.
path
.
join
(
script_path
,
"scripts"
))
modules
.
scripts
.
reload_scripts
(
os
.
path
.
join
(
script_path
,
"scripts"
))
print
(
'Reloading modules: modules.ui'
)
print
(
'Reloading modules: modules.ui'
)
importlib
.
reload
(
modules
.
ui
)
importlib
.
reload
(
modules
.
ui
)
print
(
'Refreshing Model List'
)
print
(
'Refreshing Model List'
)
modules
.
sd_models
.
list_models
()
modules
.
sd_models
.
list_models
()
print
(
'Restarting Gradio'
)
print
(
'Restarting Gradio'
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
webui
()
if
cmd_opts
.
api
:
api
()
else
:
webui
()
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