Skip to content

fit the destination image size to the init image aspect ratio - #230

Closed
lstein wants to merge 3 commits into
mainfrom
initimg-constrains-dimensions
Closed

fit the destination image size to the init image aspect ratio#230
lstein wants to merge 3 commits into
mainfrom
initimg-constrains-dimensions

Conversation

@lstein

@lstein lstein commented Aug 31, 2022

Copy link
Copy Markdown
Collaborator

Users request that the aspect ratio of the init image should constrain the dimensions of the generated image, rather than the other way around. This implements this request in a way that does not increase the overall area (and VRAM requirements) of the generated image.

In addition, there was a bug in how the destination image's dimensions were calculated, and this fixes that.

@cvar66

cvar66 commented Aug 31, 2022

Copy link
Copy Markdown

I tried your code and still having issues. When I use the webUI with a 512 X 704 image and enter those dimensions in the field it resizes my image to 320 X 512.

loaded input image of size 512x704 from ./img2img-tmp.png
resized input image to size 320x512 (use -H to adjust)

At the command line I get this error

Traceback (most recent call last):
File "scripts/dream.py", line 516, in
main()
File "scripts/dream.py", line 95, in main
main_loop(t2i, opt.outdir, opt.prompt_as_dir, cmd_parser, infile)
File "scripts/dream.py", line 178, in main_loop
normalized_prompt = PromptFormatter(t2i, opt).normalize_prompt()
File "e:\stable-diffusion\ldm\dream\pngwriter.py", line 120, in normalize_prompt
switches.append(f'-b{opt.batch_size or t2i.batch_size}')
AttributeError: 'Namespace' object has no attribute 'batch_size'

@lstein

lstein commented Aug 31, 2022

Copy link
Copy Markdown
Collaborator Author

@cvar66 You found two bugs. Thank you!
The web server version should be working now. Please test and let me know what you observe. I hope the behavior will be more intuitive now.

@lstein
lstein requested a review from tildebyte August 31, 2022 05:05
@lstein lstein mentioned this pull request Aug 31, 2022
@cvar66

cvar66 commented Aug 31, 2022

Copy link
Copy Markdown

I just updated with git and now I have a new problem. webUi loaded up fine, but as soon as i hit generate I get this error. Will try the new code when this is fixed.

File "e:\stable-diffusion\ldm\dream\server.py", line 91, in do_POST
pngwriter = PngWriter(
TypeError: init() takes from 2 to 3 positional arguments but 4 were given

@bakkot

bakkot commented Aug 31, 2022

Copy link
Copy Markdown
Contributor

webUi loaded up fine, but as soon as i hit generate I get this error

That's caused by 3be1cee having missed this line, and will be fixed by #231. In the mean time, you can delete the , 1 from the linked line and it should work.

@cvar66

cvar66 commented Aug 31, 2022

Copy link
Copy Markdown

I removed the , 1 and now I get this

File "e:\stable-diffusion\ldm\dream\server.py", line 134, in do_POST
step_writer = PngWriter('./outputs/intermediates/', prompt, 2)
TypeError: init() takes from 2 to 3 positional arguments but 4 were given

@lstein

lstein commented Aug 31, 2022

Copy link
Copy Markdown
Collaborator Author

This PR does the same thing as @blessedcoolant 's PR #229. I'm testing his version now and will use that in preference to this one because he's added checks for more edge cases.

@lstein lstein mentioned this pull request Aug 31, 2022
@lstein
lstein marked this pull request as draft August 31, 2022 13:45
@tildebyte
tildebyte removed their request for review August 31, 2022 17:09
@lstein

lstein commented Aug 31, 2022

Copy link
Copy Markdown
Collaborator Author

Abandoned.

@lstein lstein closed this Aug 31, 2022
@lstein
lstein deleted the initimg-constrains-dimensions branch September 2, 2022 01:29
JPPhoto pushed a commit to JPPhoto/InvokeAI that referenced this pull request Sep 12, 2026
…latency

fix(multi-gpu): cancel mid-step and release VRAM while a peer renders
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants