From 2e4d996fc03d89e19ade9835c33e4197001d5599 Mon Sep 17 00:00:00 2001 From: Yasuhito Nagatomo Date: Mon, 16 Jan 2023 11:45:50 +0900 Subject: [PATCH] Commented out the specifying the MLModelConfiguration.computeUnits --- README.md | 3 +++ imggensd2.xcodeproj/project.pbxproj | 16 ++++++++-------- imggensd2/ImageGenerator.swift | 15 +++++++++++---- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 3911be8..c396e31 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,9 @@ You can see how it works through the simple sample code. ![Image](images/ss0_1280.png) ## Change Log +- [1.2.2 (8)] - Jan 16, 2023 `[Changed]` + - Commented out the specifying the MLModelConfiguration.computeUnits and changed it to use the default, + because it is not necessary. - [1.2.1 (7)] - Dec 30, 2022 `[Changed]` - Changed the Seed UI from Stepper to TextField and the initial value from 100 to 1_000_000. - [1.2.0 (6)] - Dec 25, 2022 `[Added]` diff --git a/imggensd2.xcodeproj/project.pbxproj b/imggensd2.xcodeproj/project.pbxproj index 3fec43e..0aa9f7c 100644 --- a/imggensd2.xcodeproj/project.pbxproj +++ b/imggensd2.xcodeproj/project.pbxproj @@ -12,7 +12,7 @@ BA03C37C293D785D001426DE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BA03C37B293D785D001426DE /* Assets.xcassets */; }; BA03C37F293D785D001426DE /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BA03C37E293D785D001426DE /* Preview Assets.xcassets */; }; BA03C38D293D8773001426DE /* ImageGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA03C38C293D8773001426DE /* ImageGenerator.swift */; }; - BA1C3AAC295EE70E00D5FB42 /* CoreMLModels in Resources */ = {isa = PBXBuildFile; fileRef = BA1C3AAB295EE70E00D5FB42 /* CoreMLModels */; }; + BA2A0BFF2974E73C0037687E /* CoreMLModels in Resources */ = {isa = PBXBuildFile; fileRef = BA2A0BFE2974E73C0037687E /* CoreMLModels */; }; BA645DB02957E6590037BE76 /* StableDiffusion in Frameworks */ = {isa = PBXBuildFile; productRef = BA645DAF2957E6590037BE76 /* StableDiffusion */; }; /* End PBXBuildFile section */ @@ -24,7 +24,7 @@ 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 = ""; }; BA03C38C293D8773001426DE /* ImageGenerator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageGenerator.swift; sourceTree = ""; }; - BA1C3AAB295EE70E00D5FB42 /* CoreMLModels */ = {isa = PBXFileReference; lastKnownFileType = folder; path = CoreMLModels; sourceTree = ""; }; + BA2A0BFE2974E73C0037687E /* CoreMLModels */ = {isa = PBXFileReference; lastKnownFileType = folder; path = CoreMLModels; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -59,7 +59,7 @@ BA03C376293D785C001426DE /* imggensd2 */ = { isa = PBXGroup; children = ( - BA1C3AAB295EE70E00D5FB42 /* CoreMLModels */, + BA2A0BFE2974E73C0037687E /* CoreMLModels */, BA03C377293D785C001426DE /* imggensd2App.swift */, BA03C379293D785C001426DE /* ContentView.swift */, BA03C38C293D8773001426DE /* ImageGenerator.swift */, @@ -142,7 +142,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - BA1C3AAC295EE70E00D5FB42 /* CoreMLModels in Resources */, + BA2A0BFF2974E73C0037687E /* CoreMLModels in Resources */, BA03C37F293D785D001426DE /* Preview Assets.xcassets in Resources */, BA03C37C293D785D001426DE /* Assets.xcassets in Resources */, ); @@ -305,7 +305,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 7; + CURRENT_PROJECT_VERSION = 8; DEVELOPMENT_ASSET_PATHS = "\"imggensd2/Preview Content\""; DEVELOPMENT_TEAM = J5CY9Q9UP5; ENABLE_PREVIEWS = YES; @@ -321,7 +321,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.2.1; + MARKETING_VERSION = 1.2.2; PRODUCT_BUNDLE_IDENTIFIER = com.atarayosd.imggensd2; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; @@ -336,7 +336,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 7; + CURRENT_PROJECT_VERSION = 8; DEVELOPMENT_ASSET_PATHS = "\"imggensd2/Preview Content\""; DEVELOPMENT_TEAM = J5CY9Q9UP5; ENABLE_PREVIEWS = YES; @@ -352,7 +352,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.2.1; + MARKETING_VERSION = 1.2.2; PRODUCT_BUNDLE_IDENTIFIER = com.atarayosd.imggensd2; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; diff --git a/imggensd2/ImageGenerator.swift b/imggensd2/ImageGenerator.swift index 6edeb15..0703007 100644 --- a/imggensd2/ImageGenerator.swift +++ b/imggensd2/ImageGenerator.swift @@ -74,7 +74,6 @@ final class ImageGenerator: ObservableObject { generatedImages = images } - // swiftlint:disable function_body_length func generateImages(_ parameter: GenerationParameter) { guard generationState == .idle else { return } Task.detached(priority: .high) { @@ -87,9 +86,17 @@ final class ImageGenerator: ObservableObject { let resourceURL = URL(fileURLWithPath: path) let config = MLModelConfiguration() - if !ProcessInfo.processInfo.isiOSAppOnMac { - config.computeUnits = .cpuAndGPU - } + + // [Note] + // Specifying config.computeUnits is not necessary. Use the default. + // + // Specifying config.computeUnits = .cpuAndNeuralEngine will cause an internal fatal error on devices. + // config.computeUnits = .cpuAndNeuralEngine + // + // Specifying config.computeUnits = .cpuAndGPU works on device with no reason. + // if !ProcessInfo.processInfo.isiOSAppOnMac { + // config.computeUnits = .cpuAndGPU + // } // reduceMemory option was added at v0.1.0 // On iOS, the reduceMemory option should be set to true