From 3cdd7442fe0351a57e9223acc5703c4838be40cd Mon Sep 17 00:00:00 2001 From: Pedro Cuenca Date: Thu, 22 Dec 2022 09:17:04 +0100 Subject: [PATCH] Apply suggestions from review. --- README.md | 63 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 443191a..f108f36 100644 --- a/README.md +++ b/README.md @@ -33,12 +33,12 @@ Python | macOS | Xcode | iPadOS, iOS | :------:|:------:|:------:|:------:| 3.8 | 13.1 | 14.2 | 16.2 | -## Using Converted Weights from Hugging Face Hub +## Using Ready-made Core ML Models from Hugging Face Hub
Click to expand -🤗 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: +🤗 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). * [`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) @@ -46,7 +46,27 @@ Python | macOS | Xcode | iPadOS, iOS | 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 just 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 use the following helper code: +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. + +To clone the repos using `git`, please follow this process: + +**Step 1:** Install the `git lfs` extension for your system. + +`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. + +**Step 2:** Enable `git lfs` by running this command once: + +```bash +git lfs install +``` + +**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: + +```bash +git clone https://huggingface.co/apple/coreml-stable-diffusion-v1-4 +``` + +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: ```Python from huggingface_hub import snapshot_download @@ -78,34 +98,6 @@ print(f"Model downloaded at {model_path}") `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. - -If you prefer to use `git` to clone the repos with all the variants, you need to follow this process: - -**Step 1:** Install the `git lfs` extension for your system. - -`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. - -**Step 2:** Enable `git lfs` by running this command once: - -```bash -git lfs install -``` - -**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: - -```bash -git clone https://huggingface.co/apple/coreml-stable-diffusion-v1-4 -``` - -
- -## Native Swift Demo App - -
- Click to expand - -🤗 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. -
## Converting Models to Core ML @@ -236,6 +228,15 @@ Note that the chunked version of Unet is checked for first. Only if it is not pr +## Example Swift App + +
+ Click to expand + +🤗 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. + +
+ ## Performance Benchmark