apple / ml-stable-diffusion

Stable Diffusion with Core ML on Apple Silicon
MIT License
16.51k stars 890 forks source link

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

Open DylanSpeiser opened 1 year ago

DylanSpeiser commented 1 year ago

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.`

3DTOPO commented 1 year ago

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

DylanSpeiser commented 1 year ago

I have.

3DTOPO commented 1 year ago

What does your "mlpackages" directory look like?

marvpipe commented 1 year ago

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.

zhaodp commented 1 year ago

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