Skip to content

Commit 69a2c08

Browse files
authored
Merge pull request #463 from LykosAI/main
v2.8.3 Update
2 parents a0ff4a0 + c495f65 commit 69a2c08

File tree

6 files changed

+57
-26
lines changed

6 files changed

+57
-26
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to Stability Matrix will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2.0.0.html).
77

8+
## v2.8.3
9+
### Fixed
10+
- Fixed user tokens read error causing failed downloads
11+
- Failed downloads will now log error messages
12+
- Fixed [#458](https://github.com/LykosAI/StabilityMatrix/issues/458) - Save Intermediate Image not working
13+
- Fixed [#453](https://github.com/LykosAI/StabilityMatrix/issues/453) - Update Fooocus `--output-directory` argument to `--output-path`
14+
815
## v2.8.2
916
### Added
1017
- Added missing GFPGAN link to Automatic1111 packages

StabilityMatrix.Avalonia/ViewModels/Base/InferenceGenerationViewModelBase.cs

+45-19
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Collections.Immutable;
4+
using System.ComponentModel.DataAnnotations;
45
using System.Diagnostics;
56
using System.Diagnostics.CodeAnalysis;
67
using System.IO;
78
using System.Linq;
8-
using System.Management;
99
using System.Text.Json;
1010
using System.Text.Json.Serialization;
1111
using System.Threading;
@@ -15,7 +15,6 @@
1515
using Avalonia.Threading;
1616
using CommunityToolkit.Mvvm.Input;
1717
using ExifLibrary;
18-
using MetadataExtractor.Formats.Exif;
1918
using NLog;
2019
using Refit;
2120
using SkiaSharp;
@@ -27,7 +26,6 @@
2726
using StabilityMatrix.Avalonia.ViewModels.Dialogs;
2827
using StabilityMatrix.Avalonia.ViewModels.Inference;
2928
using StabilityMatrix.Avalonia.ViewModels.Inference.Modules;
30-
using StabilityMatrix.Core.Animation;
3129
using StabilityMatrix.Core.Exceptions;
3230
using StabilityMatrix.Core.Extensions;
3331
using StabilityMatrix.Core.Helper;
@@ -297,14 +295,18 @@ protected async Task RunGeneration(ImageGenerationEventArgs args, CancellationTo
297295
Task.Run(
298296
async () =>
299297
{
300-
var delayTime = 250 - (int)timer.ElapsedMilliseconds;
301-
if (delayTime > 0)
298+
try
302299
{
303-
await Task.Delay(delayTime, cancellationToken);
300+
var delayTime = 250 - (int)timer.ElapsedMilliseconds;
301+
if (delayTime > 0)
302+
{
303+
await Task.Delay(delayTime, cancellationToken);
304+
}
305+
306+
// ReSharper disable once AccessToDisposedClosure
307+
AttachRunningNodeChangedHandler(promptTask);
304308
}
305-
306-
// ReSharper disable once AccessToDisposedClosure
307-
AttachRunningNodeChangedHandler(promptTask);
309+
catch (TaskCanceledException) { }
308310
},
309311
cancellationToken
310312
)
@@ -328,10 +330,7 @@ await DialogHelper
328330
// Get output images
329331
var imageOutputs = await client.GetImagesForExecutedPromptAsync(promptTask.Id, cancellationToken);
330332

331-
if (
332-
!imageOutputs.TryGetValue(args.OutputNodeNames[0], out var images)
333-
|| images is not { Count: > 0 }
334-
)
333+
if (imageOutputs.Values.All(images => images is null or { Count: 0 }))
335334
{
336335
// No images match
337336
notificationService.Show(
@@ -350,7 +349,7 @@ await DialogHelper
350349
ImageGalleryCardViewModel.ImageSources.Clear();
351350
}
352351

353-
var outputImages = await ProcessOutputImages(images, args);
352+
var outputImages = await ProcessAllOutputImages(imageOutputs, args);
354353

355354
var notificationImage = outputImages.FirstOrDefault()?.LocalFile;
356355

@@ -380,12 +379,34 @@ await notificationService.ShowAsync(
380379
}
381380
}
382381

382+
private async Task<IEnumerable<ImageSource>> ProcessAllOutputImages(
383+
IReadOnlyDictionary<string, List<ComfyImage>?> images,
384+
ImageGenerationEventArgs args
385+
)
386+
{
387+
var results = new List<ImageSource>();
388+
389+
foreach (var (nodeName, imageList) in images)
390+
{
391+
if (imageList is null)
392+
{
393+
Logger.Warn("No images for node {NodeName}", nodeName);
394+
continue;
395+
}
396+
397+
results.AddRange(await ProcessOutputImages(imageList, args, nodeName.Replace('_', ' ')));
398+
}
399+
400+
return results;
401+
}
402+
383403
/// <summary>
384404
/// Handles image output metadata for generation runs
385405
/// </summary>
386406
private async Task<List<ImageSource>> ProcessOutputImages(
387407
IReadOnlyCollection<ComfyImage> images,
388-
ImageGenerationEventArgs args
408+
ImageGenerationEventArgs args,
409+
string? imageLabel = null
389410
)
390411
{
391412
var client = args.Client;
@@ -441,7 +462,7 @@ ImageGenerationEventArgs args
441462
images.Count
442463
);
443464

444-
outputImages.Add(new ImageSource(filePath));
465+
outputImages.Add(new ImageSource(filePath) { Label = imageLabel });
445466
EventManager.Instance.OnImageFileAdded(filePath);
446467
}
447468
else if (comfyImage.FileName.EndsWith(".webp"))
@@ -470,7 +491,7 @@ ImageGenerationEventArgs args
470491
fileExtension: Path.GetExtension(comfyImage.FileName).Replace(".", "")
471492
);
472493

473-
outputImages.Add(new ImageSource(filePath));
494+
outputImages.Add(new ImageSource(filePath) { Label = imageLabel });
474495
EventManager.Instance.OnImageFileAdded(filePath);
475496
}
476497
else
@@ -484,7 +505,7 @@ ImageGenerationEventArgs args
484505
fileExtension: Path.GetExtension(comfyImage.FileName).Replace(".", "")
485506
);
486507

487-
outputImages.Add(new ImageSource(filePath));
508+
outputImages.Add(new ImageSource(filePath) { Label = imageLabel });
488509
EventManager.Instance.OnImageFileAdded(filePath);
489510
}
490511
}
@@ -554,7 +575,12 @@ private async Task GenerateImage(
554575
}
555576
catch (OperationCanceledException)
556577
{
557-
Logger.Debug($"Image Generation Canceled");
578+
Logger.Debug("Image Generation Canceled");
579+
}
580+
catch (ValidationException e)
581+
{
582+
Logger.Debug("Image Generation Validation Error: {Message}", e.Message);
583+
notificationService.Show("Validation Error", e.Message, NotificationType.Error);
558584
}
559585
}
560586

StabilityMatrix.Core/Models/Packages/Fooocus.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ IPrerequisiteHelper prerequisiteHelper
7373
Name = "Output Directory",
7474
Type = LaunchOptionType.String,
7575
Description = "Override the output directory",
76-
Options = { "--output-directory" }
76+
Options = { "--output-path" }
7777
},
7878
new LaunchOptionDefinition
7979
{

StabilityMatrix.Core/Models/TrackedDownload.cs

+2
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@ private void OnDownloadTaskCompleted(Task task)
317317
return;
318318
}
319319

320+
Logger.Warn(Exception, "Download {Download} failed", FileName);
321+
320322
OnProgressStateChanging(ProgressState.Failed);
321323
ProgressState = ProgressState.Failed;
322324
}

StabilityMatrix.Core/Services/DownloadService.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ private async Task AddConditionalHeaders(HttpClient client, Uri url)
326326
if (url.Host.Equals("civitai.com", StringComparison.OrdinalIgnoreCase))
327327
{
328328
// Add auth if we have it
329-
if (await secretsManager.LoadAsync().ConfigureAwait(false) is { CivitApi: { } civitApi })
329+
if (await secretsManager.SafeLoadAsync().ConfigureAwait(false) is { CivitApi: { } civitApi })
330330
{
331331
logger.LogTrace(
332332
"Adding Civit auth header {Signature} for download {Url}",

StabilityMatrix.Core/Services/SecretsManager.cs

+1-5
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,7 @@ public async Task<Secrets> SafeLoadAsync()
4545
}
4646
catch (Exception e)
4747
{
48-
logger.LogWarning(
49-
e,
50-
"Failed to load secrets ({ExcType}), saving new instance",
51-
e.GetType().Name
52-
);
48+
logger.LogError(e, "Failed to load secrets ({ExcType}), saving new instance", e.GetType().Name);
5349

5450
var secrets = new Secrets();
5551
await SaveAsync(secrets).ConfigureAwait(false);

0 commit comments

Comments
 (0)