leejet / stable-diffusion.cpp

Stable Diffusion and Flux in pure C/C++
MIT License
3.27k stars 275 forks source link

Stable Diffusion with LCM on Mac OS(Metal) produces black image #143

Open GaidamakUA opened 8 months ago

GaidamakUA commented 8 months ago

This command is working fine, even though it's kind of slow 16 s/it ./bin/sd -M txt2img -m ../models/checkpoints/reliberate_v20.safetensors -p "Two girls playing tennis" This command produces black images, but iterates faster 8 s/it ./bin/sd -M txt2img -m ../models/checkpoints/reliberate_v20.safetensors -p "Two girls playing tennis<lora:lcm_lora_1.5:1>" --lora-model-dir ../models/loras --steps 4 -v --cfg-scale 1 --sampling-method lcm I don't know if it's relevant but it gives me this output

save result image to 'output.png'
ggml_metal_free: deallocating
sd(31476,0x1d9e69000) malloc: *** error for object 0x10f800000: pointer being freed was not allocated
sd(31476,0x1d9e69000) malloc: *** set a breakpoint in malloc_error_break to debug
zsh: abort      ./bin/sd -M txt2img -m  -p "Two girls playing tennis<lora:lcm_lora_1.5:1>"
yosefl20 commented 8 months ago

I fixed it by downloading the fixed vae model following this:

SD1.x, SD2.x and SDXL support

!!!The VAE in SDXL encounters NaN issues under FP16, but unfortunately, the ggml_conv_2d only operates under FP16. Hence, a parameter is needed to specify the VAE that has fixed the FP16 NaN issue. You can find it here: SDXL VAE FP16 Fix.

you may try. However, I got a very strange colored image with that vae.