ml-stable-diffusion icon indicating copy to clipboard operation
ml-stable-diffusion copied to clipboard

Error when running with Swift CLI: no "merges.txt"?

Open DylanSpeiser opened this issue 3 years ago • 5 comments

Ran the commands in the readme, checked them twice, they succeeded, but generation doesn't work: `% swift run StableDiffusionSample "a photo of an astronaut riding a horse on mars" --resource-path mlpackages/ --seed 93 --output-path outputs/

Building for debugging...

Build complete! (0.10s)

Loading resources and creating pipeline

(Note: This can take a while the first time using these resources)

Error: The file “merges.txt” couldn’t be opened because there is no such file.`

DylanSpeiser avatar Dec 03 '22 19:12 DylanSpeiser

You have to use the option "--bundle-resources-for-swift-cli" then specify that path for the "--resource-path".

3DTOPO avatar Dec 03 '22 20:12 3DTOPO

I have.

DylanSpeiser avatar Dec 03 '22 20:12 DylanSpeiser

What does your "mlpackages" directory look like?

3DTOPO avatar Dec 03 '22 20:12 3DTOPO

When you are using the download script from here https://huggingface.co/blog/diffusers-coreml You have to change line 6 and 7 to the following:

repo_id = "apple/coreml-stable-diffusion-2-base"
variant = "original/compiled"

I guess you have not downloaded the compiled models.

marvpipe avatar Dec 03 '22 22:12 marvpipe

python -m python_coreml_stable_diffusion.torch2coreml --convert-unet --convert-text-encoder --convert-vae-decoder --convert-safety-checker -o ./models --bundle-resources-for-swift-cli

zhaodp avatar Apr 15 '23 04:04 zhaodp