From 6dd439fc068e70d0ab7e4f8c9f6171d7b399989c Mon Sep 17 00:00:00 2001 From: Yasuhito Nagatomo Date: Fri, 23 Dec 2022 09:49:53 +0900 Subject: [PATCH] Edited readme: changing to SD v2.1 --- README.md | 13 +++++++------ imggensd2.xcodeproj/project.pbxproj | 8 ++++---- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 570d42a..bc3c60b 100644 --- a/README.md +++ b/README.md @@ -45,21 +45,22 @@ You can see how it works through the simple sample code. ## 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) ```bash # create a Python environment and install dependencies % conda create -n coremlsd2_38 python=3.8 -y % conda activate coremlsd2_38 -% cd SD2ModelConvChunked +% mkdir SD21ModelConvChunked +% cd SD21ModelConvChunked % git clone https://github.com/apple/ml-stable-diffusion % cd ml-stable-diffusion pip install -e . ``` -Visit the Hugging Face Hub - stabilityai/stable-diffusion-2 model's page. -(https://huggingface.co/stabilityai/stable-diffusion-2) +Visit the Hugging Face Hub - stabilityai/stable-diffusion-2-1-base model's page. +(https://huggingface.co/stabilityai/stable-diffusion-2-1-base) 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. @@ -71,7 +72,7 @@ Please visit Hugging Face's site and make an access token at Account Settings. 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, 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). ```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: diff --git a/imggensd2.xcodeproj/project.pbxproj b/imggensd2.xcodeproj/project.pbxproj index 0d4cead..bbf64b7 100644 --- a/imggensd2.xcodeproj/project.pbxproj +++ b/imggensd2.xcodeproj/project.pbxproj @@ -11,8 +11,8 @@ BA03C37A293D785C001426DE /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA03C379293D785C001426DE /* ContentView.swift */; }; BA03C37C293D785D001426DE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BA03C37B293D785D001426DE /* 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 */; }; + BA07E4C5295530180021EC77 /* CoreMLModels in Resources */ = {isa = PBXBuildFile; fileRef = BA07E4C4295530180021EC77 /* CoreMLModels */; }; BA1E84232952ED66001701EA /* StableDiffusion in Frameworks */ = {isa = PBXBuildFile; productRef = BA1E84222952ED66001701EA /* StableDiffusion */; }; /* End PBXBuildFile section */ @@ -23,8 +23,8 @@ BA03C37B293D785D001426DE /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; BA03C37E293D785D001426DE /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; BA03C386293D7CE5001426DE /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; - BA03C387293D80A4001426DE /* CoreMLModels */ = {isa = PBXFileReference; lastKnownFileType = folder; path = CoreMLModels; sourceTree = ""; }; BA03C38C293D8773001426DE /* ImageGenerator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageGenerator.swift; sourceTree = ""; }; + BA07E4C4295530180021EC77 /* CoreMLModels */ = {isa = PBXFileReference; lastKnownFileType = folder; path = CoreMLModels; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -59,10 +59,10 @@ BA03C376293D785C001426DE /* imggensd2 */ = { isa = PBXGroup; children = ( + BA07E4C4295530180021EC77 /* CoreMLModels */, BA03C377293D785C001426DE /* imggensd2App.swift */, BA03C379293D785C001426DE /* ContentView.swift */, BA03C38C293D8773001426DE /* ImageGenerator.swift */, - BA03C387293D80A4001426DE /* CoreMLModels */, BA03C37B293D785D001426DE /* Assets.xcassets */, BA03C37D293D785D001426DE /* Preview Content */, ); @@ -142,7 +142,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - BA03C388293D80A4001426DE /* CoreMLModels in Resources */, + BA07E4C5295530180021EC77 /* CoreMLModels in Resources */, BA03C37F293D785D001426DE /* Preview Assets.xcassets in Resources */, BA03C37C293D785D001426DE /* Assets.xcassets in Resources */, );