diff --git a/CHANGELOG.md b/CHANGELOG.md index e0366be7..9ebc7e4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2 ## v2.8.0-pre.5 ### Fixed - Fixed error when ControlNet module image paths are not found, even if the module is disabled +- Fixed error when finding metadata for archived models +- Fixed error when extensions folder is missing +- Fixed error when webp files have incorrect metadata ## v2.8.0-pre.4 ### Added diff --git a/StabilityMatrix.Avalonia/DialogHelper.cs b/StabilityMatrix.Avalonia/DialogHelper.cs index 7ad27bcb..a2438a20 100644 --- a/StabilityMatrix.Avalonia/DialogHelper.cs +++ b/StabilityMatrix.Avalonia/DialogHelper.cs @@ -509,7 +509,7 @@ public static class DialogHelper models.Select(m => m.FileNameWithoutExtension) ); - if (result.Score > 40) + if (result is { Score: > 40 }) { mainGrid.Children.Add( new InfoBar diff --git a/StabilityMatrix.Avalonia/ViewModels/Inference/InferenceTextToImageViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/Inference/InferenceTextToImageViewModel.cs index 052986be..9337eeb3 100644 --- a/StabilityMatrix.Avalonia/ViewModels/Inference/InferenceTextToImageViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/Inference/InferenceTextToImageViewModel.cs @@ -188,14 +188,13 @@ public class InferenceTextToImageViewModel : InferenceGenerationViewModelBase, I { // Validate the prompts if (!await PromptCardViewModel.ValidatePrompts()) - { return; - } + + if (!await ModelCardViewModel.ValidateModel()) + return; if (!await CheckClientConnectedWithPrompt() || !ClientManager.IsConnected) - { return; - } // If enabled, randomize the seed var seedCard = StackCardViewModel.GetCard(); diff --git a/StabilityMatrix.Avalonia/ViewModels/Inference/ModelCardViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/Inference/ModelCardViewModel.cs index 1fed6926..05d91e58 100644 --- a/StabilityMatrix.Avalonia/ViewModels/Inference/ModelCardViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/Inference/ModelCardViewModel.cs @@ -2,8 +2,10 @@ using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text.Json.Nodes; +using System.Threading.Tasks; using CommunityToolkit.Mvvm.ComponentModel; using StabilityMatrix.Avalonia.Controls; +using StabilityMatrix.Avalonia.Languages; using StabilityMatrix.Avalonia.Models; using StabilityMatrix.Avalonia.Models.Inference; using StabilityMatrix.Avalonia.Services; @@ -51,6 +53,19 @@ public partial class ModelCardViewModel(IInferenceClientManager clientManager) public IInferenceClientManager ClientManager { get; } = clientManager; + public async Task ValidateModel() + { + if (SelectedModel != null) + return true; + + var dialog = DialogHelper.CreateMarkdownDialog( + "Please select a model to continue.", + "No Model Selected" + ); + await dialog.ShowAsync(); + return false; + } + /// public virtual void ApplyStep(ModuleApplyStepEventArgs e) { diff --git a/StabilityMatrix.Core/Helper/ModelFinder.cs b/StabilityMatrix.Core/Helper/ModelFinder.cs index 43517c6a..bdce054d 100644 --- a/StabilityMatrix.Core/Helper/ModelFinder.cs +++ b/StabilityMatrix.Core/Helper/ModelFinder.cs @@ -56,10 +56,14 @@ public class ModelFinder // VersionResponse is not actually the full data of ModelVersion, so find it again var version = model.ModelVersions!.First(version => version.Id == versionResponse.Id); - var file = versionResponse.Files.First( + var file = versionResponse.Files.FirstOrDefault( file => hashBlake3.Equals(file.Hashes.BLAKE3, StringComparison.OrdinalIgnoreCase) ); + // Archived models do not have files + if (file == null) + return null; + return new ModelSearchResult(model, version, file); } catch (TaskCanceledException e) diff --git a/StabilityMatrix.Core/Models/Database/LocalImageFile.cs b/StabilityMatrix.Core/Models/Database/LocalImageFile.cs index 54153635..a6446d47 100644 --- a/StabilityMatrix.Core/Models/Database/LocalImageFile.cs +++ b/StabilityMatrix.Core/Models/Database/LocalImageFile.cs @@ -1,4 +1,5 @@ -using DynamicData.Tests; +using System.Text.Json; +using DynamicData.Tests; using MetadataExtractor.Formats.Exif; using StabilityMatrix.Core.Helper; using StabilityMatrix.Core.Models.FileInterfaces; @@ -89,9 +90,18 @@ public record LocalImageFile filePath, ExifDirectoryBase.TagImageDescription ); - var parameters = string.IsNullOrWhiteSpace(paramsJson) - ? null - : JsonSerializer.Deserialize(paramsJson); + + GenerationParameters? parameters = null; + try + { + parameters = string.IsNullOrWhiteSpace(paramsJson) + ? null + : JsonSerializer.Deserialize(paramsJson); + } + catch (JsonException) + { + // just don't load params I guess, no logger here <_< + } filePath.Info.Refresh(); diff --git a/StabilityMatrix.Core/Models/Packages/Extensions/GitPackageExtensionManager.cs b/StabilityMatrix.Core/Models/Packages/Extensions/GitPackageExtensionManager.cs index 9c672b8b..7f20a550 100644 --- a/StabilityMatrix.Core/Models/Packages/Extensions/GitPackageExtensionManager.cs +++ b/StabilityMatrix.Core/Models/Packages/Extensions/GitPackageExtensionManager.cs @@ -82,6 +82,12 @@ public abstract class GitPackageExtensionManager(IPrerequisiteHelper prerequisit { cancellationToken.ThrowIfCancellationRequested(); + // Skip directory if not exists + if (!indexDirectory.Exists) + { + continue; + } + // Check subdirectories of the index directory foreach (var subDirectory in indexDirectory.EnumerateDirectories()) {