Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add brief instructions to download weights from the Hub #10

Merged
merged 9 commits into from
Dec 22, 2022
Next Next commit
Add brief instructions to download weights from the Hub.
This should be convenient and time-saving for many users.
  • Loading branch information
pcuenca committed Dec 2, 2022
commit 3e7e06aaa300e7f8a0b3299fd68daf7c47b37e24
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,37 @@ M2 MacBook Air 8GB Latency (s) | 18 | 23 | 23 |
Please see [Important Notes on Performance Benchmarks](#important-notes-on-performance-benchmarks) section for details.


## <a name="using-converted-weights"></a> Using Converted Weights from Hugging Face Hub
pcuenca marked this conversation as resolved.
Show resolved Hide resolved

<details>
<summary> Click to expand </summary>

🤗 Hugging Face ran the [conversion procedure](#converting-models-to-coreml) on the following models and made the Core ML weights publicly available in the Hub:
pcuenca marked this conversation as resolved.
Show resolved Hide resolved

* [`CompVis/stable-diffusion-v1-4`](https://huggingface.co/apple/coreml-stable-diffusion-v1-4)
* [`runwayml/stable-diffusion-v1-5`](https://huggingface.co/apple/coreml-stable-diffusion-v1-5)
* [`stabilityai/stable-diffusion-2-base`](https://huggingface.co/apple/coreml-stable-diffusion-2-base)

If you want to use any of those models you may download the weights and proceed to [generate images with Python](#image-generation-with-python) or [Swift](#image-generation-with-swift).

There are several variants in each model repository. You may clone the whole repos using `git` and `git lfs`, or select the variants you need. For example, to do generation in Python using the `original` attention implementation (read [this section](#converting-models-to-core-ml) for details), you could do something like this:
pcuenca marked this conversation as resolved.
Show resolved Hide resolved
pcuenca marked this conversation as resolved.
Show resolved Hide resolved

pcuenca marked this conversation as resolved.
Show resolved Hide resolved
```Python
from huggingface_hub import snapshot_download

repo_id = "apple/coreml-stable-diffusion-v1-4"
variant = "original/packages"

downloaded = snapshot_download(repo_id, allow_patterns=f"{variant}/*")
```

`downloaded` would be the path in your local filesystem where the model checkpoint was saved.

Please, refer to [this post](https://huggingface.co/blog/diffusers-coreml) for additional details on this process.

</details>


pcuenca marked this conversation as resolved.
Show resolved Hide resolved
## <a name="converting-models-to-coreml"></a> Converting Models to Core ML

<details>
Expand Down