Edited readme: changing to SD v2.1

main
Yasuhito Nagatomo 2 years ago
parent 53bcef5581
commit 6dd439fc06

@ -45,21 +45,22 @@ You can see how it works through the simple sample code.
## Convert CoreML models ## Convert CoreML models
Convert the PyTorch SD2 model to CoreML models, following Apple's instructions. Convert the PyTorch SD2.1 model to CoreML models, following Apple's instructions.
(https://github.com/apple/ml-stable-diffusion) (https://github.com/apple/ml-stable-diffusion)
```bash ```bash
# create a Python environment and install dependencies # create a Python environment and install dependencies
% conda create -n coremlsd2_38 python=3.8 -y % conda create -n coremlsd2_38 python=3.8 -y
% conda activate coremlsd2_38 % conda activate coremlsd2_38
% cd SD2ModelConvChunked % mkdir SD21ModelConvChunked
% cd SD21ModelConvChunked
% git clone https://github.com/apple/ml-stable-diffusion % git clone https://github.com/apple/ml-stable-diffusion
% cd ml-stable-diffusion % cd ml-stable-diffusion
pip install -e . pip install -e .
``` ```
Visit the Hugging Face Hub - stabilityai/stable-diffusion-2 model's page. Visit the Hugging Face Hub - stabilityai/stable-diffusion-2-1-base model's page.
https://huggingface.co/stabilityai/stable-diffusion-2 (https://huggingface.co/stabilityai/stable-diffusion-2-1-base)
Check the Terms and Use and accept it. Then you can use the model. Check the Terms and Use and accept it. Then you can use the model.
And you need a Hugging Face's `User Access Token`, to download huggingface/models. And you need a Hugging Face's `User Access Token`, to download huggingface/models.
@ -71,7 +72,7 @@ Please visit Hugging Face's site and make an access token at Account Settings.
Token: # <- input your Access Token Token: # <- input your Access Token
``` ```
Download and convert the SD2 PyTorch model to CoreML models. Download and convert the SD2.1 PyTorch model to CoreML models.
If you do this on a Mac/8GB memory, please close all running apps except Terminal, If you do this on a Mac/8GB memory, please close all running apps except Terminal,
otherwise the converter will be killed due to memory issues. otherwise the converter will be killed due to memory issues.
@ -82,7 +83,7 @@ Use these options:
- `--attention-implementation SPLIT_EINSUM` ... use SPLIT_EINSUM for Apple Neural Engine(ANE). - `--attention-implementation SPLIT_EINSUM` ... use SPLIT_EINSUM for Apple Neural Engine(ANE).
```bash ```bash
python -m python_coreml_stable_diffusion.torch2coreml --convert-unet --convert-text-encoder --convert-vae-decoder --convert-safety-checker -o sd2CoremlChunked --model-version stabilityai/stable-diffusion-2-base --bundle-resources-for-swift-cli --chunk-unet --attention-implementation SPLIT_EINSUM --compute-unit CPU_AND_NE python -m python_coreml_stable_diffusion.torch2coreml --convert-unet --convert-text-encoder --convert-vae-decoder --convert-safety-checker -o sd2CoremlChunked --model-version stabilityai/stable-diffusion-2-1-base --bundle-resources-for-swift-cli --chunk-unet --attention-implementation SPLIT_EINSUM --compute-unit CPU_AND_NE
``` ```
How to add Core ML model files to Xcode project: How to add Core ML model files to Xcode project:

@ -11,8 +11,8 @@
BA03C37A293D785C001426DE /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA03C379293D785C001426DE /* ContentView.swift */; }; BA03C37A293D785C001426DE /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA03C379293D785C001426DE /* ContentView.swift */; };
BA03C37C293D785D001426DE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BA03C37B293D785D001426DE /* Assets.xcassets */; }; BA03C37C293D785D001426DE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BA03C37B293D785D001426DE /* Assets.xcassets */; };
BA03C37F293D785D001426DE /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BA03C37E293D785D001426DE /* Preview Assets.xcassets */; }; BA03C37F293D785D001426DE /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BA03C37E293D785D001426DE /* Preview Assets.xcassets */; };
BA03C388293D80A4001426DE /* CoreMLModels in Resources */ = {isa = PBXBuildFile; fileRef = BA03C387293D80A4001426DE /* CoreMLModels */; };
BA03C38D293D8773001426DE /* ImageGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA03C38C293D8773001426DE /* ImageGenerator.swift */; }; BA03C38D293D8773001426DE /* ImageGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA03C38C293D8773001426DE /* ImageGenerator.swift */; };
BA07E4C5295530180021EC77 /* CoreMLModels in Resources */ = {isa = PBXBuildFile; fileRef = BA07E4C4295530180021EC77 /* CoreMLModels */; };
BA1E84232952ED66001701EA /* StableDiffusion in Frameworks */ = {isa = PBXBuildFile; productRef = BA1E84222952ED66001701EA /* StableDiffusion */; }; BA1E84232952ED66001701EA /* StableDiffusion in Frameworks */ = {isa = PBXBuildFile; productRef = BA1E84222952ED66001701EA /* StableDiffusion */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
@ -23,8 +23,8 @@
BA03C37B293D785D001426DE /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; BA03C37B293D785D001426DE /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
BA03C37E293D785D001426DE /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; }; BA03C37E293D785D001426DE /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
BA03C386293D7CE5001426DE /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; }; BA03C386293D7CE5001426DE /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
BA03C387293D80A4001426DE /* CoreMLModels */ = {isa = PBXFileReference; lastKnownFileType = folder; path = CoreMLModels; sourceTree = "<group>"; };
BA03C38C293D8773001426DE /* ImageGenerator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageGenerator.swift; sourceTree = "<group>"; }; BA03C38C293D8773001426DE /* ImageGenerator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageGenerator.swift; sourceTree = "<group>"; };
BA07E4C4295530180021EC77 /* CoreMLModels */ = {isa = PBXFileReference; lastKnownFileType = folder; path = CoreMLModels; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
@ -59,10 +59,10 @@
BA03C376293D785C001426DE /* imggensd2 */ = { BA03C376293D785C001426DE /* imggensd2 */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
BA07E4C4295530180021EC77 /* CoreMLModels */,
BA03C377293D785C001426DE /* imggensd2App.swift */, BA03C377293D785C001426DE /* imggensd2App.swift */,
BA03C379293D785C001426DE /* ContentView.swift */, BA03C379293D785C001426DE /* ContentView.swift */,
BA03C38C293D8773001426DE /* ImageGenerator.swift */, BA03C38C293D8773001426DE /* ImageGenerator.swift */,
BA03C387293D80A4001426DE /* CoreMLModels */,
BA03C37B293D785D001426DE /* Assets.xcassets */, BA03C37B293D785D001426DE /* Assets.xcassets */,
BA03C37D293D785D001426DE /* Preview Content */, BA03C37D293D785D001426DE /* Preview Content */,
); );
@ -142,7 +142,7 @@
isa = PBXResourcesBuildPhase; isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
BA03C388293D80A4001426DE /* CoreMLModels in Resources */, BA07E4C5295530180021EC77 /* CoreMLModels in Resources */,
BA03C37F293D785D001426DE /* Preview Assets.xcassets in Resources */, BA03C37F293D785D001426DE /* Preview Assets.xcassets in Resources */,
BA03C37C293D785D001426DE /* Assets.xcassets in Resources */, BA03C37C293D785D001426DE /* Assets.xcassets in Resources */,
); );

Loading…
Cancel
Save