mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2025-08-04 11:12:35 +00:00
Merge branch 'master' into vae-picker
This commit is contained in:
26
webui.py
26
webui.py
@@ -9,7 +9,7 @@ from fastapi.middleware.gzip import GZipMiddleware
|
||||
|
||||
from modules.paths import script_path
|
||||
|
||||
from modules import devices, sd_samplers, upscaler
|
||||
from modules import devices, sd_samplers, upscaler, extensions
|
||||
import modules.codeformer_model as codeformer
|
||||
import modules.extras
|
||||
import modules.face_restoration
|
||||
@@ -24,6 +24,7 @@ import modules.sd_models
|
||||
import modules.sd_vae
|
||||
import modules.shared as shared
|
||||
import modules.txt2img
|
||||
import modules.script_callbacks
|
||||
|
||||
import modules.ui
|
||||
from modules import devices
|
||||
@@ -61,6 +62,8 @@ def wrap_gradio_gpu_call(func, extra_outputs=None):
|
||||
|
||||
|
||||
def initialize():
|
||||
extensions.list_extensions()
|
||||
|
||||
if cmd_opts.ui_debug_mode:
|
||||
shared.sd_upscalers = upscaler.UpscalerLanczos().scalers
|
||||
modules.scripts.load_scripts()
|
||||
@@ -77,10 +80,10 @@ def initialize():
|
||||
|
||||
modules.sd_vae.refresh_vae_list()
|
||||
modules.sd_models.load_model()
|
||||
shared.opts.onchange("sd_model_checkpoint", wrap_queued_call(lambda: modules.sd_models.reload_model_weights(shared.sd_model)))
|
||||
shared.opts.onchange("sd_model_checkpoint", wrap_queued_call(lambda: modules.sd_models.reload_model_weights()))
|
||||
# I don't know what needs to be done to only reload VAE, with all those hijacks callbacks, and lowvram,
|
||||
# so for now this reloads the whole model too, and no cache
|
||||
shared.opts.onchange("sd_vae", wrap_queued_call(lambda: modules.sd_models.reload_model_weights(shared.sd_model, force=True)), call=False)
|
||||
# so for now this reloads the whole model too
|
||||
shared.opts.onchange("sd_vae", wrap_queued_call(lambda: modules.sd_models.reload_model_weights(force=True)), call=False)
|
||||
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)
|
||||
|
||||
@@ -97,15 +100,18 @@ def create_api(app):
|
||||
api = Api(app, queue_lock)
|
||||
return api
|
||||
|
||||
|
||||
def wait_on_server(demo=None):
|
||||
while 1:
|
||||
time.sleep(0.5)
|
||||
if demo and getattr(demo, 'do_restart', False):
|
||||
if shared.state.need_restart:
|
||||
shared.state.need_restart = False
|
||||
time.sleep(0.5)
|
||||
demo.close()
|
||||
time.sleep(0.5)
|
||||
break
|
||||
|
||||
|
||||
def api_only():
|
||||
initialize()
|
||||
|
||||
@@ -137,14 +143,18 @@ def webui():
|
||||
|
||||
app.add_middleware(GZipMiddleware, minimum_size=1000)
|
||||
|
||||
if (launch_api):
|
||||
if launch_api:
|
||||
create_api(app)
|
||||
|
||||
modules.script_callbacks.app_started_callback(demo, app)
|
||||
|
||||
wait_on_server(demo)
|
||||
|
||||
sd_samplers.set_samplers()
|
||||
|
||||
print('Reloading Custom Scripts')
|
||||
print('Reloading extensions')
|
||||
extensions.list_extensions()
|
||||
print('Reloading custom scripts')
|
||||
modules.scripts.reload_scripts()
|
||||
print('Reloading modules: modules.ui')
|
||||
importlib.reload(modules.ui)
|
||||
@@ -153,8 +163,6 @@ def webui():
|
||||
print('Restarting Gradio')
|
||||
|
||||
|
||||
|
||||
task = []
|
||||
if __name__ == "__main__":
|
||||
if cmd_opts.nowebui:
|
||||
api_only()
|
||||
|
Reference in New Issue
Block a user