mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Address bakkot review
This commit is contained in:
parent
4f8e7356b3
commit
2e22d9ecf1
@ -178,18 +178,15 @@ def main_loop(t2i, outdir, prompt_as_dir, parser, infile):
|
|||||||
os.makedirs(opt.outdir)
|
os.makedirs(opt.outdir)
|
||||||
current_outdir = opt.outdir
|
current_outdir = opt.outdir
|
||||||
elif prompt_as_dir:
|
elif prompt_as_dir:
|
||||||
if prompt_as_dir == 'simple':
|
# sanitize the prompt to a valid folder name
|
||||||
# this line will sanitize the entire prompt as one folder
|
subdir = path_filter.sub('_', opt.prompt)[:name_max].rstrip(' .')
|
||||||
subdir = path_filter.sub('_', opt.prompt)[:name_max].rstrip(' .')
|
|
||||||
else:
|
|
||||||
# this line will allow the prompt to create subdirectories
|
|
||||||
subdir = os.path.join(*[path_filter.sub('_', x)[:name_max].rstrip(' .') for x in opt.prompt.replace('\\', '/').split('/') if x.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
|
||||||
subdir = subdir[:(path_max - 27 - len(os.path.abspath(outdir)))]
|
subdir = subdir[:(path_max - 27 - len(os.path.abspath(outdir)))]
|
||||||
current_outdir = os.path.join(outdir, subdir)
|
current_outdir = os.path.join(outdir, subdir)
|
||||||
|
|
||||||
print ('\nWriting files to directory: "' + current_outdir + '"\n')
|
print ('Writing files to directory: "' + current_outdir + '"')
|
||||||
|
|
||||||
# make sure the output directory exists
|
# make sure the output directory exists
|
||||||
if not os.path.exists(current_outdir):
|
if not os.path.exists(current_outdir):
|
||||||
@ -350,10 +347,8 @@ def create_argv_parser():
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--prompt_as_dir',
|
'--prompt_as_dir',
|
||||||
'-p',
|
'-p',
|
||||||
type=str,
|
action='store_true',
|
||||||
nargs='?',
|
help='Place images in subdirectories named after the prompt.',
|
||||||
const='y',
|
|
||||||
help='Output images are placed in subdirectories named using the prompt string. Only used if --prompt_as_dir or -p is specified.\nIf set to \"simple\" then all non-alphanumeric characters in the prompt will be replaced by underscores for the folder name.',
|
|
||||||
)
|
)
|
||||||
# GFPGAN related args
|
# GFPGAN related args
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
|
Loading…
Reference in New Issue
Block a user