@@ -60,7 +60,7 @@ protected override async Task<DenseTensor<float>> SchedulerStepAsync(StableDiffu
6060 var metadata = _onnxModelService . GetModelMetadata ( modelOptions , OnnxModelType . Unet ) ;
6161
6262 // Get Time ids
63- var addTimeIds = GetAddTimeIds ( modelOptions , schedulerOptions , performGuidance ) ;
63+ var addTimeIds = GetAddTimeIds ( modelOptions , schedulerOptions ) ;
6464
6565 // Loop though the timesteps
6666 var step = 0 ;
@@ -74,6 +74,7 @@ protected override async Task<DenseTensor<float>> SchedulerStepAsync(StableDiffu
7474 var inputLatent = performGuidance ? latents . Repeat ( 2 ) : latents ;
7575 var inputTensor = scheduler . ScaleInput ( inputLatent , timestep ) ;
7676 var timestepTensor = CreateTimestepTensor ( timestep ) ;
77+ var timeids = performGuidance ? addTimeIds . Repeat ( 2 ) : addTimeIds ;
7778
7879 var outputChannels = performGuidance ? 2 : 1 ;
7980 var outputDimension = schedulerOptions . GetScaledDimension ( outputChannels ) ;
@@ -83,7 +84,7 @@ protected override async Task<DenseTensor<float>> SchedulerStepAsync(StableDiffu
8384 inferenceParameters . AddInputTensor ( timestepTensor ) ;
8485 inferenceParameters . AddInputTensor ( promptEmbeddings . PromptEmbeds ) ;
8586 inferenceParameters . AddInputTensor ( promptEmbeddings . PooledPromptEmbeds ) ;
86- inferenceParameters . AddInputTensor ( addTimeIds ) ;
87+ inferenceParameters . AddInputTensor ( timeids ) ;
8788 inferenceParameters . AddOutputBuffer ( outputDimension ) ;
8889
8990 var results = await _onnxModelService . RunInferenceAsync ( modelOptions , OnnxModelType . Unet , inferenceParameters ) ;
@@ -115,26 +116,11 @@ protected override async Task<DenseTensor<float>> SchedulerStepAsync(StableDiffu
115116 /// </summary>
116117 /// <param name="schedulerOptions">The scheduler options.</param>
117118 /// <returns></returns>
118- protected DenseTensor < float > GetAddTimeIds ( StableDiffusionModelSet model , SchedulerOptions schedulerOptions , bool performGuidance )
119+ protected DenseTensor < float > GetAddTimeIds ( StableDiffusionModelSet model , SchedulerOptions schedulerOptions )
119120 {
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 } ;
138124 return TensorHelper . CreateTensor ( result , new [ ] { 1 , result . Length } ) ;
139125 }
140126
0 commit comments