Skip to content

Commit 4202e12

Browse files
authoredAug 8, 2023
Fix VAE scale factor for Stable Diffusion XL (#79)
Fix vae scale factor for Stable Diffusion XL Colors are much better now. See apple/ml-stable-diffusion@ce8ee78
1 parent 4eab476 commit 4202e12

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed
 

‎Diffusion.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"location" : "https://github.com/apple/ml-stable-diffusion",
1616
"state" : {
1717
"branch" : "main",
18-
"revision" : "8cf34376f9faf87fc6fe63159e5fae6cbbb71de6"
18+
"revision" : "ce8ee78e28613d8a2e4c8b56932b236cb57e7e20"
1919
}
2020
},
2121
{

‎Diffusion/Common/Pipeline/Pipeline.swift

+11
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ class Pipeline {
4343
let pipeline: StableDiffusionPipelineProtocol
4444
let maxSeed: UInt32
4545

46+
var isXL: Bool {
47+
if #available(macOS 14.0, iOS 17.0, *) {
48+
return (pipeline as? StableDiffusionXLPipeline) != nil
49+
}
50+
return false
51+
}
52+
4653
var progress: StableDiffusionProgress? = nil {
4754
didSet {
4855
progressPublisher.value = progress
@@ -81,6 +88,10 @@ class Pipeline {
8188
config.disableSafety = disableSafety
8289
config.schedulerType = scheduler.asStableDiffusionScheduler()
8390
config.useDenoisedIntermediates = true
91+
if isXL {
92+
config.encoderScaleFactor = 0.13025
93+
config.decoderScaleFactor = 0.13025
94+
}
8495

8596
// Evenly distribute previews based on inference steps
8697
let previewIndices = previewIndices(stepCount, previewCount)

0 commit comments

Comments
 (0)
Please sign in to comment.