ask user to make window larger if not enough space for textual inversion/merge gui

- The invokeai-ti and invokeai-merge scripts will crash if there is not enough space
  in the console to fit the user interface (even after responsive formatting).

- This PR intercepts the errors and prints a useful error message advising user to
  make window larger.
This commit is contained in:
Lincoln Stein 2023-02-12 17:38:46 -05:00
parent 3dd7393984
commit d1ad46d6f1
2 changed files with 13 additions and 9 deletions

View File

@ -463,7 +463,7 @@ def main():
"** You need to have at least two diffusers models defined in models.yaml in order to merge"
)
else:
print(f"** A layout error has occurred: {str(e)}")
print(f"** Not enough room for the user interface. Try making this window larger.")
sys.exit(-1)
except Exception as e:
print(">> An error occurred:")

View File

@ -439,19 +439,23 @@ def main():
do_front_end(args)
else:
do_textual_inversion_training(**vars(args))
except widget.NotEnoughSpaceForWidget as e:
if str(e).startswith("Height of 1 allocated"):
print(
"** You need to have at least one diffusers models defined in models.yaml in order to train"
)
else:
print(f"** A layout error has occurred: {str(e)}")
sys.exit(-1)
except AssertionError as e:
print(str(e))
sys.exit(-1)
except KeyboardInterrupt:
pass
except (widget.NotEnoughSpaceForWidget, Exception) as e:
if str(e).startswith("Height of 1 allocated"):
print(
"** You need to have at least one diffusers models defined in models.yaml in order to train"
)
elif str(e).startswith('addwstr'):
print(
'** Not enough window space for the interface. Please make your window larger and try again.'
)
else:
print(f"** A layout error has occurred: {str(e)}")
sys.exit(-1)
if __name__ == "__main__":