diff --git a/ldm/generate.py b/ldm/generate.py index b21787eb47c..c3a69fd3a3f 100644 --- a/ldm/generate.py +++ b/ldm/generate.py @@ -570,16 +570,19 @@ def apply_postprocessor( from ldm.invoke.restoration.outcrop import Outcrop extend_instructions = {} for direction,pixels in _pairwise(opt.outcrop): - extend_instructions[direction]=int(pixels) - - restorer = Outcrop(image,self,) - return restorer.process ( - extend_instructions, - opt = opt, - orig_opt = args, - image_callback = callback, - prefix = prefix, - ) + try: + extend_instructions[direction]=int(pixels) + except ValueError: + print(f'** invalid extension instruction. Use ..., as in "top 64 left 128 right 64 bottom 64"') + if len(extend_instructions)>0: + restorer = Outcrop(image,self,) + return restorer.process ( + extend_instructions, + opt = opt, + orig_opt = args, + image_callback = callback, + prefix = prefix, + ) elif tool == 'embiggen': # fetch the metadata from the image diff --git a/ldm/invoke/args.py b/ldm/invoke/args.py index 26920f28ea9..3b87db5fd7c 100644 --- a/ldm/invoke/args.py +++ b/ldm/invoke/args.py @@ -967,17 +967,17 @@ def sha256(path): return sha.hexdigest() def legacy_metadata_load(meta,pathname) -> Args: + opt = Args() if 'Dream' in meta and len(meta['Dream']) > 0: dream_prompt = meta['Dream'] - opt = Args() opt.parse_cmd(dream_prompt) - return opt else: # if nothing else, we can get the seed match = re.search('\d+\.(\d+)',pathname) if match: seed = match.groups()[0] - opt = Args() opt.seed = seed - return opt - return None + else: + opt.prompt = '' + opt.seed = 0 + return opt diff --git a/scripts/invoke.py b/scripts/invoke.py index 84b3835579a..bf6714e5249 100644 --- a/scripts/invoke.py +++ b/scripts/invoke.py @@ -598,7 +598,10 @@ 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'] - img_data = meta['image'] + if 'image' not in meta: + meta = metadata_dumps(opt,seeds=[opt.seed])['image'] + meta['image'] = {} + img_data = meta.get('image') pp = img_data.get('postprocessing',[]) or [] pp.append( {