InvokeAI/ldm/invoke
Lincoln Stein c8a9848ad6
correct a crash in img2img under particular circumstances (#2088)
When using the inpainting model, the following sequence of events
would cause a predictable crash:

1. Use unified canvas to outcrop a portion of the image.
2. Accept outcropped image and import into img2img
3. Try any img2img operation

This closes #1596.

The crash was:

```
operands could not be broadcast together with shapes (320,512) (512,576)

Traceback (most recent call last):
  File "/data/lstein/InvokeAI/backend/invoke_ai_web_server.py", line 1125, in generate_images
    self.generate.prompt2image(
  File "/data/lstein/InvokeAI/ldm/generate.py", line 492, in prompt2image
    results = generator.generate(
  File "/data/lstein/InvokeAI/ldm/invoke/generator/base.py", line 98, in generate
    image = make_image(x_T)
  File "/data/lstein/InvokeAI/ldm/invoke/generator/omnibus.py", line 138, in make_image
    return self.sample_to_image(samples)
  File "/data/lstein/InvokeAI/ldm/invoke/generator/omnibus.py", line 173, in sample_to_image
    corrected_result = super(Img2Img, self).repaste_and_color_correct(gen_result, self.pil_image, self.pil_mask, self.mask_blur_radius)
  File "/data/lstein/InvokeAI/ldm/invoke/generator/base.py", line 148, in repaste_and_color_correct
    mask_pixels = init_a_pixels * init_mask_pixels > 0
ValueError: operands could not be broadcast together with shapes (320,512) (512,576)
```

This error was caused by the image and its mask not being of identical
size due to the outcropping operation. The ultimate cause of this
error has something to do with different code paths being followed in
the `inpaint` vs the `omnibus` modules.

Since omnibus will be obsoleted by diffusers, I have chosen just to
work around the problem rather than track it down to its source. The
only ill effect is that color correction will not be applied to the
first image created by `img2img` after applying the outcrop and
immediately importing into the img2img canvas. Since the inpainting
model has less of a color drift problem than the standard model, this
is unlikely to be problematic.
2022-12-22 14:53:23 +00:00
..
generator correct a crash in img2img under particular circumstances (#2088) 2022-12-22 14:53:23 +00:00
restoration Global replace [ \t]+$, add "GB" (#1751) 2022-12-19 16:36:39 +00:00
__init__.py add --version to invoke.py arguments (#2038) 2022-12-20 15:14:28 +00:00
args.py add --version to invoke.py arguments (#2038) 2022-12-20 15:14:28 +00:00
CLI.py add --version to invoke.py arguments (#2038) 2022-12-20 15:14:28 +00:00
concepts_lib.py Global replace [ \t]+$, add "GB" (#1751) 2022-12-19 16:36:39 +00:00
conditioning.py restrict to 75 tokens and correctly handle blends 2022-12-14 16:54:27 -05:00
devices.py rename all modules from ldm.dream to ldm.invoke 2022-10-08 11:37:23 -04:00
globals.py defer patchmatch loading (#2039) 2022-12-20 15:32:35 -08:00
image_util.py Global replace [ \t]+$, add "GB" (#1751) 2022-12-19 16:36:39 +00:00
log.py rename all modules from ldm.dream to ldm.invoke 2022-10-08 11:37:23 -04:00
model_cache.py Global replace [ \t]+$, add "GB" (#1751) 2022-12-19 16:36:39 +00:00
patchmatch.py defer patchmatch loading (#2039) 2022-12-20 15:32:35 -08:00
pngwriter.py correct bug when trying to enhance JPG images (#1928) 2022-12-11 13:48:47 -05:00
prompt_parser.py Save and display per-token attention maps (#1866) 2022-12-10 15:57:41 +01:00
readline.py Save and display per-token attention maps (#1866) 2022-12-10 15:57:41 +01:00
seamless.py Global replace [ \t]+$, add "GB" (#1751) 2022-12-19 16:36:39 +00:00
server_legacy.py Global replace [ \t]+$, add "GB" (#1751) 2022-12-19 16:36:39 +00:00
server.py Global replace [ \t]+$, add "GB" (#1751) 2022-12-19 16:36:39 +00:00
txt2mask.py Global replace [ \t]+$, add "GB" (#1751) 2022-12-19 16:36:39 +00:00