Skip to content
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

Show error message when an old VAE encoder is used #177

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
15 changes: 14 additions & 1 deletion swift/StableDiffusion/pipeline/Encoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,20 @@ public struct Encoder: ResourceManaging {

var inputDescription: MLFeatureDescription {
try! model.perform { model in
model.modelDescription.inputDescriptionsByName["z"]!
guard let zInputDescription = model.modelDescription.inputDescriptionsByName["z"] else {
let modelVersion = model.modelDescription.metadata[MLModelMetadataKey.versionString] ?? "unknown version"
fatalError(
"""

The VAE encoder of this model (\(modelVersion)) is not compatible \
with this version of `ml-stable-diffusion`. Please, convert the VAE encoder again using the latest \
version of this package and following the instructions here: \
https://github.com/apple/ml-stable-diffusion#-converting-models-to-core-ml
We'd appreciate if you could then submit the new VAE encoder as a PR to the repo from which this model \
was downloaded.
""")
}
return zInputDescription
}
}

Expand Down