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:
Lincoln Stein
2022-11-08 15:22:32 +00:00
parent 4b5a96501d
commit 5606af5083
5 changed files with 17 additions and 12 deletions

View File

@ -566,12 +566,13 @@ class Generate:
args = metadata_from_png(image_path)
seed = args.seed
prompt = args.prompt
print(f'>> retrieved seed {seed} and prompt "{prompt}" from {image_path}')
if not seed:
print('* Could not recover seed for image. Replacing with 42. This will not affect image quality')
seed = 42
prompt = args.prompt or ''
if seed == 0:
seed = random.randrange(0, np.iinfo(np.uint32).max)
opt.seed = seed
print(f'>> generated new seed {seed} and prompt "{prompt}" for {image_path}')
else:
print(f'>> retrieved seed {seed} and prompt "{prompt}" from {image_path}')
# try to reuse the same filename prefix as the original file.
# we take everything up to the first period