Bug Fixes

This commit is contained in:
blessedcoolant 2022-09-17 14:12:35 +12:00
parent 61f46cac31
commit 42072fc15c
2 changed files with 17 additions and 8 deletions

View File

@ -105,6 +105,7 @@ class Args(object):
try: try:
elements = shlex.split(command) elements = shlex.split(command)
except ValueError: except ValueError:
import sys, traceback
print(traceback.format_exc(), file=sys.stderr) print(traceback.format_exc(), file=sys.stderr)
return return
switches = [''] switches = ['']
@ -266,6 +267,17 @@ class Args(object):
default='stable-diffusion-1.4', default='stable-diffusion-1.4',
help='Indicates which diffusion model to load. (currently "stable-diffusion-1.4" (default) or "laion400m")', help='Indicates which diffusion model to load. (currently "stable-diffusion-1.4" (default) or "laion400m")',
) )
model_group.add_argument(
'--sampler',
'-A',
'-m',
dest='sampler_name',
type=str,
choices=SAMPLER_CHOICES,
metavar='SAMPLER_NAME',
help=f'Switch to a different sampler. Supported samplers: {", ".join(SAMPLER_CHOICES)}',
default='k_lms',
)
model_group.add_argument( model_group.add_argument(
'-F', '-F',
'--full_precision', '--full_precision',
@ -386,14 +398,12 @@ class Args(object):
'--width', '--width',
type=int, type=int,
help='Image width, multiple of 64', help='Image width, multiple of 64',
default=512
) )
render_group.add_argument( render_group.add_argument(
'-H', '-H',
'--height', '--height',
type=int, type=int,
help='Image height, multiple of 64', help='Image height, multiple of 64',
default=512,
) )
render_group.add_argument( render_group.add_argument(
'-C', '-C',
@ -429,7 +439,6 @@ class Args(object):
choices=SAMPLER_CHOICES, choices=SAMPLER_CHOICES,
metavar='SAMPLER_NAME', metavar='SAMPLER_NAME',
help=f'Switch to a different sampler. Supported samplers: {", ".join(SAMPLER_CHOICES)}', help=f'Switch to a different sampler. Supported samplers: {", ".join(SAMPLER_CHOICES)}',
default='k_lms',
) )
render_group.add_argument( render_group.add_argument(
'-t', '-t',

View File

@ -123,7 +123,7 @@ def main_loop(gen, opt, infile):
if command.startswith(('#', '//')): if command.startswith(('#', '//')):
continue continue
if command.startswith('q '): if len(command.strip()) == 1 and command.startswith('q'):
done = True done = True
break break
@ -138,7 +138,7 @@ def main_loop(gen, opt, infile):
parser.print_help() parser.print_help()
continue continue
if len(opt.prompt) == 0: if len(opt.prompt) == 0:
print('Try again with a prompt!') print('\nTry again with a prompt!')
continue continue
# retrieve previous value! # retrieve previous value!
@ -191,14 +191,14 @@ def main_loop(gen, opt, infile):
if not os.path.exists(opt.outdir): if not os.path.exists(opt.outdir):
os.makedirs(opt.outdir) os.makedirs(opt.outdir)
current_outdir = opt.outdir current_outdir = opt.outdir
elif prompt_as_dir: elif opt.prompt_as_dir:
# sanitize the prompt to a valid folder name # sanitize the prompt to a valid folder name
subdir = path_filter.sub('_', opt.prompt)[:name_max].rstrip(' .') subdir = path_filter.sub('_', opt.prompt)[:name_max].rstrip(' .')
# truncate path to maximum allowed length # truncate path to maximum allowed length
# 27 is the length of '######.##########.##.png', plus two separators and a NUL # 27 is the length of '######.##########.##.png', plus two separators and a NUL
subdir = subdir[:(path_max - 27 - len(os.path.abspath(opt.outdir)))] subdir = subdir[:(path_max - 27 - len(os.path.abspath(opt.outdir)))]
current_outdir = os.path.join(outdir, subdir) current_outdir = os.path.join(opt.outdir, subdir)
print('Writing files to directory: "' + current_outdir + '"') print('Writing files to directory: "' + current_outdir + '"')
@ -206,7 +206,7 @@ def main_loop(gen, opt, infile):
if not os.path.exists(current_outdir): if not os.path.exists(current_outdir):
os.makedirs(current_outdir) os.makedirs(current_outdir)
else: else:
current_outdir = outdir current_outdir = opt.outdir
# Here is where the images are actually generated! # Here is where the images are actually generated!
last_results = [] last_results = []