Skip to content

Commit 1f10e42

Browse files
committed
Fix batch count seed increments not being recorded in project or image metadata
1 parent fd1da21 commit 1f10e42

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ and this project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2
6565
### Fixed
6666
- Fixed incorrect IPAdapter download links in the HuggingFace model browser
6767
- Fixed potential memory leak of transient controls (Inference Prompt and Output Image Viewer) not being garbage collected due to event subscriptions
68+
- Fixed Batch Count seeds not being recorded properly in Inference projects and image metadata
6869

6970
## v2.11.5
7071
### Added

StabilityMatrix.Avalonia/ViewModels/Inference/InferenceTextToImageViewModel.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,13 +242,20 @@ CancellationToken cancellationToken
242242
var buildPromptArgs = new BuildPromptEventArgs { Overrides = overrides, SeedOverride = seed };
243243
BuildPrompt(buildPromptArgs);
244244

245+
// update seed in project for batches
246+
var inferenceProject = InferenceProjectDocument.FromLoadable(this);
247+
if (inferenceProject.State?["Seed"]?["Seed"] is not null)
248+
{
249+
inferenceProject = inferenceProject.WithState(x => x["Seed"]["Seed"] = seed);
250+
}
251+
245252
var generationArgs = new ImageGenerationEventArgs
246253
{
247254
Client = ClientManager.Client,
248255
Nodes = buildPromptArgs.Builder.ToNodeDictionary(),
249256
OutputNodeNames = buildPromptArgs.Builder.Connections.OutputNodeNames.ToArray(),
250-
Parameters = SaveStateToParameters(new GenerationParameters()),
251-
Project = InferenceProjectDocument.FromLoadable(this),
257+
Parameters = SaveStateToParameters(new GenerationParameters(), Convert.ToUInt64(seed)),
258+
Project = inferenceProject,
252259
FilesToTransfer = buildPromptArgs.FilesToTransfer,
253260
BatchIndex = i,
254261
// Only clear output images on the first batch
@@ -281,13 +288,16 @@ public void LoadStateFromParameters(GenerationParameters parameters)
281288
}
282289

283290
/// <inheritdoc />
284-
public GenerationParameters SaveStateToParameters(GenerationParameters parameters)
291+
public GenerationParameters SaveStateToParameters(GenerationParameters parameters) =>
292+
SaveStateToParameters(parameters, null);
293+
294+
private GenerationParameters SaveStateToParameters(GenerationParameters parameters, ulong? seedOverride)
285295
{
286296
parameters = PromptCardViewModel.SaveStateToParameters(parameters);
287297
parameters = SamplerCardViewModel.SaveStateToParameters(parameters);
288298
parameters = ModelCardViewModel.SaveStateToParameters(parameters);
289299

290-
parameters.Seed = (ulong)SeedCardViewModel.Seed;
300+
parameters.Seed = seedOverride ?? (ulong)SeedCardViewModel.Seed;
291301

292302
return parameters;
293303
}

0 commit comments

Comments
 (0)