From 7ae79b350ee2c6f93f1bf722cbc9675629215952 Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Sun, 28 Aug 2022 19:57:13 -0700 Subject: [PATCH] write log files in utf-8, not ascii --- ldm/dream/server.py | 2 +- scripts/dream.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ldm/dream/server.py b/ldm/dream/server.py index e2eabc3e43..0c4f2a48ad 100644 --- a/ldm/dream/server.py +++ b/ldm/dream/server.py @@ -83,7 +83,7 @@ class DreamServer(BaseHTTPRequestHandler): post_data['initimg'] = '' # Don't send init image back # Append post_data to log - with open("./outputs/img-samples/dream_web_log.txt", "a") as log: + with open("./outputs/img-samples/dream_web_log.txt", "a", encoding="utf-8") as log: for output in outputs: log.write(f"{output[0]}: {json.dumps(post_data)}\n") diff --git a/scripts/dream.py b/scripts/dream.py index e48b2e64a8..5c51c6e68b 100755 --- a/scripts/dream.py +++ b/scripts/dream.py @@ -69,7 +69,7 @@ def main(): if opt.infile: try: if os.path.isfile(opt.infile): - infile = open(opt.infile, 'r') + infile = open(opt.infile, 'r', encoding='utf-8') elif opt.infile == '-': # stdin infile = sys.stdin else: @@ -217,7 +217,7 @@ def get_next_command(infile=None) -> str: #command string command = command.strip() print(f'#{command}') return command - + def dream_server_loop(t2i): print('\n* --web was specified, starting web server...') # Change working directory to the stable-diffusion directory @@ -244,7 +244,7 @@ def write_log_message(prompt, results, log_path): log_lines = [f'{r[0]}: {prompt} -S{r[1]}\n' for r in results] print(*log_lines, sep='') - with open(log_path, 'a') as file: + with open(log_path, 'a', encoding='utf-8') as file: file.writelines(log_lines)