mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix a few more metadata bugs
- facetool and upscale arguments now written into metadata - cleaned up handling of !fetch command
This commit is contained in:
parent
17aee48734
commit
37d38f196e
@ -113,8 +113,8 @@ PRECISION_CHOICES = [
|
||||
]
|
||||
|
||||
# is there a way to pick this up during git commits?
|
||||
APP_ID = 'lstein/stable-diffusion'
|
||||
APP_VERSION = 'v1.15'
|
||||
APP_ID = 'invoke-ai/InvokeAI'
|
||||
APP_VERSION = 'v2.02'
|
||||
|
||||
class ArgFormatter(argparse.RawTextHelpFormatter):
|
||||
# use defined argument order to display usage
|
||||
@ -847,7 +847,7 @@ def metadata_dumps(opt,
|
||||
# remove any image keys not mentioned in RFC #266
|
||||
rfc266_img_fields = ['type','postprocessing','sampler','prompt','seed','variations','steps',
|
||||
'cfg_scale','threshold','perlin','step_number','width','height','extra','strength',
|
||||
'init_img','init_mask']
|
||||
'init_img','init_mask','facetool','facetool_strength','upscale']
|
||||
|
||||
rfc_dict ={}
|
||||
|
||||
|
@ -38,7 +38,7 @@ class PngWriter:
|
||||
info = PngImagePlugin.PngInfo()
|
||||
info.add_text('Dream', dream_prompt)
|
||||
if metadata:
|
||||
info.add_text('sd-metadata', json.dumps(metadata))
|
||||
info.add_text('sd-metadata', json.dumps(metadata))
|
||||
image.save(path, 'PNG', pnginfo=info, compress_level=compress_level)
|
||||
return path
|
||||
|
||||
|
@ -808,31 +808,29 @@ def retrieve_dream_command(opt,command,completer):
|
||||
return
|
||||
|
||||
tokens = command.split()
|
||||
if len(tokens) > 1:
|
||||
return write_commands(opt,tokens)
|
||||
dir,basename = os.path.split(tokens[0])
|
||||
if len(dir) == 0:
|
||||
path = os.path.join(opt.outdir,basename)
|
||||
else:
|
||||
path = tokens[0]
|
||||
|
||||
if len(tokens) > 1:
|
||||
return write_commands(opt, path, tokens[1])
|
||||
|
||||
cmd = ''
|
||||
try:
|
||||
cmd = dream_cmd_from_png(tokens[0])
|
||||
cmd = dream_cmd_from_png(path)
|
||||
except OSError:
|
||||
print(f'## {path}: file could not be read')
|
||||
print(f'## {tokens[0]}: file could not be read')
|
||||
except (KeyError, AttributeError, IndexError):
|
||||
print(f'## {path}: file has no metadata')
|
||||
print(f'## {tokens[0]}: file has no metadata')
|
||||
except:
|
||||
print(f'## {path}: file could not be processed')
|
||||
print(f'## {tokens[0]}: file could not be processed')
|
||||
if len(cmd)>0:
|
||||
completer.set_line(cmd)
|
||||
|
||||
def write_commands(opt, tokens:list):
|
||||
file_path = tokens[0]
|
||||
outfilepath = tokens[1]
|
||||
|
||||
def write_commands(opt, file_path:str, outfilepath:str):
|
||||
dir,basename = os.path.split(file_path)
|
||||
if len(dir) == 0:
|
||||
dir = opt.outdir
|
||||
|
||||
outdir,outname = os.path.split(outfilepath)
|
||||
if len(outdir) == 0:
|
||||
outfilepath = os.path.join(dir,outname)
|
||||
try:
|
||||
paths = list(Path(dir).glob(basename))
|
||||
except ValueError:
|
||||
@ -844,8 +842,6 @@ def write_commands(opt, tokens:list):
|
||||
for path in paths:
|
||||
try:
|
||||
cmd = dream_cmd_from_png(path)
|
||||
except OSError:
|
||||
print(f'## {path}: file could not be read')
|
||||
except (KeyError, AttributeError, IndexError):
|
||||
print(f'## {path}: file has no metadata')
|
||||
except:
|
||||
@ -854,6 +850,9 @@ def write_commands(opt, tokens:list):
|
||||
commands.append(f'# {path}')
|
||||
commands.append(cmd)
|
||||
if len(commands)>0:
|
||||
dir,basename = os.path.split(outfilepath)
|
||||
if len(dir)==0:
|
||||
outfilepath = os.path.join(opt.outdir,basename)
|
||||
with open(outfilepath, 'w', encoding='utf-8') as f:
|
||||
f.write('\n'.join(commands))
|
||||
print(f'>> File {outfilepath} with commands created')
|
||||
|
Loading…
Reference in New Issue
Block a user