Skip to content

Fix VAE scale factor for Stable Diffusion XL #79

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions Diffusion/Common/Pipeline/Pipeline.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ class Pipeline {
let pipeline: StableDiffusionPipelineProtocol
let maxSeed: UInt32

var isXL: Bool {
if #available(macOS 14.0, iOS 17.0, *) {
return (pipeline as? StableDiffusionXLPipeline) != nil
}
return false
}

var progress: StableDiffusionProgress? = nil {
didSet {
progressPublisher.value = progress
Expand Down Expand Up @@ -81,6 +88,10 @@ class Pipeline {
config.disableSafety = disableSafety
config.schedulerType = scheduler.asStableDiffusionScheduler()
config.useDenoisedIntermediates = true
if isXL {
config.encoderScaleFactor = 0.13025
config.decoderScaleFactor = 0.13025
}

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