From 59557c8de17d2ebfd418c70f81531bd27cc2800a Mon Sep 17 00:00:00 2001 From: JT Date: Sun, 4 Aug 2024 20:13:31 -0700 Subject: [PATCH] Merge pull request #753 from ionite34/fix-batch-seed Fix batch count seed increments not being recorded in project or image metadata (cherry picked from commit 6b46cb5eb9afd0fbc4b325b0890ff798a07e8886) --- CHANGELOG.md | 1 + .../Inference/InferenceTextToImageViewModel.cs | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2917893..49760832 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2 ### Fixed - Fixed incorrect IPAdapter download links in the HuggingFace model browser - Fixed potential memory leak of transient controls (Inference Prompt and Output Image Viewer) not being garbage collected due to event subscriptions +- Fixed Batch Count seeds not being recorded properly in Inference projects and image metadata ## v2.11.5 ### Added diff --git a/StabilityMatrix.Avalonia/ViewModels/Inference/InferenceTextToImageViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/Inference/InferenceTextToImageViewModel.cs index 33f56760..4d628eda 100644 --- a/StabilityMatrix.Avalonia/ViewModels/Inference/InferenceTextToImageViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/Inference/InferenceTextToImageViewModel.cs @@ -214,13 +214,23 @@ CancellationToken cancellationToken var buildPromptArgs = new BuildPromptEventArgs { Overrides = overrides, SeedOverride = seed }; BuildPrompt(buildPromptArgs); + // update seed in project for batches + var inferenceProject = InferenceProjectDocument.FromLoadable(this); + if (inferenceProject.State?["Seed"]?["Seed"] is not null) + { + inferenceProject = inferenceProject.WithState(x => x["Seed"]["Seed"] = seed); + } + var generationArgs = new ImageGenerationEventArgs { Client = ClientManager.Client, Nodes = buildPromptArgs.Builder.ToNodeDictionary(), OutputNodeNames = buildPromptArgs.Builder.Connections.OutputNodeNames.ToArray(), - Parameters = SaveStateToParameters(new GenerationParameters()), - Project = InferenceProjectDocument.FromLoadable(this), + Parameters = SaveStateToParameters(new GenerationParameters()) with + { + Seed = Convert.ToUInt64(seed) + }, + Project = inferenceProject, FilesToTransfer = buildPromptArgs.FilesToTransfer, BatchIndex = i, // Only clear output images on the first batch