|
from modules import launch_utils |
|
import os |
|
import subprocess |
|
import threading |
|
import logging |
|
import sys |
|
|
|
|
|
args = launch_utils.args |
|
args.listen = True |
|
args.xformers = True |
|
args.enable_insecure_extension_access = True |
|
args.theme = "dark" |
|
args.gradio_queue = True |
|
args.multiple = True |
|
args.no_download_sd_model = True |
|
|
|
|
|
log_file_path = '/bushu/logs_run.txt' |
|
|
|
|
|
logging.basicConfig(filename=log_file_path, level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') |
|
|
|
|
|
console_handler = logging.StreamHandler(sys.stdout) |
|
console_handler.setLevel(logging.INFO) |
|
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s') |
|
console_handler.setFormatter(formatter) |
|
logging.getLogger().addHandler(console_handler) |
|
|
|
|
|
sys.stdout = logging.getLogger().handlers[0].stream |
|
sys.stderr = logging.getLogger().handlers[0].stream |
|
|
|
try: |
|
if not args.skip_prepare_environment: |
|
launch_utils.prepare_environment() |
|
os.system(f"sed -i -e 's/dict()))/dict())).cuda()/g' {launch_utils.util_py_path}") |
|
os.system(f"sed -i -e 's/stable/dict()))/dict())).cuda()/g' /bushu/ui/repositories/diffusion-stability-stable/ldm/util.py") |
|
|
|
if args.test_server: |
|
launch_utils.configure_for_tests() |
|
|
|
launch_utils.start() |
|
except Exception as e: |
|
|
|
logging.exception(f"程序发生异常: {e}") |
|
finally: |
|
|
|
logging.getLogger().removeHandler(console_handler) |
|
console_handler.close() |
|
|