@@ -60,7 +60,7 @@ protected override async Task<DenseTensor<float>> SchedulerStepAsync(StableDiffu
60
60
var metadata = _onnxModelService . GetModelMetadata ( modelOptions , OnnxModelType . Unet ) ;
61
61
62
62
// Get Time ids
63
- var addTimeIds = GetAddTimeIds ( modelOptions , schedulerOptions , performGuidance ) ;
63
+ var addTimeIds = GetAddTimeIds ( modelOptions , schedulerOptions ) ;
64
64
65
65
// Loop though the timesteps
66
66
var step = 0 ;
@@ -74,6 +74,7 @@ protected override async Task<DenseTensor<float>> SchedulerStepAsync(StableDiffu
74
74
var inputLatent = performGuidance ? latents . Repeat ( 2 ) : latents ;
75
75
var inputTensor = scheduler . ScaleInput ( inputLatent , timestep ) ;
76
76
var timestepTensor = CreateTimestepTensor ( timestep ) ;
77
+ var timeids = performGuidance ? addTimeIds . Repeat ( 2 ) : addTimeIds ;
77
78
78
79
var outputChannels = performGuidance ? 2 : 1 ;
79
80
var outputDimension = schedulerOptions . GetScaledDimension ( outputChannels ) ;
@@ -83,7 +84,7 @@ protected override async Task<DenseTensor<float>> SchedulerStepAsync(StableDiffu
83
84
inferenceParameters . AddInputTensor ( timestepTensor ) ;
84
85
inferenceParameters . AddInputTensor ( promptEmbeddings . PromptEmbeds ) ;
85
86
inferenceParameters . AddInputTensor ( promptEmbeddings . PooledPromptEmbeds ) ;
86
- inferenceParameters . AddInputTensor ( addTimeIds ) ;
87
+ inferenceParameters . AddInputTensor ( timeids ) ;
87
88
inferenceParameters . AddOutputBuffer ( outputDimension ) ;
88
89
89
90
var results = await _onnxModelService . RunInferenceAsync ( modelOptions , OnnxModelType . Unet , inferenceParameters ) ;
@@ -115,26 +116,11 @@ protected override async Task<DenseTensor<float>> SchedulerStepAsync(StableDiffu
115
116
/// </summary>
116
117
/// <param name="schedulerOptions">The scheduler options.</param>
117
118
/// <returns></returns>
118
- protected DenseTensor < float > GetAddTimeIds ( StableDiffusionModelSet model , SchedulerOptions schedulerOptions , bool performGuidance )
119
+ protected DenseTensor < float > GetAddTimeIds ( StableDiffusionModelSet model , SchedulerOptions schedulerOptions )
119
120
{
120
- float [ ] result ;
121
- if ( model . ModelType == ModelType . Refiner )
122
- {
123
- //original_size + crops_coords_top_left + aesthetic_score
124
- //original_size + crops_coords_top_left + negative_aesthetic_score
125
- result = ! performGuidance
126
- ? new float [ ] { schedulerOptions . Height , schedulerOptions . Width , 0 , 0 , schedulerOptions . AestheticScore }
127
- : new float [ ] { schedulerOptions . Height , schedulerOptions . Width , 0 , 0 , schedulerOptions . AestheticNegativeScore , schedulerOptions . Height , schedulerOptions . Width , 0 , 0 , schedulerOptions . AestheticScore } ;
128
- }
129
- else
130
- {
131
- //original_size + crops_coords_top_left + target_size
132
- //original_size + crops_coords_top_left + negative_target_size
133
- result = ! performGuidance
134
- ? new float [ ] { schedulerOptions . Height , schedulerOptions . Width , 0 , 0 , schedulerOptions . Height , schedulerOptions . Width }
135
- : new float [ ] { schedulerOptions . Height , schedulerOptions . Width , 0 , 0 , schedulerOptions . Height , schedulerOptions . Width , schedulerOptions . Height , schedulerOptions . Width , 0 , 0 , schedulerOptions . Height , schedulerOptions . Width } ;
136
- }
137
-
121
+ float [ ] result = model . ModelType == ModelType . Refiner
122
+ ? new float [ ] { schedulerOptions . Height , schedulerOptions . Width , 0 , 0 , schedulerOptions . AestheticScore }
123
+ : new float [ ] { schedulerOptions . Height , schedulerOptions . Width , 0 , 0 , schedulerOptions . Height , schedulerOptions . Width } ;
138
124
return TensorHelper . CreateTensor ( result , new [ ] { 1 , result . Length } ) ;
139
125
}
140
126
0 commit comments