enable outcropping of random JPG/PNG images

- Works best with runwayML inpainting model
- Numerous code changes required to propagate seed to final metadata.
  Original code predicated on the image being generated within InvokeAI.
This commit is contained in:
Lincoln Stein
2022-11-08 15:22:32 +00:00
parent 4b5a96501d
commit 5606af5083
5 changed files with 17 additions and 12 deletions

View File

@ -29,6 +29,7 @@ infile = None
def main():
"""Initialize command-line parsers and the diffusion model"""
global infile
print('* Initializing, be patient...')
opt = Args()
args = opt.parse_args()
@ -46,7 +47,6 @@ def main():
print('--max_loaded_models must be >= 1; using 1')
args.max_loaded_models = 1
print('* Initializing, be patient...')
from ldm.generate import Generate
# these two lines prevent a horrible warning message from appearing
@ -656,7 +656,10 @@ def do_postprocess (gen, opt, callback):
def add_postprocessing_to_metadata(opt,original_file,new_file,tool,command):
original_file = original_file if os.path.exists(original_file) else os.path.join(opt.outdir,original_file)
new_file = new_file if os.path.exists(new_file) else os.path.join(opt.outdir,new_file)
meta = retrieve_metadata(original_file)['sd-metadata']
try:
meta = retrieve_metadata(original_file)['sd-metadata']
except AttributeError:
meta = retrieve_metadata(new_file)['sd-metadata']
if 'image' not in meta:
meta = metadata_dumps(opt,seeds=[opt.seed])['image']
meta['image'] = {}