diff --git a/kohya_gui.py b/kohya_gui.py index f7e9769..91f3c19 100644 --- a/kohya_gui.py +++ b/kohya_gui.py @@ -13,6 +13,40 @@ from library.extract_lora_from_dylora_gui import gradio_extract_dylora_tab from library.merge_lycoris_gui import gradio_merge_lycoris_tab from lora_gui import lora_tab +import os +import sys +import json +import time +import shutil +import logging +import subprocess + +log = logging.getLogger("sd") + +# setup console and file logging +def setup_logging(clean=False): + try: + if clean and os.path.isfile('setup.log'): + os.remove('setup.log') + time.sleep(0.1) # prevent race condition + except: + pass + logging.basicConfig(level=logging.DEBUG, format='%(asctime)s | %(levelname)s | %(pathname)s | %(message)s', filename='setup.log', filemode='a', encoding='utf-8', force=True) + from rich.theme import Theme + from rich.logging import RichHandler + from rich.console import Console + from rich.pretty import install as pretty_install + from rich.traceback import install as traceback_install + console = Console(log_time=True, log_time_format='%H:%M:%S-%f', theme=Theme({ + "traceback.border": "black", + "traceback.border.syntax_error": "black", + "inspect.value.border": "black", + })) + pretty_install(console=console) + traceback_install(console=console, extra_lines=1, width=console.width, word_wrap=False, indent_guides=False, suppress=[]) + rh = RichHandler(show_time=True, omit_repeated_times=False, show_level=True, show_path=False, markup=False, rich_tracebacks=True, log_time_format='%H:%M:%S-%f', level=logging.DEBUG if args.debug else logging.INFO, console=console) + rh.set_name(logging.DEBUG if args.debug else logging.INFO) + log.addHandler(rh) def UI(**kwargs): css = '' diff --git a/setup.bat b/setup.bat index b692f4e..9416f83 100644 --- a/setup.bat +++ b/setup.bat @@ -39,6 +39,7 @@ if %choice%==1 ( pip install --use-pep517 --upgrade -r requirements.txt pip install --upgrade xformers==0.0.17 rem pip install -U -I --no-deps https://files.pythonhosted.org/packages/d6/f7/02662286419a2652c899e2b3d1913c47723fc164b4ac06a85f769c291013/xformers-0.0.17rc482-cp310-cp310-win_amd64.whl + pip install https://huggingface.co/r4ziel/xformers_pre_built/resolve/main/triton-2.0.0-cp310-cp310-win_amd64.whl ) copy /y .\bitsandbytes_windows\*.dll .\venv\Lib\site-packages\bitsandbytes\