InvokeAI icon indicating copy to clipboard operation
InvokeAI copied to clipboard

Images get automatically resized to 512x512 with img2img after updating

Open theRolento opened this issue 4 years ago • 6 comments

After the last update, whenever i select a 512x768 image in Web UI, it automatically resizes to 512x512

loaded input image of size 512x768 from ./img2img-tmp.png
resized input image to size 512x512
Running DDIM Sampling with 56 timesteps

theRolento avatar Aug 30 '22 21:08 theRolento

Can confirm that images get resized even without --web server

theRolento avatar Aug 30 '22 22:08 theRolento

The interaction between the dimensions of the init image and the width and height arguments changed with the most recent update. The previous behaviour was to ignore the passed image and height completely and to use whatever dimensions the image had (scaled to mutiples of 64). People were complaining that this isn't the way the other forks do it, and so now the init image is rescaled (with its aspect ratio maintained) to whatever width and height are specified. So you can get back to the original behavior by passing -W and -H with the dimensions of the image. The advantage of this is that you can take an arbitrary 2720x1532 JPEG photo and use it as an init image without fussing with it in advance.

But I see your problem. There are a couple of ways to fix this:

  1. A command-line argument that will force the width and height to be taken from the init image, restoring the original behavior.
  2. If you provide just width or height, the other dimension will be chosen so that it preserves the aspect ratio of the init image.

I think (1) is the less confusing alternative.

lstein avatar Aug 31 '22 00:08 lstein

img2img resizing is still not working great even if you enter -W -H

When using the webUI, I used an image that was -W512 -H704. I entered those dimensions in the fields. My image was resized to 512 X 512 with black bars on the sides to maintain the aspect ratio, essentially making it 512 X 372 before upscaling. I don't want lower resolution.

000546 3676962355

When I use the command line img2img and do the exact same thing with the same image, it instead resizes the image to 512 x 512 breaking the aspect ratio and putting on a black background that is the actual dimensions I input in the command line

000547 4193884334

To me it just made way more sense to just output the image exactly as it was. 99% of the time, that's what people want. I have to resize and downscale my images anyways to use with img2img to keep memory usage down.

cvar66 avatar Aug 31 '22 03:08 cvar66

@lstein like @cvar66 mentioned, i have the same problems.

If using the Web UI you can select any W and H in the fields but they don't work, they are bypassed. 512x512 is forced.

If using the console command line (without --web) you can indeed set -W and -H, but the image inside get resized anyway to 512x512 and blackbars added to fill the rest of 512x768, it's forced. As you can see, the two black bars should not be there.

000001 3052443525

theRolento avatar Aug 31 '22 09:08 theRolento

Personally I am used to the workflow of creating an initial image and resizing it manually. I think a boolean option for "A command-line argument that will force the width and height to be taken from the init image, restoring the original behavior" works best here.

Other Idea would be W and H = None by default, 512 if None in txt2img, InitImgSizeW/H if None in img2img

Edit: A recent commit allows the old workflow again

veprogames avatar Aug 31 '22 18:08 veprogames

This was fixed about a week ago. The init image's dimensions are always used for the generated image unless --fit is provided on dream command line. Closing this issue as resolved.

lstein avatar Sep 09 '22 17:09 lstein