FahimF / sd-gui

Clean and simple Stable Diffusion GUI for macOS, Windows, and Linux
MIT License
232 stars 17 forks source link

KeyError: 'sample' #23

Closed dnlbrv closed 2 years ago

dnlbrv commented 2 years ago

Hello Fahim. Finally I managed to install everything without errors but when the image is generated it gives me an error and the GUI closes. If you have any ideas I appreciate your help, I'm so close. This is the log:

(ml) dnlbrv@dMBP16 sd-gui % python app.py Output folder exists Type: GeneratorType.txt2img Scheduler: Default Prompt: car in the sky, Canon50 Width: 512 Height: 512 Strength: 0.6 Num Stpes: 99 Guidance: 7.5 Copies: 1 Seed: -1 Seed for new image: 14014266794435115304 100%|███████████████████████████████████████████████████████████████████| 100/100 [01:21<00:00, 1.22it/s] Traceback (most recent call last): File "/Users/dnlbrv/sd-gui/ui/base_tab.py", line 21, in generate image, self.parent.is_nsfw, self.parent.seed = self.parent.sd.generate(cfg.prompt.prompt, cfg.width, cfg.height, cfg.seed, File "/Users/dnlbrv/sd-gui/tools/sd_engine.py", line 83, in generate img = result["sample"][0] File "/Users/dnlbrv/miniconda3/envs/ml/lib/python3.9/site-packages/diffusers/utils/outputs.py", line 88, in getitem return inner_dict[k] KeyError: 'sample' zsh: abort python app.py (ml) dnlbrv@dMBP16 sd-gui % /Users/dnlbrv/miniconda3/envs/ml/lib/python3.9/multiprocessing/resource_tracker.py:216: UserWarning: resource_tracker: There appear to be 1 leaked semaphore objects to clean up at shutdown warnings.warn('resource_tracker: There appear to be %d '

Thanxs in advance.

FahimF commented 2 years ago

Based on the error, it looks as if the issue is coming from diffusers, could you please run the following commands and let me know what the results are?

pip list | grep diff pip list | grep torch

I just want to see what the installed diffusers and PyTorch versions are since the issue would seem to be there.

dnlbrv commented 2 years ago

Thanks, Fahim. Your request:

Last login: Sat Oct 22 09:35:56 on ttys000 (base) dnlbrv@dMBP16 ~ % conda activate invokeai (invokeai) dnlbrv@dMBP16 ~ % cd InvokeAI (invokeai) dnlbrv@dMBP16 InvokeAI % pip list | grep diff k-diffusion 0.0.1 /Users/dnlbrv/InvokeAI/src/k-diffusion torchdiffeq 0.2.3 (invokeai) dnlbrv@dMBP16 InvokeAI % pip list | grep torch pytorch-lightning 1.7.7 torch 1.12.1 torch-fidelity 0.3.0 torchdiffeq 0.2.3 torchmetrics 0.10.0 torchvision 0.13.1 (invokeai) dnlbrv@dMBP16 InvokeAI %

FahimF commented 2 years ago

Based on the output, I don't see diffusers installed at all and you seem to have an older version of PyTorch that wouldn't have the necessary changes to be fully compatible with Apple Silicon.

Are you sure, that you are in the right conda environment? Do note that the your output is for an environment named "invokeai" while my instructions talk about an environment named "ml". It's possible that you used a different environment but checking in case you have the wrong environment.

You might need to follow the installation guide and set up a new clean environment since trying to figure out what is going on in an environment which is a mix of different packages can be a pretty complicated ...

dnlbrv commented 2 years ago

Yes! sorry, this is another environment. The correct data:

(base) dnlbrv@dMBP16 ~ % conda activate ml (ml) dnlbrv@dMBP16 ~ % cd sd-gui (ml) dnlbrv@dMBP16 sd-gui % pip list | grep diff diffusers 0.6.0 (ml) dnlbrv@dMBP16 sd-gui % pip list | grep torch torch 1.14.0.dev20221020 (ml) dnlbrv@dMBP16 sd-gui %

Thanks!

FahimF commented 2 years ago

There appears to have been a change to one of the supporting libraries which broke my code. That was the error your were seeing. So thank you for reporting it.

I've fixed the issue and pushed an update to the repo. If you refresh the code from my repo, it should work for you now.

dnlbrv commented 2 years ago

Do I reinstall your github by cloning the repository again? Whits this lines?: git clone https://github.com/FahimF/sd-gui.git cd sd-gui mkdir output

FahimF commented 2 years ago

Well, you can do that, or you can simply do a git pull 🙂 Just cd into the the sd-gui folder and then run the following:

git pull main

More info here: https://docs.github.com/en/get-started/using-git/getting-changes-from-a-remote-repository#pulling-changes-from-a-remote-repository

dnlbrv commented 2 years ago

Thanks a lot Fahim! now works perfect. Thanks for create and share this tool.

FahimF commented 2 years ago

You're welcome 🙂