mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
outcrop improvements, hand-added
This commit is contained in:
parent
7ad2355b1d
commit
ed943bd6c7
@ -105,7 +105,7 @@ invoke> !fix images/vacation.png --outcrop top 128 --new_prompt "family vacation
|
||||
```
|
||||
|
||||
You may also provide a different seed for outcropping to use by passing
|
||||
`-S<seed>`. A seed of "0" will generate a new random seed.
|
||||
`-S<seed>`. A negative seed will generate a new random seed.
|
||||
|
||||
A number of caveats:
|
||||
|
||||
|
@ -563,19 +563,12 @@ class Generate:
|
||||
seed = None
|
||||
prompt = None
|
||||
|
||||
args = metadata_from_png(image_path)
|
||||
if opt.seed is not None:
|
||||
seed = opt.seed
|
||||
elif args.seed >= 0:
|
||||
seed = args.seed
|
||||
else:
|
||||
args = metadata_from_png(image_path)
|
||||
seed = opt.seed or args.seed
|
||||
if seed is None or seed < 0:
|
||||
seed = random.randrange(0, np.iinfo(np.uint32).max)
|
||||
|
||||
if opt.prompt is not None:
|
||||
prompt = opt.prompt
|
||||
else:
|
||||
prompt = args.prompt
|
||||
|
||||
|
||||
prompt = opt.prompt or args.prompt or ''
|
||||
print(f'>> using seed {seed} and prompt "{prompt}" for {image_path}')
|
||||
|
||||
# try to reuse the same filename prefix as the original file.
|
||||
@ -627,7 +620,7 @@ class Generate:
|
||||
opt.seed = seed
|
||||
opt.prompt = prompt
|
||||
|
||||
if len(extend_instructions)>0:
|
||||
if len(extend_instructions) > 0:
|
||||
restorer = Outcrop(image,self,)
|
||||
return restorer.process (
|
||||
extend_instructions,
|
||||
|
@ -63,7 +63,7 @@ class Generator():
|
||||
**kwargs
|
||||
)
|
||||
results = []
|
||||
seed = seed if seed is not None and seed > 0 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)
|
||||
|
||||
|
@ -169,7 +169,7 @@ class Inpaint(Img2Img):
|
||||
# Fill missing areas of original image
|
||||
init_filled = self.tile_fill_missing(
|
||||
self.pil_image.copy(),
|
||||
seed = self.seed,
|
||||
seed = self.seed if self.seed >= 0 else self.new_seed(),
|
||||
tile_size = tile_size
|
||||
)
|
||||
init_filled.paste(init_image, (0,0), init_image.split()[-1])
|
||||
|
@ -28,12 +28,12 @@ class Outcrop(object):
|
||||
self.generate._set_sampler()
|
||||
|
||||
def wrapped_callback(img,seed,**kwargs):
|
||||
preferred_seed = orig_opt.seed if orig_opt.seed> 0 else seed
|
||||
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(
|
||||
orig_opt.prompt,
|
||||
seed = orig_opt.seed if orig_opt.seed>0 else opt.seed,
|
||||
opt.prompt,
|
||||
seed = opt.seed or orig_opt.seed,
|
||||
sampler = self.generate.sampler,
|
||||
steps = opt.steps,
|
||||
cfg_scale = opt.cfg_scale,
|
||||
|
@ -213,7 +213,10 @@ def main_loop(gen, opt):
|
||||
setattr(opt,attr,path)
|
||||
|
||||
# retrieve previous value of seed if requested
|
||||
if opt.seed is not None and opt.seed < 0:
|
||||
# Exception: for postprocess operations negative seed values
|
||||
 # mean "discard the original seed and generate a new one"
|
||||
 # (this is a non-obvious hack and needs to be reworked)
|
||||
 if opt.seed is not None and opt.seed < 0 and operation != 'postprocess':
|
||||
try:
|
||||
opt.seed = last_results[opt.seed][1]
|
||||
print(f'>> Reusing previous seed {opt.seed}')
|
||||
|
Loading…
Reference in New Issue
Block a user