mirror of https://github.com/vladmandic/automatic
add asyncio handler
parent
e83708284a
commit
def7a02d82
|
|
@ -1,8 +1,8 @@
|
|||
import datetime
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import json
|
||||
import datetime
|
||||
|
||||
import gradio as gr
|
||||
import tqdm
|
||||
|
|
@ -321,23 +321,12 @@ options_templates.update(options_section(('saving-paths', "Image Paths"), {
|
|||
"outdir_save": OptionInfo("outputs/save", "Directory for saving images using the Save button", component_args=hide_dirs),
|
||||
}))
|
||||
|
||||
cuda_dtype = OptionInfo("FP16", "Device precision type", gr.Radio, lambda: {"choices": ["FP32", "FP16", "BF16"]})
|
||||
no_half = OptionInfo(False, "Use full precision for model (--no-half)")
|
||||
no_half_vae = OptionInfo(False, "Use full precision for VAE (--no-half-vae)")
|
||||
upcast_sampling = OptionInfo(False,
|
||||
"Enable upcast sampling. Usually produces similar results to --no-half with better performance while using less memory")
|
||||
# support for macOS.
|
||||
if sys.platform == "darwin":
|
||||
cuda_dtype.default = "FP32"
|
||||
upcast_sampling.default = True
|
||||
|
||||
|
||||
options_templates.update(options_section(('cuda', "CUDA Settings"), {
|
||||
"precision": OptionInfo("Autocast", "Precision type", gr.Radio, lambda: {"choices": ["Autocast", "Full"]}),
|
||||
"cuda_dtype": cuda_dtype,
|
||||
"no_half": no_half,
|
||||
"no_half_vae": no_half_vae,
|
||||
"upcast_sampling": upcast_sampling,
|
||||
"cuda_dtype": OptionInfo("FP32" if sys.platform == "darwin" else "FP16", "Device precision type", gr.Radio, lambda: {"choices": ["FP32", "FP16", "BF16"]}),
|
||||
"no_half": OptionInfo(False, "Use full precision for model (--no-half)"),
|
||||
"no_half_vae": OptionInfo(False, "Use full precision for VAE (--no-half-vae)"),
|
||||
"upcast_sampling": OptionInfo(True if sys.platform == "darwin" else False, "Enable upcast sampling. Usually produces similar results to --no-half with better performance while using less memory"),
|
||||
"disable_nan_check": OptionInfo(True, "Do not check if produced images/latent spaces have NaN values"),
|
||||
"rollback_vae": OptionInfo(False, "Attempt to roll back VAE when produced NaN values, requires NaN check (experimental)"),
|
||||
"opt_channelslast": OptionInfo(False, "Use channels last as torch memory format "),
|
||||
|
|
|
|||
20
webui.py
20
webui.py
|
|
@ -1,9 +1,11 @@
|
|||
import os
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
import signal
|
||||
import warnings
|
||||
import asyncio
|
||||
import logging
|
||||
import warnings
|
||||
from rich import print # pylint: disable=W0622
|
||||
from modules import timer, errors
|
||||
|
||||
|
|
@ -166,9 +168,25 @@ def create_api(app):
|
|||
return api
|
||||
|
||||
|
||||
def async_policy():
|
||||
_BasePolicy = asyncio.WindowsSelectorEventLoopPolicy if sys.platform == "win32" and hasattr(asyncio, "WindowsSelectorEventLoopPolicy") else asyncio.DefaultEventLoopPolicy
|
||||
|
||||
class AnyThreadEventLoopPolicy(_BasePolicy):
|
||||
def get_event_loop(self) -> asyncio.AbstractEventLoop:
|
||||
try:
|
||||
return super().get_event_loop()
|
||||
except (RuntimeError, AssertionError):
|
||||
loop = self.new_event_loop()
|
||||
self.set_event_loop(loop)
|
||||
return loop
|
||||
|
||||
asyncio.set_event_loop_policy(AnyThreadEventLoopPolicy())
|
||||
|
||||
|
||||
def start_ui():
|
||||
logging.disable(logging.INFO)
|
||||
create_paths(opts)
|
||||
async_policy()
|
||||
initialize()
|
||||
if shared.opts.clean_temp_dir_at_start:
|
||||
ui_tempdir.cleanup_tmpdr()
|
||||
|
|
|
|||
Loading…
Reference in New Issue