#!/usr/bin/env python3
-from sys import exit as sys_exit
+from sys import argv, exit as sys_exit
from os.path import dirname, basename, splitext, join as path_join, exists
from argparse import ArgumentParser
from random import randint
from stable.core import ImageMaker
-DEFAULT_SCHEDULER='EulerAncestralDiscreteScheduler'
+DEFAULT_SCHEDULER = 'EulerAncestralDiscreteScheduler'
def save_path(count: int) -> str:
parser.add_argument('-o', '--output')
parser.add_argument('-p', '--prompt')
parser.add_argument('-H', '--help', action='help')
- parser.add_argument('-S', '--list_schedulers', action='store_true')
- parser.add_argument('-g', '--guidance', default=7.5, type=float,
- help='default: 7.5')
+ parser.add_argument('-S', '--list-schedulers', action='store_true')
parser.add_argument('-h', '--height', default=512, type=int,
help='default: 512')
+ parser.add_argument('-w', '--width', default=512, type=int,
+ help='default: 512')
+ parser.add_argument('-g', '--guidance', default=7.5, type=float,
+ help='default: 7.5')
parser.add_argument('-n', '--n_steps', default=15, type=int,
help='default: 15')
parser.add_argument('-q', '--quantity', default=1, type=int,
parser.add_argument('-r', '--randomness_seed', default=1, type=int,
help='default: 1; if set 0, chosen randomnly')
parser.add_argument('-s', '--scheduler', default=DEFAULT_SCHEDULER,
- help=f'default: DEFAULT_SCHEDULER')
- parser.add_argument('-w', '--width', default=512, type=int,
- help='default: 512')
+ help=f'default: {DEFAULT_SCHEDULER}')
parsed_args = parser.parse_args()
if not parsed_args.list_schedulers:
- if not parsed_args.output:
- raise Exception('Unless -H or -S, need --output set.')
- if not parsed_args.prompt:
- raise Exception('Unless -H or -S, need --prompt set.')
+ prefix = f'{argv[0]}: error: unless calling with -H/--help or '\
+ '-S/--list-schedulers, requiring '
+ suffix = ''
+ if (not parsed_args.output) and (not parsed_args.prompt):
+ suffix = '-o/--output and -p/--prompt'
+ elif not parsed_args.output:
+ suffix = '-o/--output'
+ elif not parsed_args.prompt:
+ suffix = '-p/--prompt'
+ if (not parsed_args.output) or (not parsed_args.prompt):
+ parser.print_usage()
+ print(f'{prefix}{suffix}')
+ sys_exit(1)
return parsed_args