Skip to content
This repository was archived by the owner on Nov 27, 2024. It is now read-only.

Commit 3808599

Browse files
committed
Support LCM variants with no guidance embeds
1 parent f1aff5d commit 3808599

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

OnnxStack.StableDiffusion/Diffusers/LatentConsistency/LatentConsistencyDiffuser.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,10 @@ protected override async Task<DenseTensor<float>> SchedulerStepAsync(IModelOptio
107107

108108
// Get Model metadata
109109
var metadata = _onnxModelService.GetModelMetadata(modelOptions, OnnxModelType.Unet);
110-
110+
111+
// Some LCM variants require no guidance embeds
112+
var guidanceEmbeddingsRequired = metadata.Inputs.Count == 4;
113+
111114
// Loop though the timesteps
112115
var step = 0;
113116
foreach (var timestep in timesteps)
@@ -127,7 +130,8 @@ protected override async Task<DenseTensor<float>> SchedulerStepAsync(IModelOptio
127130
inferenceParameters.AddInputTensor(inputTensor);
128131
inferenceParameters.AddInputTensor(timestepTensor);
129132
inferenceParameters.AddInputTensor(promptEmbeddings.PromptEmbeds);
130-
inferenceParameters.AddInputTensor(guidanceEmbeddings);
133+
if(guidanceEmbeddingsRequired)
134+
inferenceParameters.AddInputTensor(guidanceEmbeddings);
131135
inferenceParameters.AddOutputBuffer(outputDimension);
132136

133137
var results = await _onnxModelService.RunInferenceAsync(modelOptions, OnnxModelType.Unet, inferenceParameters);

0 commit comments

Comments
 (0)