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
|
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:
|
A number of caveats:
|
||||||
|
|
||||||
|
@ -564,18 +564,11 @@ class Generate:
|
|||||||
prompt = None
|
prompt = None
|
||||||
|
|
||||||
args = metadata_from_png(image_path)
|
args = metadata_from_png(image_path)
|
||||||
if opt.seed is not None:
|
seed = opt.seed or args.seed
|
||||||
seed = opt.seed
|
if seed is None or seed < 0:
|
||||||
elif args.seed >= 0:
|
|
||||||
seed = args.seed
|
|
||||||
else:
|
|
||||||
seed = random.randrange(0, np.iinfo(np.uint32).max)
|
seed = random.randrange(0, np.iinfo(np.uint32).max)
|
||||||
|
|
||||||
if opt.prompt is not None:
|
prompt = opt.prompt or args.prompt or ''
|
||||||
prompt = opt.prompt
|
|
||||||
else:
|
|
||||||
prompt = args.prompt
|
|
||||||
|
|
||||||
print(f'>> using seed {seed} and prompt "{prompt}" for {image_path}')
|
print(f'>> using seed {seed} and prompt "{prompt}" for {image_path}')
|
||||||
|
|
||||||
# try to reuse the same filename prefix as the original file.
|
# try to reuse the same filename prefix as the original file.
|
||||||
@ -627,7 +620,7 @@ class Generate:
|
|||||||
opt.seed = seed
|
opt.seed = seed
|
||||||
opt.prompt = prompt
|
opt.prompt = prompt
|
||||||
|
|
||||||
if len(extend_instructions)>0:
|
if len(extend_instructions) > 0:
|
||||||
restorer = Outcrop(image,self,)
|
restorer = Outcrop(image,self,)
|
||||||
return restorer.process (
|
return restorer.process (
|
||||||
extend_instructions,
|
extend_instructions,
|
||||||
|
@ -63,7 +63,7 @@ class Generator():
|
|||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
results = []
|
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
|
first_seed = seed
|
||||||
seed, initial_noise = self.generate_initial_noise(seed, width, height)
|
seed, initial_noise = self.generate_initial_noise(seed, width, height)
|
||||||
|
|
||||||
|
@ -169,7 +169,7 @@ class Inpaint(Img2Img):
|
|||||||
# Fill missing areas of original image
|
# Fill missing areas of original image
|
||||||
init_filled = self.tile_fill_missing(
|
init_filled = self.tile_fill_missing(
|
||||||
self.pil_image.copy(),
|
self.pil_image.copy(),
|
||||||
seed = self.seed,
|
seed = self.seed if self.seed >= 0 else self.new_seed(),
|
||||||
tile_size = tile_size
|
tile_size = tile_size
|
||||||
)
|
)
|
||||||
init_filled.paste(init_image, (0,0), init_image.split()[-1])
|
init_filled.paste(init_image, (0,0), init_image.split()[-1])
|
||||||
|
@ -28,12 +28,12 @@ class Outcrop(object):
|
|||||||
self.generate._set_sampler()
|
self.generate._set_sampler()
|
||||||
|
|
||||||
def wrapped_callback(img,seed,**kwargs):
|
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)
|
image_callback(img,preferred_seed,use_prefix=prefix,**kwargs)
|
||||||
|
|
||||||
result= self.generate.prompt2image(
|
result= self.generate.prompt2image(
|
||||||
orig_opt.prompt,
|
opt.prompt,
|
||||||
seed = orig_opt.seed if orig_opt.seed>0 else opt.seed,
|
seed = opt.seed or orig_opt.seed,
|
||||||
sampler = self.generate.sampler,
|
sampler = self.generate.sampler,
|
||||||
steps = opt.steps,
|
steps = opt.steps,
|
||||||
cfg_scale = opt.cfg_scale,
|
cfg_scale = opt.cfg_scale,
|
||||||
|
@ -213,7 +213,10 @@ def main_loop(gen, opt):
|
|||||||
setattr(opt,attr,path)
|
setattr(opt,attr,path)
|
||||||
|
|
||||||
# retrieve previous value of seed if requested
|
# 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:
|
try:
|
||||||
opt.seed = last_results[opt.seed][1]
|
opt.seed = last_results[opt.seed][1]
|
||||||
print(f'>> Reusing previous seed {opt.seed}')
|
print(f'>> Reusing previous seed {opt.seed}')
|
||||||
|
Loading…
Reference in New Issue
Block a user