You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add brief instructions to download weights from the Hub (apple#10)
* Add brief instructions to download weights from the Hub.
This should be convenient and time-saving for many users.
* Capitalize ORIGINAL.
* Expand git lfs details.
* Make download code robust to symlinks.
coremltools seems to not like symlinks.
* Add mention to demo app.
* Add steps to git lfs process.
* Minor text change.
* Apply suggestions from review.
## <aname="using-converted-weights"></a> Using Ready-made Core ML Models from Hugging Face Hub
37
+
38
+
<details>
39
+
<summary> Click to expand </summary>
40
+
41
+
🤗 Hugging Face ran the [conversion procedure](#converting-models-to-coreml) on the following models and made the Core ML weights publicly available on the Hub. If you would like to convert a version of Stable Diffusion that is not already available on the Hub, please refer to the [Converting Models to Core ML](#converting-models-to-core-ml).
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).
48
+
49
+
There are several variants in each model repository. You may clone the whole repos using `git` and `git lfs` to download all variants, or selectively download the ones you need.
50
+
51
+
To clone the repos using `git`, please follow this process:
52
+
53
+
**Step 1:** Install the `git lfs` extension for your system.
54
+
55
+
`git lfs` stores large files outside the main git repo, and it downloads them from the appropriate server after you clone or checkout. It is available in most package managers, check [the installation page](https://git-lfs.com) for details.
56
+
57
+
**Step 2:** Enable `git lfs` by running this command once:
58
+
59
+
```bash
60
+
git lfs install
61
+
```
62
+
63
+
**Step 3:** Use `git clone` to download a copy of the repo that includes all model variants. For Stable Diffusion version 1.4, you'd issue the following command in your terminal:
If you prefer to download specific variants instead of cloning the repos, you can use the `huggingface_hub` Python library. For example, to do generation in Python using the `ORIGINAL` attention implementation (read [this section](#converting-models-to-core-ml) for details), you could use the following helper code:
70
+
71
+
```Python
72
+
from huggingface_hub import snapshot_download
73
+
from huggingface_hub.file_download import repo_folder_name
`model_path` would be the path in your local filesystem where the checkpoint was saved. Please, refer to [this post](https://huggingface.co/blog/diffusers-coreml) for additional details.
100
+
101
+
</details>
102
+
36
103
## <aname="converting-models-to-coreml"></a> Converting Models to Core ML
37
104
38
105
<details>
@@ -161,6 +228,15 @@ Note that the chunked version of Unet is checked for first. Only if it is not pr
161
228
162
229
</details>
163
230
231
+
## <aname="swift-app"></a> Example Swift App
232
+
233
+
<details>
234
+
<summary> Click to expand </summary>
235
+
236
+
🤗 Hugging Face created an [open-source demo app](https://github.com/huggingface/swift-coreml-diffusers) on top of this library. It's written in native Swift and Swift UI, and runs on macOS, iOS and iPadOS. You can use the code as a starting point for your app, or to see how to integrate this library in your own projects.
0 commit comments