Closed daniel-hmc closed 9 months ago
Black images normally hint at fp16/fp32 issues when SDXL produces nan's during generation / VAE.
I don't have the hardware available you're using but a M1 Macbook Pro 16'' 2021 32GB, where image generation is not an issue.
I'm fairly certain this is not a general Fooocus but an individual issue.
--vae-in-fp32
should work here but it seems you've already tried this. Can you pelase check if you're able to use any other model successfully, e.g. --preset sai
(with and without refiner)?
--preset sai --vae-in-fp32
--> same black image issue.
--preset sai
--> same black image issue.
--preset realistic
--> same black image issue.
Please enlighten me on the term "refiner". What is it and how can I enable/disable this?
If this is an individual issue, where (in general) would I need to look for the root cause, if not in Fooocus code? Would a solution be a workaround to be put in Fooocus code, or how would one deal with such an issue?
Refiner: https://huggingface.co/stabilityai/stable-diffusion-xl-refiner-1.0 + https://github.com/lllyasviel/Fooocus/discussions/830#discussioncomment-8363727
Basically switching the model mid-rendering. This is enabled in Preset sai but not mandatory, jsut to keep an eye on.
Please check if --all-in-fp32
helps.
--all-in-fp32
--> same black image issue
I now tried with above parameter with and without a refiner set in model tab. Without: juggernautXL With: Model sd-xl-base, refiner: sd-xl-refiner --> Both variants same black image issue.
Aw snap, hoped that would fix it... 😑 There are also related issues, but as far as i know no real solutions, sorry:
same here
does anyone know how to use https://github.com/apple/ml-stable-diffusion with this project ?
Guess what? Today I upgraded from macOS Monterey 12.6.1 to Sonoma 14.3 and now image generation seems to be reliable with GPU at high performance about 4s/it.
Just with:
python entry_with_update.py --disable-offload-from-vram
So this ticket can be closed I guess.
@daniel-hmc great to hear, thank you for your feedback!
Read Troubleshoot
[x] I admit that I have read the Troubleshoot before making this issue.
Describe the problem
Fooocus 2.1.864 Python 3.10.13 macOS 12.6.1 <-- CULPRIT! After upgrade to Sonoma (macOS 14.3) I can now generate images at 4s/it using GPU (without --always-cpu). :) Hardware: MacBook Pro 14" 2021, CPU M1 Max, 64GB RAM
By default (no command line parameters), when beginning to generate images in Fooocus, the first iterations appear normal, then suddenly preview becomes black and final output is also a black image. This is 99% reproducible. In very rare cases the image is generated correctly. Performance is good with abt. 5s/it.
Workaround
With --always-cpu this black image issue can be avoided, images are generated 100% reliably. However, performance degrades heavily to abt. 30s/it.
Debugging attempts
So I tried to debug the black image issue. Here are my findings. I am not an AI expert nor a Python expert, hence I got stuck soon.
Error message in log in the moment the first image turns black is
So I inserted debug output for x0 (which is the source for x_sample) in core.py before line 257 before any further processing of the tensor x0:
And it turned out that in the moment the first image in preview turns black, x0 begins to only contain "NaN" values:
Normal output immediately before error:
First output after error occured:
When I tried to find the source of these NaN values, I could not find occurrences in the whole Fooocus tree where this function "preview_function" is called. (I'm not a developer... sorry)
So since the x0 tensor is processed in that function with VAE things (I don't know what this is, though), I tried various vae-related command line parameters:
but none of them solved the issue. Same result as before.
This is where I got stuck. Maybe someone can pick up here and debug further to find the root cause? I am glad to make any further tests, if you tell me which ones.
Further info
...that might or might not be relevant:
Info from log output that might be relevant:
I tried various other command line parameters that do not seem to make any difference. However, I didn't try any possible combination of course:
Full Console Log
Paste full console log here. You will make our job easier if you give a full log.
Okay :)