mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
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:
parent
6f9f848345
commit
0b529f0c57
@ -63,7 +63,7 @@ class Generator():
|
||||
**kwargs
|
||||
)
|
||||
results = []
|
||||
seed = seed if seed is not None else self.new_seed()
|
||||
seed = seed if seed is not None and seed > 0 else self.new_seed()
|
||||
first_seed = seed
|
||||
seed, initial_noise = self.generate_initial_noise(seed, width, height)
|
||||
|
||||
|
@ -636,7 +636,7 @@ def split_weighted_subprompts(text, skip_normalize=False)->list:
|
||||
weight_sum = sum(map(lambda x: x[1], parsed_prompts))
|
||||
if weight_sum == 0:
|
||||
print(
|
||||
"Warning: Subprompt weights add up to zero. Discarding and using even weights instead.")
|
||||
"* Warning: Subprompt weights add up to zero. Discarding and using even weights instead.")
|
||||
equal_weight = 1 / max(len(parsed_prompts), 1)
|
||||
return [(x[0], equal_weight) for x in parsed_prompts]
|
||||
return [(x[0], x[1] / weight_sum) for x in parsed_prompts]
|
||||
|
@ -28,11 +28,12 @@ class Outcrop(object):
|
||||
self.generate._set_sampler()
|
||||
|
||||
def wrapped_callback(img,seed,**kwargs):
|
||||
image_callback(img,orig_opt.seed,use_prefix=prefix,**kwargs)
|
||||
preferred_seed = orig_opt.seed if orig_opt.seed> 0 else seed
|
||||
image_callback(img,preferred_seed,use_prefix=prefix,**kwargs)
|
||||
|
||||
result= self.generate.prompt2image(
|
||||
opt.prompt,
|
||||
seed = opt.seed if opt.seed else orig_opt.seed,
|
||||
orig_opt.prompt,
|
||||
seed = orig_opt.seed if orig_opt.seed>0 else opt.seed,
|
||||
sampler = self.generate.sampler,
|
||||
steps = opt.steps,
|
||||
cfg_scale = opt.cfg_scale,
|
||||
|
@ -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
|
||||
@ -668,7 +668,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'] = {}
|
||||
|
Loading…
Reference in New Issue
Block a user