mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix duplicate files created during upscaling/facial reconstruction
- When --save_orig *not* provided during image generation with upscaling/face fixing, an extra image file was being created. This PR fixes the problem. - Also generalizes the tab autocomplete for image paths such that autocomplete searches the output directory for all path-modifying options except for --outdir.
This commit is contained in:
parent
779422d01b
commit
8c9f2ae705
@ -52,15 +52,15 @@ COMMANDS = (
|
|||||||
'!fix','!fetch',
|
'!fix','!fetch',
|
||||||
)
|
)
|
||||||
IMG_PATH_COMMANDS = (
|
IMG_PATH_COMMANDS = (
|
||||||
'--init_img[=\s]','-I',
|
'--outdir[=\s]',
|
||||||
'--init_mask[=\s]','-M',
|
|
||||||
'--init_color[=\s]',
|
|
||||||
'--embedding_path[=\s]',
|
|
||||||
'--outdir[=\s]'
|
|
||||||
)
|
)
|
||||||
IMG_FILE_COMMANDS=(
|
IMG_FILE_COMMANDS=(
|
||||||
'!fix',
|
'!fix',
|
||||||
'!fetch',
|
'!fetch',
|
||||||
|
'--init_img[=\s]','-I',
|
||||||
|
'--init_mask[=\s]','-M',
|
||||||
|
'--init_color[=\s]',
|
||||||
|
'--embedding_path[=\s]',
|
||||||
)
|
)
|
||||||
path_regexp = '('+'|'.join(IMG_PATH_COMMANDS+IMG_FILE_COMMANDS) + ')\s*\S*$'
|
path_regexp = '('+'|'.join(IMG_PATH_COMMANDS+IMG_FILE_COMMANDS) + ')\s*\S*$'
|
||||||
|
|
||||||
@ -178,7 +178,7 @@ class Completer:
|
|||||||
readline.redisplay()
|
readline.redisplay()
|
||||||
self.linebuffer = None
|
self.linebuffer = None
|
||||||
|
|
||||||
def _path_completions(self, text, state, extensions, shortcut_ok=False):
|
def _path_completions(self, text, state, extensions, shortcut_ok=True):
|
||||||
# separate the switch from the partial path
|
# separate the switch from the partial path
|
||||||
match = re.search('^(-\w|--\w+=?)(.*)',text)
|
match = re.search('^(-\w|--\w+=?)(.*)',text)
|
||||||
if match is None:
|
if match is None:
|
||||||
|
@ -219,6 +219,13 @@ def main_loop(gen, opt, infile):
|
|||||||
opt.init_img = None
|
opt.init_img = None
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# try to relativize pathnames
|
||||||
|
for attr in ('init_img','init_mask','init_color','embedding_path'):
|
||||||
|
if getattr(opt,attr) and not os.path.exists(getattr(opt,attr)):
|
||||||
|
basename = getattr(opt,attr)
|
||||||
|
path = os.path.join(opt.outdir,basename)
|
||||||
|
setattr(opt,attr,path)
|
||||||
|
|
||||||
# retrieve previous valueof seed if requested
|
# retrieve previous valueof seed if requested
|
||||||
if opt.seed is not None and opt.seed < 0:
|
if opt.seed is not None and opt.seed < 0:
|
||||||
try:
|
try:
|
||||||
@ -261,16 +268,19 @@ def main_loop(gen, opt, infile):
|
|||||||
results = [] # list of filename, prompt pairs
|
results = [] # list of filename, prompt pairs
|
||||||
grid_images = dict() # seed -> Image, only used if `opt.grid`
|
grid_images = dict() # seed -> Image, only used if `opt.grid`
|
||||||
prior_variations = opt.with_variations or []
|
prior_variations = opt.with_variations or []
|
||||||
|
prefix = file_writer.unique_prefix()
|
||||||
|
|
||||||
def image_writer(image, seed, upscaled=False, first_seed=None, use_prefix=None):
|
def image_writer(image, seed, upscaled=False, first_seed=None, use_prefix=None):
|
||||||
|
print(f'DEBUG:upscaled={upscaled}, first_seed={first_seed}, use_prefix={use_prefix}')
|
||||||
|
|
||||||
|
|
||||||
# note the seed is the seed of the current image
|
# note the seed is the seed of the current image
|
||||||
# the first_seed is the original seed that noise is added to
|
# the first_seed is the original seed that noise is added to
|
||||||
# when the -v switch is used to generate variations
|
# when the -v switch is used to generate variations
|
||||||
nonlocal prior_variations
|
nonlocal prior_variations
|
||||||
|
nonlocal prefix
|
||||||
if use_prefix is not None:
|
if use_prefix is not None:
|
||||||
prefix = use_prefix
|
prefix = use_prefix
|
||||||
else:
|
|
||||||
prefix = file_writer.unique_prefix()
|
|
||||||
|
|
||||||
path = None
|
path = None
|
||||||
if opt.grid:
|
if opt.grid:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user