|
from modules import launch_utils |
|
import os |
|
import subprocess |
|
import threading |
|
import logging |
|
import sys |
|
|
|
|
|
log_file = '/bushu/logs_run.txt' |
|
if os.path.exists(log_file): |
|
os.remove(log_file) |
|
|
|
|
|
logging.basicConfig(filename=log_file, 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 |
|
|
|
|
|
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 |
|
args.share = True |
|
|
|
|
|
util_py_path = '/bushu/ui/repositories/diffusion-stability-stable/ldm/util.py' |
|
|
|
def main(): |
|
if not args.skip_prepare_environment: |
|
prepare_environment() |
|
for _ in range(3): |
|
os.system(f"sed -i -e 's/dict()))/dict())).cuda()/g' {util_py_path}") |
|
os.system(f"sed -i -e 's/stable/dict()))/dict())).cuda()/g' /content/ui/repositories/diffusion-stability-stable/ldm/util.py") |
|
|
|
if args.test_server: |
|
configure_for_tests() |
|
|
|
start() |
|
|
|
|
|
def find_and_print_links(): |
|
while True: |
|
line = log_process.stdout.readline() |
|
if "Public WebUI Colab URL" in line: |
|
url = line.split("Public WebUI Colab URL: ")[1].strip() |
|
print(url) |
|
else: |
|
|
|
log_file.write(line) |
|
log_file.flush() |
|
|
|
|
|
log_file_path = '/bushu/logs_run_launch.txt' |
|
log_file = open(log_file_path, 'w') |
|
|
|
|
|
tee_command = f"{python} -u -m tee -a {log_file_path}" |
|
log_process = subprocess.Popen(tee_command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=1, universal_newlines=True) |
|
|
|
__name__ = "__main__" |
|
|
|
main() |
|
|
|
|
|
|
|
log_process.wait() |
|
|
|
|
|
log_file.close() |
|
|