mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
outcropping improvements
- catch syntax errors in the outcrop coordinates - work (after a fashion) on non-Invoke generated images
This commit is contained in:
parent
8254ca9492
commit
ce6d618e3b
@ -555,16 +555,19 @@ class Generate:
|
|||||||
from ldm.invoke.restoration.outcrop import Outcrop
|
from ldm.invoke.restoration.outcrop import Outcrop
|
||||||
extend_instructions = {}
|
extend_instructions = {}
|
||||||
for direction,pixels in _pairwise(opt.outcrop):
|
for direction,pixels in _pairwise(opt.outcrop):
|
||||||
extend_instructions[direction]=int(pixels)
|
try:
|
||||||
|
extend_instructions[direction]=int(pixels)
|
||||||
restorer = Outcrop(image,self,)
|
except ValueError:
|
||||||
return restorer.process (
|
print(f'** invalid extension instruction. Use <directions> <pixels>..., as in "top 64 left 128 right 64 bottom 64"')
|
||||||
extend_instructions,
|
if len(extend_instructions)>0:
|
||||||
opt = opt,
|
restorer = Outcrop(image,self,)
|
||||||
orig_opt = args,
|
return restorer.process (
|
||||||
image_callback = callback,
|
extend_instructions,
|
||||||
prefix = prefix,
|
opt = opt,
|
||||||
)
|
orig_opt = args,
|
||||||
|
image_callback = callback,
|
||||||
|
prefix = prefix,
|
||||||
|
)
|
||||||
|
|
||||||
elif tool == 'embiggen':
|
elif tool == 'embiggen':
|
||||||
# fetch the metadata from the image
|
# fetch the metadata from the image
|
||||||
|
@ -973,17 +973,17 @@ def sha256(path):
|
|||||||
return sha.hexdigest()
|
return sha.hexdigest()
|
||||||
|
|
||||||
def legacy_metadata_load(meta,pathname) -> Args:
|
def legacy_metadata_load(meta,pathname) -> Args:
|
||||||
|
opt = Args()
|
||||||
if 'Dream' in meta and len(meta['Dream']) > 0:
|
if 'Dream' in meta and len(meta['Dream']) > 0:
|
||||||
dream_prompt = meta['Dream']
|
dream_prompt = meta['Dream']
|
||||||
opt = Args()
|
|
||||||
opt.parse_cmd(dream_prompt)
|
opt.parse_cmd(dream_prompt)
|
||||||
return opt
|
|
||||||
else: # if nothing else, we can get the seed
|
else: # if nothing else, we can get the seed
|
||||||
match = re.search('\d+\.(\d+)',pathname)
|
match = re.search('\d+\.(\d+)',pathname)
|
||||||
if match:
|
if match:
|
||||||
seed = match.groups()[0]
|
seed = match.groups()[0]
|
||||||
opt = Args()
|
|
||||||
opt.seed = seed
|
opt.seed = seed
|
||||||
return opt
|
else:
|
||||||
return None
|
opt.prompt = ''
|
||||||
|
opt.seed = 0
|
||||||
|
return opt
|
||||||
|
|
||||||
|
@ -636,7 +636,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)
|
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)
|
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']
|
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 = img_data.get('postprocessing',[]) or []
|
||||||
pp.append(
|
pp.append(
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user