From e49e83e944de5e1aecff5cd99df682fea4b523d6 Mon Sep 17 00:00:00 2001 From: Lincoln Stein Date: Wed, 28 Sep 2022 11:57:59 -0400 Subject: [PATCH] fix crash that occurs in write_log when user interrupts generation with ^C --- ldm/dream/args.py | 6 ++++-- ldm/dream/log.py | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ldm/dream/args.py b/ldm/dream/args.py index 92d5acee0c..1204773db7 100644 --- a/ldm/dream/args.py +++ b/ldm/dream/args.py @@ -81,7 +81,7 @@ with metadata_from_png(): """ import argparse -from argparse import Namespace +from argparse import Namespace, RawTextHelpFormatter import shlex import json import hashlib @@ -445,7 +445,9 @@ class Args(object): # This creates the parser that processes commands on the dream> command line def _create_dream_cmd_parser(self): parser = argparse.ArgumentParser( - description=""" + formatter_class=RawTextHelpFormatter, + description= + """ *Image generation:* To generate images, type a text prompt with optional switches. Example: a fantastic alien landscape -W576 -H512 -s60 -n4 diff --git a/ldm/dream/log.py b/ldm/dream/log.py index beca10fa3f..8aebe62671 100644 --- a/ldm/dream/log.py +++ b/ldm/dream/log.py @@ -22,6 +22,8 @@ def write_log(results, log_path, file_types, output_cntr): def write_log_message(results, output_cntr): """logs to the terminal""" + if len(results) == 0: + return output_cntr log_lines = [f"{path}: {prompt}\n" for path, prompt in results] if len(log_lines)>1: subcntr = 1