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