Skip to content

Commit

Permalink
Switch to GuernikaCore
Browse files Browse the repository at this point in the history
- New Scheduler:
  LCM, DPM++ 2M Karras, DPM++ SDE Karras, Euler Ancenstral

- New Model:
  LCM, SDXL Turbo

- New Control
  T2I-Adapter
  • Loading branch information
czkoko committed Feb 17, 2024
1 parent 773e5e9 commit fb463dc
Show file tree
Hide file tree
Showing 95 changed files with 151 additions and 159 deletions.
Empty file modified CHANGELOG.md
100644 → 100755
Empty file.
Empty file modified Info.plist
100644 → 100755
Empty file.
Empty file modified LICENSE
100644 → 100755
Empty file.
69 changes: 25 additions & 44 deletions Mochi Diffusion.xcodeproj/project.pbxproj
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
0386DF8D2950F25500CA4CEB /* GalleryToolbarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0386DF8C2950F25500CA4CEB /* GalleryToolbarView.swift */; };
0388DEB0297B00FC008B1C1C /* CompactSlider in Frameworks */ = {isa = PBXBuildFile; productRef = 0388DEAF297B00FC008B1C1C /* CompactSlider */; };
0395B3112995C70400465B73 /* Scheduler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0395B3102995C70400465B73 /* Scheduler.swift */; };
03ADC8B9299581AF00B2843F /* StableDiffusion in Frameworks */ = {isa = PBXBuildFile; productRef = 03ADC8B8299581AF00B2843F /* StableDiffusion */; };
03B1ACA8295167B900302F54 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03B1ACA7295167B900302F54 /* SettingsView.swift */; };
03CB9D18297399AE0041A4FA /* ImageCommands.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03CB9D17297399AE0041A4FA /* ImageCommands.swift */; };
03D280F2294FD60E00C7D184 /* PromptView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03D280F1294FD60E00C7D184 /* PromptView.swift */; };
Expand All @@ -61,6 +60,7 @@
C1220FC02AFB122F007E5055 /* ImageWellView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1220FBF2AFB122F007E5055 /* ImageWellView.swift */; };
C1ADEC2C2B16957800E142CA /* FolderMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1ADEC2B2B16957800E142CA /* FolderMonitor.swift */; };
D7B03F2029D42F9900DF89DD /* SDModelAttentionType.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7B03F1F29D42F9900DF89DD /* SDModelAttentionType.swift */; };
E45FA5822B7F7E4B009E90F0 /* GuernikaKit in Frameworks */ = {isa = PBXBuildFile; productRef = E45FA5812B7F7E4B009E90F0 /* GuernikaKit */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -140,7 +140,7 @@
buildActionMask = 2147483647;
files = (
036BFC4E294B9FDB00D8AD04 /* Path in Frameworks */,
03ADC8B9299581AF00B2843F /* StableDiffusion in Frameworks */,
E45FA5822B7F7E4B009E90F0 /* GuernikaKit in Frameworks */,
0352E2A5294E2591003FBF25 /* Sparkle in Frameworks */,
0388DEB0297B00FC008B1C1C /* CompactSlider in Frameworks */,
);
Expand Down Expand Up @@ -287,7 +287,6 @@
isa = PBXNativeTarget;
buildConfigurationList = 036BFC43294B9F7600D8AD04 /* Build configuration list for PBXNativeTarget "Mochi Diffusion" */;
buildPhases = (
03074A1C2971C90C004A15DB /* ShellScript */,
036BFC1A294B9F7500D8AD04 /* Sources */,
036BFC1B294B9F7500D8AD04 /* Frameworks */,
036BFC1C294B9F7500D8AD04 /* Resources */,
Expand All @@ -301,7 +300,7 @@
036BFC4D294B9FDB00D8AD04 /* Path */,
0352E2A4294E2591003FBF25 /* Sparkle */,
0388DEAF297B00FC008B1C1C /* CompactSlider */,
03ADC8B8299581AF00B2843F /* StableDiffusion */,
E45FA5812B7F7E4B009E90F0 /* GuernikaKit */,
);
productName = "Mochi Diffusion";
productReference = 036BFC1E294B9F7500D8AD04 /* Mochi Diffusion.app */;
Expand All @@ -315,7 +314,7 @@
attributes = {
BuildIndependentTargetsInParallel = 1;
LastSwiftUpdateCheck = 1420;
LastUpgradeCheck = 1430;
LastUpgradeCheck = 1510;
TargetAttributes = {
036BFC1D294B9F7500D8AD04 = {
CreatedOnToolsVersion = 14.2;
Expand Down Expand Up @@ -370,7 +369,7 @@
036BFC4C294B9FDB00D8AD04 /* XCRemoteSwiftPackageReference "Path.swift" */,
0352E2A3294E2591003FBF25 /* XCRemoteSwiftPackageReference "Sparkle" */,
0388DEAE297B00FC008B1C1C /* XCRemoteSwiftPackageReference "CompactSlider" */,
03ADC8B7299581AF00B2843F /* XCRemoteSwiftPackageReference "ml-stable-diffusion" */,
E45FA5802B7F7E4B009E90F0 /* XCRemoteSwiftPackageReference "GuernikaKit" */,
);
productRefGroup = 036BFC1F294B9F7500D8AD04 /* Products */;
projectDirPath = "";
Expand All @@ -395,27 +394,6 @@
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
03074A1C2971C90C004A15DB /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "export PATH=\"$PATH:/opt/homebrew/bin\"\nif which swiftlint > /dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n";
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
036BFC1A294B9F7500D8AD04 /* Sources */ = {
isa = PBXSourcesBuildPhase;
Expand Down Expand Up @@ -512,7 +490,6 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = arm64;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
Expand Down Expand Up @@ -547,6 +524,7 @@
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
Expand Down Expand Up @@ -576,7 +554,6 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = arm64;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
Expand Down Expand Up @@ -611,6 +588,7 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
Expand All @@ -622,6 +600,7 @@
MACOSX_DEPLOYMENT_TARGET = 14.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_EMIT_LOC_STRINGS = YES;
Expand All @@ -636,12 +615,13 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = "Mochi Diffusion/App.entitlements";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 5.0;
CURRENT_PROJECT_VERSION = 6.0;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"Mochi Diffusion/Preview Content\"";
DEVELOPMENT_TEAM = TCQ6328PP6;
DEVELOPMENT_TEAM = "";
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -653,7 +633,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 5.0;
MARKETING_VERSION = 6.0;
PRODUCT_BUNDLE_IDENTIFIER = "com.joshua-park.Mochi-Diffusion";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -669,12 +649,13 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = "Mochi Diffusion/App.entitlements";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 5.0;
CURRENT_PROJECT_VERSION = 6.0;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"Mochi Diffusion/Preview Content\"";
DEVELOPMENT_TEAM = TCQ6328PP6;
DEVELOPMENT_TEAM = "";
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -686,7 +667,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 5.0;
MARKETING_VERSION = 6.0;
PRODUCT_BUNDLE_IDENTIFIER = "com.joshua-park.Mochi-Diffusion";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -743,12 +724,12 @@
minimumVersion = 1.0.0;
};
};
03ADC8B7299581AF00B2843F /* XCRemoteSwiftPackageReference "ml-stable-diffusion" */ = {
E45FA5802B7F7E4B009E90F0 /* XCRemoteSwiftPackageReference "GuernikaKit" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/apple/ml-stable-diffusion";
repositoryURL = "https://github.com/GuernikaCore/GuernikaKit.git";
requirement = {
branch = main;
kind = branch;
kind = upToNextMajorVersion;
minimumVersion = 1.5.0;
};
};
/* End XCRemoteSwiftPackageReference section */
Expand All @@ -769,10 +750,10 @@
package = 0388DEAE297B00FC008B1C1C /* XCRemoteSwiftPackageReference "CompactSlider" */;
productName = CompactSlider;
};
03ADC8B8299581AF00B2843F /* StableDiffusion */ = {
E45FA5812B7F7E4B009E90F0 /* GuernikaKit */ = {
isa = XCSwiftPackageProductDependency;
package = 03ADC8B7299581AF00B2843F /* XCRemoteSwiftPackageReference "ml-stable-diffusion" */;
productName = StableDiffusion;
package = E45FA5802B7F7E4B009E90F0 /* XCRemoteSwiftPackageReference "GuernikaKit" */;
productName = GuernikaKit;
};
/* End XCSwiftPackageProductDependency section */
};
Expand Down
Empty file.
Empty file.
31 changes: 20 additions & 11 deletions Mochi Diffusion.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
}
},
{
"identity" : "ml-stable-diffusion",
"identity" : "guernikakit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/ml-stable-diffusion",
"location" : "https://github.com/GuernikaCore/GuernikaKit.git",
"state" : {
"branch" : "main",
"revision" : "d456a972cd7d84cab2ec353a29896d59b8602248"
"revision" : "2c1ce26535279b309149acba47ae65e6a9394cb5",
"version" : "1.5.0"
}
},
{
Expand All @@ -28,22 +28,31 @@
}
},
{
"identity" : "sparkle",
"identity" : "randomgenerator",
"kind" : "remoteSourceControl",
"location" : "https://github.com/sparkle-project/Sparkle",
"location" : "https://github.com/GuernikaCore/RandomGenerator.git",
"state" : {
"revision" : "47d3d90aee3c52b6f61d04ceae426e607df62347",
"version" : "2.5.2"
"revision" : "7c91e2f454ecc753075a526cf5ffc34d3c4a10c5",
"version" : "1.0.0"
}
},
{
"identity" : "swift-argument-parser",
"identity" : "schedulers",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser.git",
"location" : "https://github.com/GuernikaCore/Schedulers.git",
"state" : {
"revision" : "fddd1c00396eed152c45a46bea9f47b98e59301d",
"revision" : "5e6ab9fa91aa56fc34edc6bae9de1caa7f13deb8",
"version" : "1.2.0"
}
},
{
"identity" : "sparkle",
"kind" : "remoteSourceControl",
"location" : "https://github.com/sparkle-project/Sparkle",
"state" : {
"revision" : "47d3d90aee3c52b6f61d04ceae426e607df62347",
"version" : "2.5.2"
}
}
],
"version" : 2
Expand Down
2 changes: 1 addition & 1 deletion Mochi Diffusion.xcodeproj/xcshareddata/xcschemes/Mochi Diffusion.xcscheme
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
LastUpgradeVersion = "1510"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Empty file.
Empty file modified Mochi Diffusion/App.entitlements
100644 → 100755
Empty file.
Empty file modified Mochi Diffusion/App.swift
100644 → 100755
Empty file.
Empty file modified Mochi Diffusion/Main Menu/AppCommands.swift
100644 → 100755
Empty file.
Empty file modified Mochi Diffusion/Main Menu/FileCommands.swift
100644 → 100755
Empty file.
Empty file modified Mochi Diffusion/Main Menu/HelpCommands.swift
100644 → 100755
Empty file.
Empty file modified Mochi Diffusion/Main Menu/ImageCommands.swift
100644 → 100755
Empty file.
Empty file modified Mochi Diffusion/Model/ImageStore.swift
100644 → 100755
Empty file.
Empty file modified Mochi Diffusion/Model/Metadata.swift
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion Mochi Diffusion/Model/SDControlNet.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private func identifyControlNetSize(_ url: URL) -> CGSize? {
return nil
}

guard let controlnetCond = inputSchema.first(where: { ($0["name"] as? String) == "controlnet_cond" }) else {
guard let controlnetCond = inputSchema.first(where: { ($0["name"] as? String) == "controlnet_cond" }) ?? inputSchema.first(where: { ($0["name"] as? String) == "input" }) else {
print("Error: 'controlnet_cond' not found in 'inputSchema'")
return nil
}
Expand Down
8 changes: 4 additions & 4 deletions Mochi Diffusion/Model/SDImage.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import AppKit
import CoreGraphics
import CoreML
import Foundation
import StableDiffusion
import GuernikaKit
import UniformTypeIdentifiers

struct SDImage: Identifiable, Hashable {
Expand All @@ -21,11 +21,11 @@ struct SDImage: Identifiable, Hashable {
var height: Int { self.image?.height ?? 0 }
var aspectRatio: CGFloat = 0.0
var model = ""
var scheduler = Scheduler.dpmSolverMultistepScheduler
var scheduler = Scheduler.dpmSolverMultistepKarras
var mlComputeUnit: MLComputeUnits?
var seed: UInt32 = 0
var steps = 28
var guidanceScale = 11.0
var steps = 15
var guidanceScale = 5.0
var generatedDate = Date()
var upscaler = ""
var isUpscaling = false
Expand Down
Empty file modified Mochi Diffusion/Model/SDModel.swift
100644 → 100755
Empty file.
Empty file modified Mochi Diffusion/Model/SDModelAttentionType.swift
100644 → 100755
Empty file.
28 changes: 20 additions & 8 deletions Mochi Diffusion/Model/Scheduler.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,33 @@
// Created by Joshua Park on 2/9/23.
//

import StableDiffusion
import Schedulers

/// Schedulers compatible with StableDiffusionPipeline
enum Scheduler: String, CaseIterable {
/// Scheduler that uses a pseudo-linear multi-step (PLMS) method
case pndmScheduler = "PNDM"
case lcm = "LCM"
/// Scheduler that uses a second order DPM-Solver++ algorithm
case dpmSolverMultistepScheduler = "DPM-Solver++"
case dpmSolverMultistep = "DPM++ 2M"

case dpmSolverMultistepKarras = "DPM++ 2M Karras"

case dpmSolverSinglestepKarras = "DPM++ SDE Karras"

case eulerAncenstralDiscrete = "Euler Ancenstral"
}

func convertScheduler(_ scheduler: Scheduler) -> StableDiffusionScheduler {
func convertScheduler(_ scheduler: Scheduler) -> Schedulers {
switch scheduler {
case .pndmScheduler:
return StableDiffusionScheduler.pndmScheduler
case .dpmSolverMultistepScheduler:
return StableDiffusionScheduler.dpmSolverMultistepScheduler
case .lcm:
return Schedulers.lcm
case .dpmSolverMultistep:
return Schedulers.dpmSolverMultistep
case .dpmSolverMultistepKarras:
return Schedulers.dpmSolverMultistepKarras
case .dpmSolverSinglestepKarras:
return Schedulers.dpmSolverSinglestepKarras
case .eulerAncenstralDiscrete:
return Schedulers.eulerAncenstralDiscrete
}
}
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Empty file modified Mochi Diffusion/Resources/Assets.xcassets/Contents.json
100644 → 100755
Empty file.
Empty file.
Empty file.
Empty file.
Empty file modified Mochi Diffusion/Resources/RealESRGAN.mlmodel
100644 → 100755
Empty file.
Empty file modified Mochi Diffusion/Support/CVPixelBuffer+Create.swift
100644 → 100755
Empty file.
Empty file modified Mochi Diffusion/Support/CVPixelBuffer+Resize.swift
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion Mochi Diffusion/Support/Extensions.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import CompactSlider
import CoreML
import StableDiffusion
import GuernikaKit
import SwiftUI
import UniformTypeIdentifiers

Expand Down
Empty file modified Mochi Diffusion/Support/FocusController.swift
100644 → 100755
Empty file.
Empty file modified Mochi Diffusion/Support/FolderMonitor.swift
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion Mochi Diffusion/Support/Functions.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import AppKit
import CoreGraphics
import CoreML
import Foundation
import StableDiffusion
import GuernikaKit
import UniformTypeIdentifiers

func compareVersion(_ thisVersion: String, _ compareTo: String) -> ComparisonResult {
Expand Down
Loading

0 comments on commit fb463dc

Please sign in to comment.