leejet / stable-diffusion.cpp

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

Unable to run PhotoMaker. #411

Open aalok013 opened 2 months ago

aalok013 commented 2 months ago

I'm unable to run photomaker as it is unable to find input image. I'm using bellow command. And I'm using gguf model as safetensors model of photomaker is giving me another error GGML_ASSERT(ggml_nelements(a) == ggml_nelements(b)) failed

./sd\sd.exe -M txt2img -m ./models/Stable-Diffusion/juggernaut_reborn.safetensors -p "a guy img" --sampling-method euler_a --steps 20 --schedule discrete -W 384 -H 384 -b 1 --cfg-scale 7 -s -1 --clip-skip 1 --embd-dir ./models/Embeddings/ --lora-model-dir ./models/Lora/ -t 0 --rng cuda -o ./output/txt2img/39_photo.png --vae-on-cpu --color --stacked-id-embd-dir ./models/PhotoMaker/photomaker-v1.q8_0.gguf --input-id-images-dir ./mage.jpg --normalize-input

I see the following log in console. And I tried using image without extension as shown in the guide as well. But it's not working either.

[WARN ] stable-diffusion.cpp:1200 - Provided PhotoMaker model file, but NO input ID images
[WARN ] stable-diffusion.cpp:1201 - Turn off PhotoMaker
bssrdf commented 2 months ago

-input-id-images-dir expects a directory which contains input images. Try --input-id-images-dir ./ in the command line.

BTW, can you point me to the safetensor version of the photomaker model file that gave the error?

aalok013 commented 1 month ago

I tired changing it to relative path. It's seems to identify the image now. But it's throwing the error.

Command: ./sd\sd.exe -M txt2img -m ./models/Stable-Diffusion/juggernaut_reborn.safetensors -p "a girl img" --sampling-method euler_a --steps 20 --schedule discrete -W 384 -H 384 -b 1 --cfg-scale 7 -s -1 --clip-skip 1 --embd-dir ./models/Embeddings/ --lora-model-dir ./models/Lora/ -t 0 --rng cuda -o F:\SD\sd-cpp-output/txt2img/39_photo.png --vae-on-cpu --color --stacked-id-embd-dir ./models/PhotoMaker/photomaker-v1.q8_0.gguf --input-id-images-dir ./models/PhotoMaker/image --normalize-input

Error: D:\a\stable-diffusion.cpp\stable-diffusion.cpp\ggml\src\ggml.c:4702: GGML_ASSERT(ggml_can_repeat(b, a)) failed

And I tired using the original safetensors file as well. But that's giving another error.

D:\a\stable-diffusion.cpp\stable-diffusion.cpp\ggml\src\ggml.c:5792: GGML_ASSERT(ggml_nelements(a) == ggml_nelements(b)) failed

But this error is different from previous error I got when using safetensors file. It seems there is some problem when I'm using absolute path for photomaker.

I downloaded the model mentioned in the guide. Here is the url

aalok013 commented 1 month ago

I found the issue. It seems the problem is the model. I'm using 1.5 and I have to use SDXL. Although the results are not great, I'm able to run it now. But we still have an issue when using absolute path instead of relative path for PhotoMaker.

Thanks for the help.

bssrdf commented 1 month ago

There maybe a bug in win32 portion of the code to get files from an absolute directory. The Photomaker V1 implementation in SD does not produce high ID fidelity. There is a PR pending which updated to V2. The fidelity improves a lot.