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

Commit a362793

Browse files
committed
Fix video frame result callback
1 parent fa234ee commit a362793

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

OnnxStack.StableDiffusion/Pipelines/Base/PipelineBase.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ protected async IAsyncEnumerable<DenseTensor<float>> DiffuseVideoAsync(IDiffuser
218218

219219
var frameIndex = 0;
220220
var videoFrames = promptOptions.InputVideo.Frames;
221-
var schedulerFrameCallback = CreateBatchCallback(progressCallback, videoFrames.Count, () => frameIndex);
222221
foreach (var videoFrame in videoFrames)
223222
{
224223
if (promptOptions.DiffuserType == DiffuserType.ControlNet || promptOptions.DiffuserType == DiffuserType.ControlNetImage)
@@ -234,7 +233,7 @@ protected async IAsyncEnumerable<DenseTensor<float>> DiffuseVideoAsync(IDiffuser
234233
promptOptions.InputImage = videoFrame;
235234
}
236235

237-
var frameResultTensor = await diffuser.DiffuseAsync(promptOptions, schedulerOptions, promptEmbeddings, performGuidance, schedulerFrameCallback, cancellationToken);
236+
var frameResultTensor = await diffuser.DiffuseAsync(promptOptions, schedulerOptions, promptEmbeddings, performGuidance, progressCallback, cancellationToken);
238237

239238
// Frame Progress
240239
ReportBatchProgress(progressCallback, ++frameIndex, videoFrames.Count, frameResultTensor);
@@ -296,7 +295,9 @@ protected Action<DiffusionProgress> CreateBatchCallback(Action<DiffusionProgress
296295
StepValue = progress.StepValue,
297296
StepTensor = progress.StepTensor,
298297
BatchMax = batchCount,
299-
BatchValue = batchIndex()
298+
BatchValue = batchIndex(),
299+
BatchTensor = progress.BatchTensor,
300+
Message = progress.Message
300301
});
301302
}
302303

OnnxStack.UI/Views/VideoToVideoView.xaml.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,11 +379,13 @@ private Action<DiffusionProgress> ProgressCallback()
379379
if (_cancelationTokenSource.IsCancellationRequested)
380380
return;
381381

382+
if (progress.BatchTensor is null)
383+
ProgressText = $"Frame: {progress.BatchValue:D2}/{_videoFrames.Frames.Count} | Step: {progress.StepValue:D2}/{progress.StepMax:D2}";
384+
382385
if (progress.BatchTensor is not null)
383386
{
384387
PreviewResult = Utils.CreateBitmap(new OnnxImage(progress.BatchTensor).GetImageBytes());
385388
PreviewSource = UpdatePreviewFrame(progress.BatchValue - 1);
386-
ProgressText = $"Video Frame {progress.BatchValue} of {_videoFrames.Frames.Count} complete";
387389
}
388390

389391
if (ProgressText != progress.Message && progress.BatchMax == 0)

0 commit comments

Comments
 (0)