InvokeAI icon indicating copy to clipboard operation
InvokeAI copied to clipboard

txt2img grid contains same repeated for all images

Open Vargol opened this issue 4 years ago • 16 comments

python ./scripts/orig_scripts/txt2img.py --prompt 'they were dark and golden eyed' --W 256 --H 256 --n_sample=2 --n_iter 5 --ddim_steps 5 --seed 999

gave me the same image in grid over and over again.

grid-0010

All saved images are unique

Vargol avatar Aug 31 '22 16:08 Vargol

Did you by chance mean to post this over at https://github.com/basujindal/stable-diffusion ?

Edit: nm I'm just so used to using the dream prompt on this repo 😁

namion avatar Aug 31 '22 16:08 namion

Either way, ./scripts/orig_scripts/txt2img.py is the wrong script

tildebyte avatar Aug 31 '22 16:08 tildebyte

txt2img is being maintained I can see it had a change 12 hours ago.

Vargol avatar Aug 31 '22 16:08 Vargol

Right. That's not the correct script to call. Use scripts/dream.py

tildebyte avatar Aug 31 '22 16:08 tildebyte

I wouldn't rely on txt2img and img2img being maintained here much longer. Support for batch size (n_sample) was recently removed and that's probably causing your problem. Try with --n_iter=10. It'll use much less VRAM.

lstein avatar Aug 31 '22 17:08 lstein

I know, the n_sample 2 was to demonstrate the image is the same across samples.

Is dream.py going to get a full command line then, that is why I use txt2img.py

Vargol avatar Aug 31 '22 17:08 Vargol

What dream.py can do now is to read a series of prompts and switches from standard input or a file, by using the --from_file argument. Internally it uses a simple function call to a library called ldm.simplet2i, and someday soon I'll reimplement txt2img and img2img using that library. This'll make everything more stable and consistent.

lstein avatar Aug 31 '22 17:08 lstein

I still get the same image in the grid without using the n_samples and with n_samples=1

dream.py I've got to wait for PR #256 to be merged :-(

Vargol avatar Aug 31 '22 17:08 Vargol

Are you on a Mac, or on a system without NVIDIA hardware?

tildebyte avatar Aug 31 '22 17:08 tildebyte

Mac, Mac Mini M1 (with 8 GB, 512x512 just about squeezes in there with samples a 1)

Vargol avatar Aug 31 '22 18:08 Vargol

Mac, Mac Mini M1 (with 8 GB, 512x512 just about squeezes in there with samples a 1)

It seems different M1 users are seeing the program fail on their machines. Have you encountered any errors before running the model? or did the model run first try?

cosalexelle avatar Aug 31 '22 18:08 cosalexelle

IIUC Mx/MPS support implementation is a work-in-progess, so you're likely to see bugs.

tildebyte avatar Aug 31 '22 18:08 tildebyte

With this repo taken around 6 hours ago, using txt2img.py, then yes it ran first try

However I don't quite use the standard build instructions, conda seems to cause more issues that it fixes with Apple Silicon. So I'm using a venv and pip to install.

I'm not perfect, kms give me nothing but black images, and I've had one crash so at 512x512, which I'm not sure is an issue with the repo or just me being on the edge memory wise.

Vargol avatar Aug 31 '22 18:08 Vargol

conda seems to cause more issues that it fixes with Apple Silicon. So I'm using a venv and pip to install

You might find something useful in the wiki instructions for using pip to install on Windows (particularly the revised requirements.txt, although numpy and torch are platform-specific). Note that the deps in the wiki are for Python 3.10. If nothing else, I'd offer 'pew' as a fantastic venv manager/util.

tildebyte avatar Aug 31 '22 19:08 tildebyte

So, this look like its a issue with torchvision, maybe just the nightlies, and probably the underlying issue is yet another torch bug.

the make_grid function is broke.

Raised a ticket other there

https://github.com/pytorch/vision/issues/6533

Vargol avatar Sep 01 '22 20:09 Vargol

This can be worked around with

                         if not opt.skip_grid:
-                            all_samples.append(x_samples_ddim)
+                            all_samples.append(x_samples_ddim.to(torch.device("cpu")))

So it does the grid with CPU Tensors

Vargol avatar Sep 02 '22 16:09 Vargol