stable-diffusion.cpp icon indicating copy to clipboard operation
stable-diffusion.cpp copied to clipboard

Unable to run PhotoMaker.

Open aalok013 opened this issue 1 year ago • 5 comments

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

aalok013 avatar Sep 15 '24 22:09 aalok013

-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?

bssrdf avatar Sep 16 '24 01:09 bssrdf

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 avatar Sep 16 '24 07:09 aalok013

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.

aalok013 avatar Sep 16 '24 08:09 aalok013

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.

bssrdf avatar Sep 17 '24 01:09 bssrdf

I created a pull request to fix the absolute path problem: https://github.com/leejet/stable-diffusion.cpp/pull/598 However, there's another issue: https://github.com/leejet/stable-diffusion.cpp/issues/566 I was able to workaround it with the suggetion there, but it's not really a fix...

mpulukkinen avatar Feb 13 '25 18:02 mpulukkinen