From b4fd64e7fc9592b60ba9dd2c6fa3887a1986080e Mon Sep 17 00:00:00 2001 From: jt Date: Sat, 18 Nov 2023 00:14:22 -0800 Subject: [PATCH 001/116] macos fixes & remove mac label for volta --- .../StabilityMatrix.Avalonia.Diagnostics.csproj | 1 + StabilityMatrix.Avalonia/App.axaml | 1 + StabilityMatrix.Avalonia/Helpers/UriHandler.cs | 2 +- StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj | 9 +++++++++ StabilityMatrix.Core/Models/Packages/BasePackage.cs | 5 +++++ StabilityMatrix.Core/Models/Packages/VoltaML.cs | 2 +- StabilityMatrix.Core/Processes/ProcessRunner.cs | 2 +- StabilityMatrix.Core/StabilityMatrix.Core.csproj | 1 + StabilityMatrix.Tests/StabilityMatrix.Tests.csproj | 1 + StabilityMatrix.UITests/StabilityMatrix.UITests.csproj | 1 + 10 files changed, 22 insertions(+), 3 deletions(-) diff --git a/StabilityMatrix.Avalonia.Diagnostics/StabilityMatrix.Avalonia.Diagnostics.csproj b/StabilityMatrix.Avalonia.Diagnostics/StabilityMatrix.Avalonia.Diagnostics.csproj index eb84e3f3..84e8c3f9 100644 --- a/StabilityMatrix.Avalonia.Diagnostics/StabilityMatrix.Avalonia.Diagnostics.csproj +++ b/StabilityMatrix.Avalonia.Diagnostics/StabilityMatrix.Avalonia.Diagnostics.csproj @@ -21,6 +21,7 @@ + diff --git a/StabilityMatrix.Avalonia/App.axaml b/StabilityMatrix.Avalonia/App.axaml index c2821641..2e08109c 100644 --- a/StabilityMatrix.Avalonia/App.axaml +++ b/StabilityMatrix.Avalonia/App.axaml @@ -4,6 +4,7 @@ xmlns:local="using:StabilityMatrix.Avalonia" xmlns:idcr="using:Dock.Avalonia.Controls.Recycling" xmlns:styling="clr-namespace:FluentAvalonia.Styling;assembly=FluentAvalonia" + Name="Stability Matrix" RequestedThemeVariant="Dark"> diff --git a/StabilityMatrix.Avalonia/Helpers/UriHandler.cs b/StabilityMatrix.Avalonia/Helpers/UriHandler.cs index e500a1e4..a6f04b3d 100644 --- a/StabilityMatrix.Avalonia/Helpers/UriHandler.cs +++ b/StabilityMatrix.Avalonia/Helpers/UriHandler.cs @@ -64,7 +64,7 @@ public class UriHandler { RegisterUriSchemeWin(); } - else + else if (Compat.IsLinux) { RegisterUriSchemeUnix(); } diff --git a/StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj b/StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj index fb16d35f..d3111ecd 100644 --- a/StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj +++ b/StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj @@ -1,5 +1,6 @@  + Stability Matrix WinExe net8.0 win-x64;linux-x64;osx-x64;osx-arm64 @@ -14,6 +15,13 @@ true + + + StabilityMatrix.URL + stabilitymatrix;stabilitymatrix:// + + + @@ -37,6 +45,7 @@ + diff --git a/StabilityMatrix.Core/Models/Packages/BasePackage.cs b/StabilityMatrix.Core/Models/Packages/BasePackage.cs index 29ff06b9..f704b0f0 100644 --- a/StabilityMatrix.Core/Models/Packages/BasePackage.cs +++ b/StabilityMatrix.Core/Models/Packages/BasePackage.cs @@ -133,6 +133,11 @@ public abstract class BasePackage return TorchVersion.DirectMl; } + if (Compat.IsMacOS && Compat.IsArm && AvailableTorchVersions.Contains(TorchVersion.Mps)) + { + return TorchVersion.Mps; + } + return TorchVersion.Cpu; } diff --git a/StabilityMatrix.Core/Models/Packages/VoltaML.cs b/StabilityMatrix.Core/Models/Packages/VoltaML.cs index eeef1ce3..933e4fb3 100644 --- a/StabilityMatrix.Core/Models/Packages/VoltaML.cs +++ b/StabilityMatrix.Core/Models/Packages/VoltaML.cs @@ -62,7 +62,7 @@ public class VoltaML : BaseGitPackage public override SharedFolderMethod RecommendedSharedFolderMethod => SharedFolderMethod.Symlink; public override IEnumerable AvailableTorchVersions => - new[] { TorchVersion.Cpu, TorchVersion.Cuda, TorchVersion.DirectMl, TorchVersion.Mps }; + new[] { TorchVersion.Cpu, TorchVersion.Cuda, TorchVersion.DirectMl }; public override IEnumerable AvailableSharedFolderMethods => new[] { SharedFolderMethod.Symlink, SharedFolderMethod.None }; diff --git a/StabilityMatrix.Core/Processes/ProcessRunner.cs b/StabilityMatrix.Core/Processes/ProcessRunner.cs index 3a20cc60..8adde5eb 100644 --- a/StabilityMatrix.Core/Processes/ProcessRunner.cs +++ b/StabilityMatrix.Core/Processes/ProcessRunner.cs @@ -92,7 +92,7 @@ public static class ProcessRunner else if (Compat.IsMacOS) { using var process = new Process(); - process.StartInfo.FileName = "explorer"; + process.StartInfo.FileName = "open"; process.StartInfo.Arguments = $"-R {Quote(filePath)}"; process.Start(); await process.WaitForExitAsync().ConfigureAwait(false); diff --git a/StabilityMatrix.Core/StabilityMatrix.Core.csproj b/StabilityMatrix.Core/StabilityMatrix.Core.csproj index 254f8efe..f62ba22a 100644 --- a/StabilityMatrix.Core/StabilityMatrix.Core.csproj +++ b/StabilityMatrix.Core/StabilityMatrix.Core.csproj @@ -23,6 +23,7 @@ + diff --git a/StabilityMatrix.Tests/StabilityMatrix.Tests.csproj b/StabilityMatrix.Tests/StabilityMatrix.Tests.csproj index 87423475..a0acdc33 100644 --- a/StabilityMatrix.Tests/StabilityMatrix.Tests.csproj +++ b/StabilityMatrix.Tests/StabilityMatrix.Tests.csproj @@ -11,6 +11,7 @@ + diff --git a/StabilityMatrix.UITests/StabilityMatrix.UITests.csproj b/StabilityMatrix.UITests/StabilityMatrix.UITests.csproj index 8062d3bd..961598f0 100644 --- a/StabilityMatrix.UITests/StabilityMatrix.UITests.csproj +++ b/StabilityMatrix.UITests/StabilityMatrix.UITests.csproj @@ -11,6 +11,7 @@ + From e389085ec11104f51ac5b10c4e7edab3dc3f9f42 Mon Sep 17 00:00:00 2001 From: JT Date: Tue, 28 Nov 2023 23:03:51 -0800 Subject: [PATCH 002/116] Added image to video in inference (mostly) --- StabilityMatrix.Avalonia/App.axaml | 3 +- .../Controls/ModelCard.axaml | 2 + .../VideoGenerationSettingsCard.axaml | 122 +++++++++ .../VideoGenerationSettingsCard.axaml.cs | 7 + .../Controls/VideoOutputSettingsCard.axaml | 86 +++++++ .../Controls/VideoOutputSettingsCard.axaml.cs | 7 + .../DesignData/DesignData.cs | 14 + .../Models/Inference/VideoOutputMethod.cs | 8 + .../Models/InferenceProjectDocument.cs | 1 + .../Models/InferenceProjectType.cs | 4 +- .../StabilityMatrix.Avalonia.csproj | 12 + .../Base/InferenceGenerationViewModelBase.cs | 37 ++- .../InferenceImageToVideoViewModel.cs | 243 ++++++++++++++++++ .../Inference/ModelCardViewModel.cs | 5 +- .../Video/ImgToVidModelCardViewModel.cs | 37 +++ .../Video/SvdImgToVidConditioningViewModel.cs | 90 +++++++ .../Video/VideoOutputSettingsCardViewModel.cs | 80 ++++++ .../Inference/InferenceImageToVideoView.axaml | 221 ++++++++++++++++ .../InferenceImageToVideoView.axaml.cs | 13 + .../Views/InferencePage.axaml | 10 + .../Views/InferencePage.axaml.cs | 7 + .../Api/Comfy/NodeTypes/NodeConnections.cs | 2 + .../Api/Comfy/Nodes/ComfyNodeBuilder.cs | 41 +++ 23 files changed, 1038 insertions(+), 14 deletions(-) create mode 100644 StabilityMatrix.Avalonia/Controls/VideoGenerationSettingsCard.axaml create mode 100644 StabilityMatrix.Avalonia/Controls/VideoGenerationSettingsCard.axaml.cs create mode 100644 StabilityMatrix.Avalonia/Controls/VideoOutputSettingsCard.axaml create mode 100644 StabilityMatrix.Avalonia/Controls/VideoOutputSettingsCard.axaml.cs create mode 100644 StabilityMatrix.Avalonia/Models/Inference/VideoOutputMethod.cs create mode 100644 StabilityMatrix.Avalonia/ViewModels/Inference/InferenceImageToVideoViewModel.cs create mode 100644 StabilityMatrix.Avalonia/ViewModels/Inference/Video/ImgToVidModelCardViewModel.cs create mode 100644 StabilityMatrix.Avalonia/ViewModels/Inference/Video/SvdImgToVidConditioningViewModel.cs create mode 100644 StabilityMatrix.Avalonia/ViewModels/Inference/Video/VideoOutputSettingsCardViewModel.cs create mode 100644 StabilityMatrix.Avalonia/Views/Inference/InferenceImageToVideoView.axaml create mode 100644 StabilityMatrix.Avalonia/Views/Inference/InferenceImageToVideoView.axaml.cs diff --git a/StabilityMatrix.Avalonia/App.axaml b/StabilityMatrix.Avalonia/App.axaml index 93486dab..4e02cb07 100644 --- a/StabilityMatrix.Avalonia/App.axaml +++ b/StabilityMatrix.Avalonia/App.axaml @@ -74,7 +74,8 @@ - + + diff --git a/StabilityMatrix.Avalonia/Controls/ModelCard.axaml b/StabilityMatrix.Avalonia/Controls/ModelCard.axaml index e0fc6a1c..ce990ac9 100644 --- a/StabilityMatrix.Avalonia/Controls/ModelCard.axaml +++ b/StabilityMatrix.Avalonia/Controls/ModelCard.axaml @@ -12,6 +12,7 @@ + @@ -135,6 +136,7 @@ + + @@ -190,6 +192,31 @@ IsVisible="{Binding IsVaeSelectionEnabled}" ItemsSource="{Binding ClientManager.VaeModels}" SelectedItem="{Binding SelectedVae}" /> + + + + + From d82f3d4843b3ec4200fa95893c946f71ea8f1d17 Mon Sep 17 00:00:00 2001 From: Ionite Date: Sat, 16 Dec 2023 16:57:23 -0500 Subject: [PATCH 009/116] Fix Value access --- .../Inference/Modules/ControlNetModule.cs | 26 ++++++------------- 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/StabilityMatrix.Avalonia/ViewModels/Inference/Modules/ControlNetModule.cs b/StabilityMatrix.Avalonia/ViewModels/Inference/Modules/ControlNetModule.cs index 4f4e7191..26bf7897 100644 --- a/StabilityMatrix.Avalonia/ViewModels/Inference/Modules/ControlNetModule.cs +++ b/StabilityMatrix.Avalonia/ViewModels/Inference/Modules/ControlNetModule.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using System.Linq; -using StabilityMatrix.Avalonia.Controls; using StabilityMatrix.Avalonia.Models; using StabilityMatrix.Avalonia.Models.Inference; using StabilityMatrix.Avalonia.Services; @@ -42,9 +40,8 @@ public class ControlNetModule : ModuleBase { Name = e.Nodes.GetUniqueName("ControlNet_LoadImage"), Image = - card.SelectImageCardViewModel.ImageSource?.GetHashGuidFileNameCached( - "Inference" - ) ?? throw new ValidationException("No ImageSource") + card.SelectImageCardViewModel.ImageSource?.GetHashGuidFileNameCached("Inference") + ?? throw new ValidationException("No ImageSource") } ); @@ -52,9 +49,7 @@ public class ControlNetModule : ModuleBase new ComfyNodeBuilder.ControlNetLoader { Name = e.Nodes.GetUniqueName("ControlNetLoader"), - ControlNetName = - card.SelectedModel?.FileName - ?? throw new ValidationException("No SelectedModel"), + ControlNetName = card.SelectedModel?.FileName ?? throw new ValidationException("No SelectedModel"), } ); @@ -64,10 +59,8 @@ public class ControlNetModule : ModuleBase Name = e.Nodes.GetUniqueName("ControlNetApply"), Image = imageLoad.Output1, ControlNet = controlNetLoader.Output, - Positive = - e.Temp.Conditioning?.Positive ?? throw new ArgumentException("No Conditioning"), - Negative = - e.Temp.Conditioning?.Negative ?? throw new ArgumentException("No Conditioning"), + Positive = e.Temp.Conditioning?.Positive ?? throw new ArgumentException("No Conditioning"), + Negative = e.Temp.Conditioning?.Negative ?? throw new ArgumentException("No Conditioning"), Strength = card.Strength, StartPercent = card.StartPercent, EndPercent = card.EndPercent, @@ -85,18 +78,15 @@ public class ControlNetModule : ModuleBase Name = e.Nodes.GetUniqueName("Refiner_ControlNetApply"), Image = imageLoad.Output1, ControlNet = controlNetLoader.Output, - Positive = e.Temp.RefinerConditioning.Value.Positive, - Negative = e.Temp.RefinerConditioning.Value.Negative, + Positive = e.Temp.RefinerConditioning.Positive, + Negative = e.Temp.RefinerConditioning.Negative, Strength = card.Strength, StartPercent = card.StartPercent, EndPercent = card.EndPercent, } ); - e.Temp.RefinerConditioning = ( - controlNetRefinerApply.Output1, - controlNetRefinerApply.Output2 - ); + e.Temp.RefinerConditioning = (controlNetRefinerApply.Output1, controlNetRefinerApply.Output2); } } } From 1c37e9b4e400e0639be005dc30f5d89647ccd04c Mon Sep 17 00:00:00 2001 From: Ionite Date: Sat, 16 Dec 2023 16:58:28 -0500 Subject: [PATCH 010/116] Version bump --- StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj b/StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj index 446a2476..2113c78c 100644 --- a/StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj +++ b/StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj @@ -9,7 +9,7 @@ app.manifest true ./Assets/Icon.ico - 2.7.0-pre.999 + 2.8.0-dev.999 $(Version) true true From ed4f78a57ece8bcbc9c548f118b3b1e4bdf4ada4 Mon Sep 17 00:00:00 2001 From: Ionite Date: Sat, 16 Dec 2023 17:02:21 -0500 Subject: [PATCH 011/116] Add clip skip default value --- .../ViewModels/Inference/ModelCardViewModel.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/StabilityMatrix.Avalonia/ViewModels/Inference/ModelCardViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/Inference/ModelCardViewModel.cs index 38e13bb2..b8a1d94b 100644 --- a/StabilityMatrix.Avalonia/ViewModels/Inference/ModelCardViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/Inference/ModelCardViewModel.cs @@ -9,9 +9,7 @@ using StabilityMatrix.Avalonia.Models.Inference; using StabilityMatrix.Avalonia.Services; using StabilityMatrix.Avalonia.ViewModels.Base; using StabilityMatrix.Core.Attributes; -using StabilityMatrix.Core.Extensions; using StabilityMatrix.Core.Models; -using StabilityMatrix.Core.Models.Api.Comfy.NodeTypes; using StabilityMatrix.Core.Models.Api.Comfy.Nodes; namespace StabilityMatrix.Avalonia.ViewModels.Inference; @@ -208,7 +206,7 @@ public partial class ModelCardViewModel(IInferenceClientManager clientManager) public string? SelectedModelName { get; init; } public string? SelectedRefinerName { get; init; } public string? SelectedVaeName { get; init; } - public int ClipSkip { get; init; } + public int ClipSkip { get; init; } = 1; public bool IsVaeSelectionEnabled { get; init; } public bool IsRefinerSelectionEnabled { get; init; } From a6c87a2be3f28c9143617266ace9b51841846006 Mon Sep 17 00:00:00 2001 From: Ionite Date: Sat, 16 Dec 2023 21:11:56 -0500 Subject: [PATCH 012/116] Add BetterComboBox --- StabilityMatrix.Avalonia/App.axaml | 1 + .../Controls/BetterComboBox.cs | 41 ++++ .../ControlThemes/BetterComboBoxStyles.axaml | 202 ++++++++++++++++++ 3 files changed, 244 insertions(+) create mode 100644 StabilityMatrix.Avalonia/Controls/BetterComboBox.cs create mode 100644 StabilityMatrix.Avalonia/Styles/ControlThemes/BetterComboBoxStyles.axaml diff --git a/StabilityMatrix.Avalonia/App.axaml b/StabilityMatrix.Avalonia/App.axaml index f54dc933..afeea869 100644 --- a/StabilityMatrix.Avalonia/App.axaml +++ b/StabilityMatrix.Avalonia/App.axaml @@ -24,6 +24,7 @@ + diff --git a/StabilityMatrix.Avalonia/Controls/BetterComboBox.cs b/StabilityMatrix.Avalonia/Controls/BetterComboBox.cs new file mode 100644 index 00000000..7209879c --- /dev/null +++ b/StabilityMatrix.Avalonia/Controls/BetterComboBox.cs @@ -0,0 +1,41 @@ +using System; +using Avalonia; +using Avalonia.Controls; +using Avalonia.Controls.Primitives; +using Avalonia.Controls.Templates; + +namespace StabilityMatrix.Avalonia.Controls; + +public class BetterComboBox : ComboBox +{ + // protected override Type StyleKeyOverride { get; } = typeof(CheckBox); + + public static readonly DirectProperty SelectionBoxItemTemplateProperty = + AvaloniaProperty.RegisterDirect( + nameof(SelectionBoxItemTemplate), + v => v.SelectionBoxItemTemplate, + (x, v) => x.SelectionBoxItemTemplate = v + ); + + private IDataTemplate? _selectionBoxItemTemplate; + + public IDataTemplate? SelectionBoxItemTemplate + { + get => _selectionBoxItemTemplate; + private set => SetAndRaise(SelectionBoxItemTemplateProperty, ref _selectionBoxItemTemplate, value); + } + + /// + protected override void OnApplyTemplate(TemplateAppliedEventArgs e) + { + base.OnApplyTemplate(e); + + if (e.NameScope.Find("ContentPresenter") is { } contentPresenter) + { + if (SelectionBoxItemTemplate is { } template) + { + contentPresenter.ContentTemplate = template; + } + } + } +} diff --git a/StabilityMatrix.Avalonia/Styles/ControlThemes/BetterComboBoxStyles.axaml b/StabilityMatrix.Avalonia/Styles/ControlThemes/BetterComboBoxStyles.axaml new file mode 100644 index 00000000..887299ca --- /dev/null +++ b/StabilityMatrix.Avalonia/Styles/ControlThemes/BetterComboBoxStyles.axaml @@ -0,0 +1,202 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 1afe3e6347a48a5d7a22dd4507ccfadfaf99db13 Mon Sep 17 00:00:00 2001 From: Ionite Date: Sat, 16 Dec 2023 21:12:59 -0500 Subject: [PATCH 013/116] Add improved model card combo box styles --- .../Controls/Inference/ModelCard.axaml | 117 ++---------------- .../DesignData/DesignData.cs | 38 ++++++ .../Models/Database/LocalModelFile.cs | 17 ++- 3 files changed, 67 insertions(+), 105 deletions(-) diff --git a/StabilityMatrix.Avalonia/Controls/Inference/ModelCard.axaml b/StabilityMatrix.Avalonia/Controls/Inference/ModelCard.axaml index 7bf995a8..4e5a3ed2 100644 --- a/StabilityMatrix.Avalonia/Controls/Inference/ModelCard.axaml +++ b/StabilityMatrix.Avalonia/Controls/Inference/ModelCard.axaml @@ -30,112 +30,21 @@ VerticalAlignment="Center" Text="{x:Static lang:Resources.Label_Model}" TextAlignment="Left" /> - - - - - - - - - - - - - - - - - + SelectedItem="{Binding SelectedModel}"/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/StabilityMatrix.Avalonia/Views/Dialogs/NewInstallerDialog.axaml.cs b/StabilityMatrix.Avalonia/Views/Dialogs/NewInstallerDialog.axaml.cs new file mode 100644 index 00000000..53ba4b81 --- /dev/null +++ b/StabilityMatrix.Avalonia/Views/Dialogs/NewInstallerDialog.axaml.cs @@ -0,0 +1,13 @@ +using StabilityMatrix.Avalonia.Controls; +using StabilityMatrix.Core.Attributes; + +namespace StabilityMatrix.Avalonia.Views.Dialogs; + +[Singleton] +public partial class NewInstallerDialog : UserControlBase +{ + public NewInstallerDialog() + { + InitializeComponent(); + } +} diff --git a/StabilityMatrix.Avalonia/Views/NewPackageManagerPage.axaml b/StabilityMatrix.Avalonia/Views/NewPackageManagerPage.axaml new file mode 100644 index 00000000..f2f8f007 --- /dev/null +++ b/StabilityMatrix.Avalonia/Views/NewPackageManagerPage.axaml @@ -0,0 +1,49 @@ + + + + + + 24 + 17 + 6,3 + Medium + + + + + + + + + + + + + + + + + + + diff --git a/StabilityMatrix.Avalonia/Views/NewPackageManagerPage.axaml.cs b/StabilityMatrix.Avalonia/Views/NewPackageManagerPage.axaml.cs new file mode 100644 index 00000000..a503d34a --- /dev/null +++ b/StabilityMatrix.Avalonia/Views/NewPackageManagerPage.axaml.cs @@ -0,0 +1,99 @@ +using System; +using System.ComponentModel; +using System.Linq; +using Avalonia.Interactivity; +using Avalonia.Threading; +using FluentAvalonia.UI.Controls; +using FluentAvalonia.UI.Media.Animation; +using FluentAvalonia.UI.Navigation; +using Microsoft.Extensions.DependencyInjection; +using StabilityMatrix.Avalonia.Animations; +using StabilityMatrix.Avalonia.Controls; +using StabilityMatrix.Avalonia.Models; +using StabilityMatrix.Avalonia.Services; +using StabilityMatrix.Avalonia.ViewModels; +using StabilityMatrix.Avalonia.ViewModels.Base; +using StabilityMatrix.Core.Attributes; +using StabilityMatrix.Core.Models; + +namespace StabilityMatrix.Avalonia.Views; + +[Singleton] +public partial class NewPackageManagerPage : UserControlBase, IHandleNavigation +{ + private readonly INavigationService packageNavigationService; + + private bool hasLoaded; + + private NewPackageManagerViewModel ViewModel => (NewPackageManagerViewModel)DataContext!; + + [DesignOnly(true)] + [Obsolete("For XAML use only", true)] + public NewPackageManagerPage() + : this(App.Services.GetRequiredService>()) { } + + public NewPackageManagerPage(INavigationService packageNavigationService) + { + this.packageNavigationService = packageNavigationService; + + InitializeComponent(); + + packageNavigationService.SetFrame(FrameView); + packageNavigationService.TypedNavigation += NavigationService_OnTypedNavigation; + FrameView.Navigated += FrameView_Navigated; + BreadcrumbBar.ItemClicked += BreadcrumbBar_ItemClicked; + } + + /// + protected override void OnLoaded(RoutedEventArgs e) + { + base.OnLoaded(e); + + if (!hasLoaded) + { + // Initial load, navigate to first page + Dispatcher.UIThread.Post( + () => + packageNavigationService.NavigateTo( + ViewModel.SubPages[0], + new SuppressNavigationTransitionInfo() + ) + ); + + hasLoaded = true; + } + } + + private void NavigationService_OnTypedNavigation(object? sender, TypedNavigationEventArgs e) + { + ViewModel.CurrentPage = + ViewModel.SubPages.FirstOrDefault(x => x.GetType() == e.ViewModelType) + ?? e.ViewModel as PageViewModelBase; + } + + private void FrameView_Navigated(object? sender, NavigationEventArgs args) + { + if (args.Content is not PageViewModelBase vm) + { + return; + } + + ViewModel.CurrentPage = vm; + } + + private void BreadcrumbBar_ItemClicked(BreadcrumbBar sender, BreadcrumbBarItemClickedEventArgs args) + { + // Skip if already on same page + if (args.Item is not PageViewModelBase viewModel || viewModel == ViewModel.CurrentPage) + { + return; + } + + packageNavigationService.NavigateTo(viewModel, BetterSlideNavigationTransition.PageSlideFromLeft); + } + + public bool GoBack() + { + return packageNavigationService.GoBack(); + } +} diff --git a/StabilityMatrix.Avalonia/Views/PackageInstallDetailView.axaml b/StabilityMatrix.Avalonia/Views/PackageInstallDetailView.axaml new file mode 100644 index 00000000..9a826529 --- /dev/null +++ b/StabilityMatrix.Avalonia/Views/PackageInstallDetailView.axaml @@ -0,0 +1,195 @@ + + + + + + + + + + + + + + + + + + @@ -225,9 +240,9 @@ - - - - - + + + + + diff --git a/StabilityMatrix.Avalonia/Views/PackageManagerPage.axaml.cs b/StabilityMatrix.Avalonia/Views/PackageManagerPage.axaml.cs index 5282b885..e017decf 100644 --- a/StabilityMatrix.Avalonia/Views/PackageManagerPage.axaml.cs +++ b/StabilityMatrix.Avalonia/Views/PackageManagerPage.axaml.cs @@ -33,9 +33,9 @@ public partial class PackageManagerPage : UserControlBase if (args.Parameter is PackageManagerNavigationOptions { OpenInstallerDialog: true } options) { var vm = (PackageManagerViewModel)DataContext!; - Dispatcher.UIThread.InvokeAsync(async () => + Dispatcher.UIThread.Invoke(() => { - await vm.ShowInstallDialog(options.InstallerSelectedPackage); + vm.ShowInstallDialog(options.InstallerSelectedPackage); }); } } diff --git a/StabilityMatrix.Core/Models/Packages/StableDiffusionUx.cs b/StabilityMatrix.Core/Models/Packages/StableDiffusionUx.cs index 1f646d06..8da91d96 100644 --- a/StabilityMatrix.Core/Models/Packages/StableDiffusionUx.cs +++ b/StabilityMatrix.Core/Models/Packages/StableDiffusionUx.cs @@ -28,7 +28,8 @@ public class StableDiffusionUx( public override string DisplayName { get; set; } = "Stable Diffusion Web UI-UX"; public override string Author => "anapnoe"; public override string LicenseType => "AGPL-3.0"; - public override string LicenseUrl => "https://github.com/anapnoe/stable-diffusion-webui-ux/blob/master/LICENSE.txt"; + public override string LicenseUrl => + "https://github.com/anapnoe/stable-diffusion-webui-ux/blob/master/LICENSE.txt"; public override string Blurb => "A pixel perfect design, mobile friendly, customizable interface that adds accessibility, " + "ease of use and extended functionallity to the stable diffusion web ui."; @@ -38,7 +39,7 @@ public class StableDiffusionUx( public override SharedFolderMethod RecommendedSharedFolderMethod => SharedFolderMethod.Symlink; - public override PackageDifficulty InstallerSortOrder => PackageDifficulty.Simple; + public override PackageDifficulty InstallerSortOrder => PackageDifficulty.Advanced; public override Dictionary> SharedFolders => new() From 82004934aa22d576ce864b4774af2bb58001cc04 Mon Sep 17 00:00:00 2001 From: JT Date: Tue, 2 Jan 2024 19:31:00 -0800 Subject: [PATCH 106/116] default to recommended torch version & show disclaimers --- .../PackageInstallDetailViewModel.cs | 2 + .../Views/Dialogs/NewInstallerDialog.axaml | 43 +++++++++---------- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/StabilityMatrix.Avalonia/ViewModels/PackageInstallDetailViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/PackageInstallDetailViewModel.cs index c2c7b25d..72a155ab 100644 --- a/StabilityMatrix.Avalonia/ViewModels/PackageInstallDetailViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/PackageInstallDetailViewModel.cs @@ -107,6 +107,8 @@ public partial class PackageInstallDetailViewModel( UpdateVersions(); await UpdateCommits(SelectedPackage.MainBranch); } + + SelectedTorchVersion = SelectedPackage.GetRecommendedTorchVersion(); } [RelayCommand] diff --git a/StabilityMatrix.Avalonia/Views/Dialogs/NewInstallerDialog.axaml b/StabilityMatrix.Avalonia/Views/Dialogs/NewInstallerDialog.axaml index 9fd96094..bd98a96c 100644 --- a/StabilityMatrix.Avalonia/Views/Dialogs/NewInstallerDialog.axaml +++ b/StabilityMatrix.Avalonia/Views/Dialogs/NewInstallerDialog.axaml @@ -30,43 +30,40 @@ CommandParameter="{Binding }"> - + - + - - + + - @@ -187,10 +184,10 @@ + + - Date: Tue, 2 Jan 2024 20:03:22 -0800 Subject: [PATCH 107/116] also set RecommendedSharedFolderMethod --- .../ViewModels/PackageInstallDetailViewModel.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/StabilityMatrix.Avalonia/ViewModels/PackageInstallDetailViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/PackageInstallDetailViewModel.cs index 72a155ab..bbb8cff0 100644 --- a/StabilityMatrix.Avalonia/ViewModels/PackageInstallDetailViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/PackageInstallDetailViewModel.cs @@ -109,6 +109,7 @@ public partial class PackageInstallDetailViewModel( } SelectedTorchVersion = SelectedPackage.GetRecommendedTorchVersion(); + SelectedSharedFolderMethod = SelectedPackage.RecommendedSharedFolderMethod; } [RelayCommand] From f582bf4d76ebe772f3e62c0d852ad374037ea2ce Mon Sep 17 00:00:00 2001 From: JT Date: Tue, 2 Jan 2024 20:31:43 -0800 Subject: [PATCH 108/116] ionite killed comfy manager & I added search to new packages page --- .../Dialogs/NewInstallerDialogViewModel.cs | 21 +++++- .../Views/Dialogs/NewInstallerDialog.axaml | 74 ++++++++++++++++--- .../Views/Dialogs/NewInstallerDialog.axaml.cs | 12 ++- .../Models/Packages/BasePackage.cs | 4 - .../Models/Packages/ComfyUI.cs | 3 - .../Packages/Extensions/ComfyManager.cs | 28 ------- 6 files changed, 93 insertions(+), 49 deletions(-) delete mode 100644 StabilityMatrix.Core/Models/Packages/Extensions/ComfyManager.cs diff --git a/StabilityMatrix.Avalonia/ViewModels/Dialogs/NewInstallerDialogViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/Dialogs/NewInstallerDialogViewModel.cs index b2c9d879..d041e4c1 100644 --- a/StabilityMatrix.Avalonia/ViewModels/Dialogs/NewInstallerDialogViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/Dialogs/NewInstallerDialogViewModel.cs @@ -38,6 +38,9 @@ public partial class NewInstallerDialogViewModel : PageViewModelBase [ObservableProperty] private bool showIncompatiblePackages = false; + [ObservableProperty] + private string searchFilter = string.Empty; + private SourceCache packageSource = new(p => p.GithubUrl); public IObservableCollection InferencePackages { get; } = @@ -63,13 +66,23 @@ public partial class NewInstallerDialogViewModel : PageViewModelBase this.pyRunner = pyRunner; this.prerequisiteHelper = prerequisiteHelper; - var searchPredicate = this.WhenPropertyChanged(vm => vm.ShowIncompatiblePackages) + var incompatiblePredicate = this.WhenPropertyChanged(vm => vm.ShowIncompatiblePackages) .Select(_ => new Func(p => p.IsCompatible || ShowIncompatiblePackages)) .AsObservable(); + var searchPredicate = this.WhenPropertyChanged(vm => vm.SearchFilter) + .Select( + _ => + new Func( + p => p.DisplayName.Contains(SearchFilter, StringComparison.OrdinalIgnoreCase) + ) + ) + .AsObservable(); + packageSource .Connect() .DeferUntilLoaded() + .Filter(incompatiblePredicate) .Filter(searchPredicate) .Where(p => p is { PackageType: PackageType.SdInference }) .Sort( @@ -83,6 +96,7 @@ public partial class NewInstallerDialogViewModel : PageViewModelBase packageSource .Connect() .DeferUntilLoaded() + .Filter(incompatiblePredicate) .Filter(searchPredicate) .Where(p => p is { PackageType: PackageType.SdTraining }) .Sort( @@ -124,4 +138,9 @@ public partial class NewInstallerDialogViewModel : PageViewModelBase DispatcherPriority.Send ); } + + public void ClearSearchQuery() + { + SearchFilter = string.Empty; + } } diff --git a/StabilityMatrix.Avalonia/Views/Dialogs/NewInstallerDialog.axaml b/StabilityMatrix.Avalonia/Views/Dialogs/NewInstallerDialog.axaml index bd98a96c..00ae0cb4 100644 --- a/StabilityMatrix.Avalonia/Views/Dialogs/NewInstallerDialog.axaml +++ b/StabilityMatrix.Avalonia/Views/Dialogs/NewInstallerDialog.axaml @@ -203,12 +203,37 @@ - + + + + + + + + + + + @@ -223,12 +248,37 @@ - + + + + + + + + + + + diff --git a/StabilityMatrix.Avalonia/Views/Dialogs/NewInstallerDialog.axaml.cs b/StabilityMatrix.Avalonia/Views/Dialogs/NewInstallerDialog.axaml.cs index 53ba4b81..3fbb2301 100644 --- a/StabilityMatrix.Avalonia/Views/Dialogs/NewInstallerDialog.axaml.cs +++ b/StabilityMatrix.Avalonia/Views/Dialogs/NewInstallerDialog.axaml.cs @@ -1,4 +1,6 @@ -using StabilityMatrix.Avalonia.Controls; +using Avalonia.Input; +using StabilityMatrix.Avalonia.Controls; +using StabilityMatrix.Avalonia.ViewModels.Dialogs; using StabilityMatrix.Core.Attributes; namespace StabilityMatrix.Avalonia.Views.Dialogs; @@ -10,4 +12,12 @@ public partial class NewInstallerDialog : UserControlBase { InitializeComponent(); } + + private void InputElement_OnKeyDown(object? sender, KeyEventArgs e) + { + if (e.Key == Key.Escape && DataContext is NewInstallerDialogViewModel vm) + { + vm.ClearSearchQuery(); + } + } } diff --git a/StabilityMatrix.Core/Models/Packages/BasePackage.cs b/StabilityMatrix.Core/Models/Packages/BasePackage.cs index 8cbdb81d..68fd939a 100644 --- a/StabilityMatrix.Core/Models/Packages/BasePackage.cs +++ b/StabilityMatrix.Core/Models/Packages/BasePackage.cs @@ -50,10 +50,6 @@ public abstract class BasePackage public virtual PackageType PackageType => PackageType.SdInference; - public virtual IEnumerable AvailableExtensions => Enumerable.Empty(); - - public virtual string ExtensionsFolderName => string.Empty; - public abstract Task DownloadPackage( string installLocation, DownloadPackageVersionOptions versionOptions, diff --git a/StabilityMatrix.Core/Models/Packages/ComfyUI.cs b/StabilityMatrix.Core/Models/Packages/ComfyUI.cs index 5c833a53..5ac92976 100644 --- a/StabilityMatrix.Core/Models/Packages/ComfyUI.cs +++ b/StabilityMatrix.Core/Models/Packages/ComfyUI.cs @@ -168,9 +168,6 @@ public class ComfyUI( public override string MainBranch => "master"; - public override IEnumerable AvailableExtensions => [new ComfyManager(PrerequisiteHelper)]; - public override string ExtensionsFolderName => "custom_nodes"; - public override IEnumerable AvailableTorchVersions => new[] { diff --git a/StabilityMatrix.Core/Models/Packages/Extensions/ComfyManager.cs b/StabilityMatrix.Core/Models/Packages/Extensions/ComfyManager.cs deleted file mode 100644 index 7bbaec88..00000000 --- a/StabilityMatrix.Core/Models/Packages/Extensions/ComfyManager.cs +++ /dev/null @@ -1,28 +0,0 @@ -using StabilityMatrix.Core.Helper; -using StabilityMatrix.Core.Models.FileInterfaces; - -namespace StabilityMatrix.Core.Models.Packages.Extensions; - -public class ComfyManager(IPrerequisiteHelper prerequisiteHelper) : ExtensionBase -{ - public override string RepoName => "ComfyUI-Manager"; - public override string DisplayName { get; set; } = "ComfyUI Manager"; - public override string Author => "ltdrdata"; - - public override string Blurb => - "ComfyUI-Manager is an extension designed to enhance the usability of ComfyUI. It offers management functions to install, remove, disable, and enable various custom nodes of ComfyUI."; - - public override IEnumerable CompatibleWith => [nameof(ComfyUI)]; - public override string MainBranch => "main"; - - public override Task InstallExtensionAsync( - DirectoryPath installDirectory, - string branch, - CancellationToken cancellationToken = default - ) - { - return Directory.Exists(Path.Combine(installDirectory, RepoName)) - ? Task.CompletedTask - : prerequisiteHelper.RunGit(new[] { "clone", GithubUrl }, installDirectory); - } -} From 3a2223cddadf8e5e49064f295a01841da74e5d53 Mon Sep 17 00:00:00 2001 From: JT Date: Tue, 2 Jan 2024 20:33:15 -0800 Subject: [PATCH 109/116] extensions ded --- .../PackageInstallDetailViewModel.cs | 27 ++----------------- .../Views/PackageInstallDetailView.axaml | 18 ------------- 2 files changed, 2 insertions(+), 43 deletions(-) diff --git a/StabilityMatrix.Avalonia/ViewModels/PackageInstallDetailViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/PackageInstallDetailViewModel.cs index bbb8cff0..cae6f84c 100644 --- a/StabilityMatrix.Avalonia/ViewModels/PackageInstallDetailViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/PackageInstallDetailViewModel.cs @@ -50,7 +50,6 @@ public partial class PackageInstallDetailViewModel( public string ReleaseLabelText => IsReleaseMode ? Resources.Label_Version : Resources.Label_Branch; public bool ShowTorchVersionOptions => SelectedTorchVersion != TorchVersion.None; - public bool ShowExtensions => SelectedPackage.AvailableExtensions.Any(); [ObservableProperty] [NotifyPropertyChangedFor(nameof(FullInstallPath))] @@ -82,9 +81,6 @@ public partial class PackageInstallDetailViewModel( [ObservableProperty] private GitCommit? selectedCommit; - [ObservableProperty] - private ObservableCollection availableExtensions = []; - private PackageVersionOptions? allOptions; public override async Task OnLoadedAsync() @@ -93,9 +89,6 @@ public partial class PackageInstallDetailViewModel( return; OnInstallNameChanged(InstallName); - AvailableExtensions = new ObservableCollection( - SelectedPackage.AvailableExtensions.Select(p => new ExtensionViewModel { Extension = p }) - ); allOptions = await SelectedPackage.GetAllVersionOptions(); if (ShowReleaseMode) @@ -171,16 +164,6 @@ public partial class PackageInstallDetailViewModel( downloadOptions, installLocation ); - var installExtensionSteps = AvailableExtensions - .Where(e => e.IsSelected) - .Select( - e => - new InstallExtensionStep( - e.Extension, - Path.Combine(installLocation, SelectedPackage.ExtensionsFolderName) - ) - ) - .ToList(); var setupModelFoldersStep = new SetupModelFoldersStep( SelectedPackage, @@ -209,16 +192,10 @@ public partial class PackageInstallDetailViewModel( prereqStep, downloadStep, installStep, + setupModelFoldersStep, + addInstalledPackageStep }; - if (installExtensionSteps.Count > 0) - { - steps.AddRange(installExtensionSteps); - } - - steps.Add(setupModelFoldersStep); - steps.Add(addInstalledPackageStep); - var runner = new PackageModificationRunner { ShowDialogOnStart = true }; EventManager.Instance.OnPackageInstallProgressAdded(runner); await runner.ExecuteSteps(steps.ToList()); diff --git a/StabilityMatrix.Avalonia/Views/PackageInstallDetailView.axaml b/StabilityMatrix.Avalonia/Views/PackageInstallDetailView.axaml index 9a826529..713d7e2e 100644 --- a/StabilityMatrix.Avalonia/Views/PackageInstallDetailView.axaml +++ b/StabilityMatrix.Avalonia/Views/PackageInstallDetailView.axaml @@ -97,24 +97,6 @@ - - - - - - - - - - - - - Date: Thu, 4 Jan 2024 09:58:47 +0800 Subject: [PATCH 110/116] Organize namespaces --- StabilityMatrix.Avalonia/DesignData/DesignData.cs | 9 +++------ .../StabilityMatrix.Avalonia.csproj | 6 +++++- .../ViewModels/NewPackageManagerViewModel.cs | 3 ++- .../PackageInstallBrowserViewModel.cs} | 13 +++++-------- .../PackageInstallDetailViewModel.cs | 4 ++-- .../ViewModels/PackageManagerViewModel.cs | 2 +- .../PackageInstallBrowserView.axaml} | 5 +++-- .../PackageInstallBrowserView.axaml.cs} | 10 +++++----- .../PackageInstallDetailView.axaml | 5 +++-- .../PackageInstallDetailView.axaml.cs | 2 +- 10 files changed, 30 insertions(+), 29 deletions(-) rename StabilityMatrix.Avalonia/ViewModels/{Dialogs/NewInstallerDialogViewModel.cs => PackageManager/PackageInstallBrowserViewModel.cs} (93%) rename StabilityMatrix.Avalonia/ViewModels/{ => PackageManager}/PackageInstallDetailViewModel.cs (98%) rename StabilityMatrix.Avalonia/Views/{Dialogs/NewInstallerDialog.axaml => PackageManager/PackageInstallBrowserView.axaml} (98%) rename StabilityMatrix.Avalonia/Views/{Dialogs/NewInstallerDialog.axaml.cs => PackageManager/PackageInstallBrowserView.axaml.cs} (50%) rename StabilityMatrix.Avalonia/Views/{ => PackageManager}/PackageInstallDetailView.axaml (97%) rename StabilityMatrix.Avalonia/Views/{ => PackageManager}/PackageInstallDetailView.axaml.cs (81%) diff --git a/StabilityMatrix.Avalonia/DesignData/DesignData.cs b/StabilityMatrix.Avalonia/DesignData/DesignData.cs index b112c6f6..9688f93d 100644 --- a/StabilityMatrix.Avalonia/DesignData/DesignData.cs +++ b/StabilityMatrix.Avalonia/DesignData/DesignData.cs @@ -8,13 +8,10 @@ using System.Linq; using System.Net.Http; using System.Text; using AvaloniaEdit.Utils; -using CommunityToolkit.Mvvm.ComponentModel; using DynamicData; using DynamicData.Binding; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging.Abstractions; using NSubstitute; -using NSubstitute.ReturnsExtensions; using Semver; using StabilityMatrix.Avalonia.Controls.CodeCompletion; using StabilityMatrix.Avalonia.Models; @@ -26,9 +23,9 @@ using StabilityMatrix.Avalonia.ViewModels.CheckpointBrowser; using StabilityMatrix.Avalonia.ViewModels.CheckpointManager; using StabilityMatrix.Avalonia.ViewModels.Dialogs; using StabilityMatrix.Avalonia.ViewModels.Inference; -using StabilityMatrix.Avalonia.ViewModels.Inference.Modules; using StabilityMatrix.Avalonia.ViewModels.Inference.Video; using StabilityMatrix.Avalonia.ViewModels.OutputsPage; +using StabilityMatrix.Avalonia.ViewModels.PackageManager; using StabilityMatrix.Avalonia.ViewModels.Progress; using StabilityMatrix.Avalonia.ViewModels.Settings; using StabilityMatrix.Core.Api; @@ -178,7 +175,7 @@ public static class DesignData }; LaunchOptionsViewModel.UpdateFilterCards(); - NewInstallerDialogViewModel = Services.GetRequiredService(); + NewInstallerDialogViewModel = Services.GetRequiredService(); // NewInstallerDialogViewModel.InferencePackages = new ObservableCollectionExtended( // packageFactory.GetPackagesByType(PackageType.SdInference).OrderBy(p => p.InstallerSortOrder) // ); @@ -418,7 +415,7 @@ public static class DesignData } [NotNull] - public static NewInstallerDialogViewModel? NewInstallerDialogViewModel { get; private set; } + public static PackageInstallBrowserViewModel? NewInstallerDialogViewModel { get; private set; } [NotNull] public static PackageInstallDetailViewModel? PackageInstallDetailViewModel { get; private set; } diff --git a/StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj b/StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj index 145a821a..51fd37cc 100644 --- a/StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj +++ b/StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj @@ -177,10 +177,14 @@ NewPackageManagerPage.axaml Code - + PackageInstallDetailView.axaml Code + + NewInstallerDialog.axaml + Code + diff --git a/StabilityMatrix.Avalonia/ViewModels/NewPackageManagerViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/NewPackageManagerViewModel.cs index ed751c8e..0cd0e689 100644 --- a/StabilityMatrix.Avalonia/ViewModels/NewPackageManagerViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/NewPackageManagerViewModel.cs @@ -6,6 +6,7 @@ using FluentAvalonia.UI.Controls; using StabilityMatrix.Avalonia.Services; using StabilityMatrix.Avalonia.ViewModels.Base; using StabilityMatrix.Avalonia.ViewModels.Dialogs; +using StabilityMatrix.Avalonia.ViewModels.PackageManager; using StabilityMatrix.Avalonia.Views; using StabilityMatrix.Core.Attributes; using Symbol = FluentIcons.Common.Symbol; @@ -33,7 +34,7 @@ public partial class NewPackageManagerViewModel : PageViewModelBase SubPages = new PageViewModelBase[] { vmFactory.Get(), - vmFactory.Get(), + vmFactory.Get(), }; CurrentPagePath.AddRange(SubPages); diff --git a/StabilityMatrix.Avalonia/ViewModels/Dialogs/NewInstallerDialogViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageInstallBrowserViewModel.cs similarity index 93% rename from StabilityMatrix.Avalonia/ViewModels/Dialogs/NewInstallerDialogViewModel.cs rename to StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageInstallBrowserViewModel.cs index d041e4c1..44ce5d4c 100644 --- a/StabilityMatrix.Avalonia/ViewModels/Dialogs/NewInstallerDialogViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageInstallBrowserViewModel.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; using System.Reactive.Linq; using Avalonia.Threading; using CommunityToolkit.Mvvm.ComponentModel; @@ -13,7 +10,7 @@ using Microsoft.Extensions.Logging; using StabilityMatrix.Avalonia.Animations; using StabilityMatrix.Avalonia.Services; using StabilityMatrix.Avalonia.ViewModels.Base; -using StabilityMatrix.Avalonia.Views.Dialogs; +using StabilityMatrix.Avalonia.Views.PackageManager; using StabilityMatrix.Core.Attributes; using StabilityMatrix.Core.Helper; using StabilityMatrix.Core.Helper.Factory; @@ -22,11 +19,11 @@ using StabilityMatrix.Core.Models.Packages; using StabilityMatrix.Core.Python; using StabilityMatrix.Core.Services; -namespace StabilityMatrix.Avalonia.ViewModels.Dialogs; +namespace StabilityMatrix.Avalonia.ViewModels.PackageManager; -[View(typeof(NewInstallerDialog))] +[View(typeof(PackageInstallBrowserView))] [Transient, ManagedService] -public partial class NewInstallerDialogViewModel : PageViewModelBase +public partial class PackageInstallBrowserViewModel : PageViewModelBase { private readonly INavigationService packageNavigationService; private readonly ISettingsManager settingsManager; @@ -49,7 +46,7 @@ public partial class NewInstallerDialogViewModel : PageViewModelBase public IObservableCollection TrainingPackages { get; } = new ObservableCollectionExtended(); - public NewInstallerDialogViewModel( + public PackageInstallBrowserViewModel( IPackageFactory packageFactory, INavigationService packageNavigationService, ISettingsManager settingsManager, diff --git a/StabilityMatrix.Avalonia/ViewModels/PackageInstallDetailViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageInstallDetailViewModel.cs similarity index 98% rename from StabilityMatrix.Avalonia/ViewModels/PackageInstallDetailViewModel.cs rename to StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageInstallDetailViewModel.cs index cae6f84c..f6022e1b 100644 --- a/StabilityMatrix.Avalonia/ViewModels/PackageInstallDetailViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageInstallDetailViewModel.cs @@ -15,7 +15,6 @@ using StabilityMatrix.Avalonia.Extensions; using StabilityMatrix.Avalonia.Languages; using StabilityMatrix.Avalonia.Services; using StabilityMatrix.Avalonia.ViewModels.Base; -using StabilityMatrix.Avalonia.Views; using StabilityMatrix.Core.Attributes; using StabilityMatrix.Core.Helper; using StabilityMatrix.Core.Models; @@ -25,9 +24,10 @@ using StabilityMatrix.Core.Models.PackageModification; using StabilityMatrix.Core.Models.Packages; using StabilityMatrix.Core.Python; using StabilityMatrix.Core.Services; +using PackageInstallDetailView = StabilityMatrix.Avalonia.Views.PackageManager.PackageInstallDetailView; using SymbolIconSource = FluentIcons.FluentAvalonia.SymbolIconSource; -namespace StabilityMatrix.Avalonia.ViewModels; +namespace StabilityMatrix.Avalonia.ViewModels.PackageManager; [View(typeof(PackageInstallDetailView))] public partial class PackageInstallDetailViewModel( diff --git a/StabilityMatrix.Avalonia/ViewModels/PackageManagerViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/PackageManagerViewModel.cs index 950abf1f..3fc0b95e 100644 --- a/StabilityMatrix.Avalonia/ViewModels/PackageManagerViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/PackageManagerViewModel.cs @@ -138,7 +138,7 @@ public partial class PackageManagerViewModel : PageViewModelBase public void ShowInstallDialog(BasePackage? selectedPackage = null) { - NavigateToSubPage(typeof(NewInstallerDialogViewModel)); + NavigateToSubPage(typeof(PackageInstallBrowserViewModel)); } private async Task CheckPackagesForUpdates() diff --git a/StabilityMatrix.Avalonia/Views/Dialogs/NewInstallerDialog.axaml b/StabilityMatrix.Avalonia/Views/PackageManager/PackageInstallBrowserView.axaml similarity index 98% rename from StabilityMatrix.Avalonia/Views/Dialogs/NewInstallerDialog.axaml rename to StabilityMatrix.Avalonia/Views/PackageManager/PackageInstallBrowserView.axaml index 00ae0cb4..dc8ba2ca 100644 --- a/StabilityMatrix.Avalonia/Views/Dialogs/NewInstallerDialog.axaml +++ b/StabilityMatrix.Avalonia/Views/PackageManager/PackageInstallBrowserView.axaml @@ -10,10 +10,11 @@ xmlns:controls1="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia" xmlns:input="clr-namespace:FluentAvalonia.UI.Input;assembly=FluentAvalonia" xmlns:lang="clr-namespace:StabilityMatrix.Avalonia.Languages" + xmlns:packageManager="clr-namespace:StabilityMatrix.Avalonia.ViewModels.PackageManager" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" - x:DataType="dialogs:NewInstallerDialogViewModel" + x:DataType="packageManager:PackageInstallBrowserViewModel" d:DataContext="{x:Static mocks:DesignData.NewInstallerDialogViewModel}" - x:Class="StabilityMatrix.Avalonia.Views.Dialogs.NewInstallerDialog"> + x:Class="StabilityMatrix.Avalonia.Views.PackageManager.PackageInstallBrowserView"> + x:Class="StabilityMatrix.Avalonia.Views.PackageManager.PackageInstallDetailView"> diff --git a/StabilityMatrix.Avalonia/Views/PackageInstallDetailView.axaml.cs b/StabilityMatrix.Avalonia/Views/PackageManager/PackageInstallDetailView.axaml.cs similarity index 81% rename from StabilityMatrix.Avalonia/Views/PackageInstallDetailView.axaml.cs rename to StabilityMatrix.Avalonia/Views/PackageManager/PackageInstallDetailView.axaml.cs index 0973e814..606bef95 100644 --- a/StabilityMatrix.Avalonia/Views/PackageInstallDetailView.axaml.cs +++ b/StabilityMatrix.Avalonia/Views/PackageManager/PackageInstallDetailView.axaml.cs @@ -1,7 +1,7 @@ using StabilityMatrix.Avalonia.Controls; using StabilityMatrix.Core.Attributes; -namespace StabilityMatrix.Avalonia.Views; +namespace StabilityMatrix.Avalonia.Views.PackageManager; [Transient] public partial class PackageInstallDetailView : UserControlBase From bc463dfbbff977b435439c54c2ef4105e11902fa Mon Sep 17 00:00:00 2001 From: ionite34 Date: Thu, 4 Jan 2024 09:58:59 +0800 Subject: [PATCH 111/116] Fix exit freeze on macos --- StabilityMatrix.Avalonia/App.axaml.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/StabilityMatrix.Avalonia/App.axaml.cs b/StabilityMatrix.Avalonia/App.axaml.cs index 25a2d0e2..d4bba201 100644 --- a/StabilityMatrix.Avalonia/App.axaml.cs +++ b/StabilityMatrix.Avalonia/App.axaml.cs @@ -590,6 +590,11 @@ public sealed class App : Application { var result = lifetime.TryShutdown(exitCode); Debug.WriteLine($"Shutdown: {result}"); + + if (result) + { + Environment.Exit(exitCode); + } } catch (InvalidOperationException) { From bd128a09367c0726b170493ec2f6a5a1e9015e07 Mon Sep 17 00:00:00 2001 From: ionite34 Date: Thu, 4 Jan 2024 10:01:19 +0800 Subject: [PATCH 112/116] cleanup --- .../PackageManager/PackageInstallBrowserViewModel.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageInstallBrowserViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageInstallBrowserViewModel.cs index 44ce5d4c..34d78439 100644 --- a/StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageInstallBrowserViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageInstallBrowserViewModel.cs @@ -33,7 +33,7 @@ public partial class PackageInstallBrowserViewModel : PageViewModelBase private readonly IPrerequisiteHelper prerequisiteHelper; [ObservableProperty] - private bool showIncompatiblePackages = false; + private bool showIncompatiblePackages; [ObservableProperty] private string searchFilter = string.Empty; @@ -113,7 +113,7 @@ public partial class PackageInstallBrowserViewModel : PageViewModelBase public override string Title => "Add Package"; public override IconSource IconSource => new SymbolIconSource { Symbol = Symbol.Add }; - public void OnPackageSelected(BaseGitPackage package) + public void OnPackageSelected(BaseGitPackage? package) { if (package is null) { From ae9a9d3f61a0aca632618650dde32fd7342d8fc8 Mon Sep 17 00:00:00 2001 From: ionite34 Date: Thu, 4 Jan 2024 11:17:33 +0800 Subject: [PATCH 113/116] Fix ConnectionHelp navigation to installer --- .../Models/PackageManagerNavigationOptions.cs | 10 +++++++ .../InferenceConnectionHelpViewModel.cs | 17 +++++------ .../PackageInstallBrowserViewModel.cs | 2 +- .../PackageInstallDetailViewModel.cs | 4 +-- .../Views/NewPackageManagerPage.axaml.cs | 28 +++++++++++++++++++ .../Views/PackageManagerPage.axaml.cs | 8 +----- 6 files changed, 51 insertions(+), 18 deletions(-) create mode 100644 StabilityMatrix.Avalonia/Models/PackageManagerNavigationOptions.cs diff --git a/StabilityMatrix.Avalonia/Models/PackageManagerNavigationOptions.cs b/StabilityMatrix.Avalonia/Models/PackageManagerNavigationOptions.cs new file mode 100644 index 00000000..18982f9a --- /dev/null +++ b/StabilityMatrix.Avalonia/Models/PackageManagerNavigationOptions.cs @@ -0,0 +1,10 @@ +using StabilityMatrix.Core.Models.Packages; + +namespace StabilityMatrix.Avalonia.Models; + +public record PackageManagerNavigationOptions +{ + public bool OpenInstallerDialog { get; init; } + + public BasePackage? InstallerSelectedPackage { get; init; } +} diff --git a/StabilityMatrix.Avalonia/ViewModels/Dialogs/InferenceConnectionHelpViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/Dialogs/InferenceConnectionHelpViewModel.cs index aad4cc87..fafd1206 100644 --- a/StabilityMatrix.Avalonia/ViewModels/Dialogs/InferenceConnectionHelpViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/Dialogs/InferenceConnectionHelpViewModel.cs @@ -8,6 +8,7 @@ using CommunityToolkit.Mvvm.Input; using FluentAvalonia.UI.Controls; using StabilityMatrix.Avalonia.Controls; using StabilityMatrix.Avalonia.Languages; +using StabilityMatrix.Avalonia.Models; using StabilityMatrix.Avalonia.Services; using StabilityMatrix.Avalonia.ViewModels.Base; using StabilityMatrix.Avalonia.Views; @@ -65,8 +66,9 @@ public partial class InferenceConnectionHelpViewModel : ContentDialogViewModelBa this.packageFactory = packageFactory; // Get comfy type installed packages - var comfyPackages = this.settingsManager.Settings.InstalledPackages - .Where(p => p.PackageName == "ComfyUI") + var comfyPackages = this.settingsManager.Settings.InstalledPackages.Where( + p => p.PackageName == "ComfyUI" + ) .ToImmutableArray(); InstalledPackages = comfyPackages; @@ -103,13 +105,14 @@ public partial class InferenceConnectionHelpViewModel : ContentDialogViewModelBa { Dispatcher.UIThread.Post(() => { - navigationService.NavigateTo( - param: new PackageManagerPage.PackageManagerNavigationOptions + navigationService.NavigateTo( + param: new PackageManagerNavigationOptions { OpenInstallerDialog = true, InstallerSelectedPackage = packageFactory .GetAllAvailablePackages() - .First(p => p is ComfyUI) + .OfType() + .First() } ); }); @@ -138,9 +141,7 @@ public partial class InferenceConnectionHelpViewModel : ContentDialogViewModelBa var dialog = new BetterContentDialog { Content = new InferenceConnectionHelpDialog { DataContext = this }, - PrimaryButtonCommand = IsInstallMode - ? NavigateToInstallCommand - : LaunchSelectedPackageCommand, + PrimaryButtonCommand = IsInstallMode ? NavigateToInstallCommand : LaunchSelectedPackageCommand, PrimaryButtonText = IsInstallMode ? Resources.Action_Install : Resources.Action_Launch, CloseButtonText = Resources.Action_Close, DefaultButton = ContentDialogButton.Primary diff --git a/StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageInstallBrowserViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageInstallBrowserViewModel.cs index 34d78439..e38770ac 100644 --- a/StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageInstallBrowserViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageInstallBrowserViewModel.cs @@ -113,7 +113,7 @@ public partial class PackageInstallBrowserViewModel : PageViewModelBase public override string Title => "Add Package"; public override IconSource IconSource => new SymbolIconSource { Symbol = Symbol.Add }; - public void OnPackageSelected(BaseGitPackage? package) + public void OnPackageSelected(BasePackage? package) { if (package is null) { diff --git a/StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageInstallDetailViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageInstallDetailViewModel.cs index f6022e1b..3c940d25 100644 --- a/StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageInstallDetailViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageInstallDetailViewModel.cs @@ -31,7 +31,7 @@ namespace StabilityMatrix.Avalonia.ViewModels.PackageManager; [View(typeof(PackageInstallDetailView))] public partial class PackageInstallDetailViewModel( - BaseGitPackage package, + BasePackage package, ISettingsManager settingsManager, INotificationService notificationService, ILogger logger, @@ -40,7 +40,7 @@ public partial class PackageInstallDetailViewModel( INavigationService packageNavigationService ) : PageViewModelBase { - public BaseGitPackage SelectedPackage { get; } = package; + public BasePackage SelectedPackage { get; } = package; public override string Title { get; } = package.DisplayName; public override IconSource IconSource => new SymbolIconSource(); diff --git a/StabilityMatrix.Avalonia/Views/NewPackageManagerPage.axaml.cs b/StabilityMatrix.Avalonia/Views/NewPackageManagerPage.axaml.cs index a503d34a..6fdeb5d4 100644 --- a/StabilityMatrix.Avalonia/Views/NewPackageManagerPage.axaml.cs +++ b/StabilityMatrix.Avalonia/Views/NewPackageManagerPage.axaml.cs @@ -13,6 +13,7 @@ using StabilityMatrix.Avalonia.Models; using StabilityMatrix.Avalonia.Services; using StabilityMatrix.Avalonia.ViewModels; using StabilityMatrix.Avalonia.ViewModels.Base; +using StabilityMatrix.Avalonia.ViewModels.PackageManager; using StabilityMatrix.Core.Attributes; using StabilityMatrix.Core.Models; @@ -38,6 +39,8 @@ public partial class NewPackageManagerPage : UserControlBase, IHandleNavigation InitializeComponent(); + AddHandler(Frame.NavigatedToEvent, OnNavigatedTo, RoutingStrategies.Direct); + packageNavigationService.SetFrame(FrameView); packageNavigationService.TypedNavigation += NavigationService_OnTypedNavigation; FrameView.Navigated += FrameView_Navigated; @@ -64,6 +67,31 @@ public partial class NewPackageManagerPage : UserControlBase, IHandleNavigation } } + /// + /// Handle navigation events to this page + /// + private void OnNavigatedTo(object? sender, NavigationEventArgs args) + { + if (args.Parameter is PackageManagerNavigationOptions { OpenInstallerDialog: true } options) + { + var vm = (NewPackageManagerViewModel)DataContext!; + + Dispatcher.UIThread.Post( + () => + { + // Navigate to the installer page + packageNavigationService.NavigateTo(); + + // Select the package + vm.SubPages.OfType() + .First() + .OnPackageSelected(options.InstallerSelectedPackage); + }, + DispatcherPriority.Send + ); + } + } + private void NavigationService_OnTypedNavigation(object? sender, TypedNavigationEventArgs e) { ViewModel.CurrentPage = diff --git a/StabilityMatrix.Avalonia/Views/PackageManagerPage.axaml.cs b/StabilityMatrix.Avalonia/Views/PackageManagerPage.axaml.cs index e017decf..cca1d38a 100644 --- a/StabilityMatrix.Avalonia/Views/PackageManagerPage.axaml.cs +++ b/StabilityMatrix.Avalonia/Views/PackageManagerPage.axaml.cs @@ -4,6 +4,7 @@ using Avalonia.Threading; using FluentAvalonia.UI.Controls; using FluentAvalonia.UI.Navigation; using StabilityMatrix.Avalonia.Controls; +using StabilityMatrix.Avalonia.Models; using StabilityMatrix.Avalonia.ViewModels; using StabilityMatrix.Core.Attributes; using StabilityMatrix.Core.Models.Packages; @@ -39,11 +40,4 @@ public partial class PackageManagerPage : UserControlBase }); } } - - public record PackageManagerNavigationOptions - { - public bool OpenInstallerDialog { get; init; } - - public BasePackage? InstallerSelectedPackage { get; init; } - } } From 871a0cda5cab79fba0046cd9f8559b5fe26a393f Mon Sep 17 00:00:00 2001 From: JT Date: Wed, 3 Jan 2024 21:50:02 -0800 Subject: [PATCH 114/116] - Added `--use-directml` launch argument for SDWebUI DirectML fork - Changed default Period to "AllTime" in the Model Browser - Fixed SDTurboScheduler's missing denoise parameter --- .../CivitAiBrowserViewModel.cs | 57 +++++++++++++++---- .../InferenceTextToImageViewModel.cs | 8 +++ .../Inference/SamplerCardViewModel.cs | 18 ++++-- .../Api/Comfy/Nodes/ComfyNodeBuilder.cs | 45 ++++++++++++--- .../Packages/StableDiffusionDirectMl.cs | 28 +++++++-- 5 files changed, 128 insertions(+), 28 deletions(-) diff --git a/StabilityMatrix.Avalonia/ViewModels/CheckpointBrowser/CivitAiBrowserViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/CheckpointBrowser/CivitAiBrowserViewModel.cs index 2d9cef4b..2911dc6b 100644 --- a/StabilityMatrix.Avalonia/ViewModels/CheckpointBrowser/CivitAiBrowserViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/CheckpointBrowser/CivitAiBrowserViewModel.cs @@ -72,7 +72,7 @@ public partial class CivitAiBrowserViewModel : TabViewModelBase private bool showMainLoadingSpinner; [ObservableProperty] - private CivitPeriod selectedPeriod = CivitPeriod.Month; + private CivitPeriod selectedPeriod = CivitPeriod.AllTime; [ObservableProperty] private CivitSortMode sortMode = CivitSortMode.HighestRated; @@ -118,8 +118,10 @@ public partial class CivitAiBrowserViewModel : TabViewModelBase private List allModelCards = new(); - public IEnumerable AllCivitPeriods => Enum.GetValues(typeof(CivitPeriod)).Cast(); - public IEnumerable AllSortModes => Enum.GetValues(typeof(CivitSortMode)).Cast(); + public IEnumerable AllCivitPeriods => + Enum.GetValues(typeof(CivitPeriod)).Cast(); + public IEnumerable AllSortModes => + Enum.GetValues(typeof(CivitSortMode)).Cast(); public IEnumerable AllModelTypes => Enum.GetValues(typeof(CivitModelType)) @@ -128,7 +130,17 @@ public partial class CivitAiBrowserViewModel : TabViewModelBase .OrderBy(t => t.ToString()); public List BaseModelOptions => - ["All", "SD 1.5", "SD 1.5 LCM", "SD 2.1", "SDXL 0.9", "SDXL 1.0", "SDXL 1.0 LCM", "SDXL Turbo", "Other"]; + [ + "All", + "SD 1.5", + "SD 1.5 LCM", + "SD 2.1", + "SDXL 0.9", + "SDXL 1.0", + "SDXL 1.0 LCM", + "SDXL Turbo", + "Other" + ]; public CivitAiBrowserViewModel( ICivitApi civitApi, @@ -189,7 +201,11 @@ public partial class CivitAiBrowserViewModel : TabViewModelBase ShowNsfw = settingsManager.Settings.ModelBrowserNsfwEnabled; - settingsManager.RelayPropertyFor(this, model => model.ShowNsfw, settings => settings.ModelBrowserNsfwEnabled); + settingsManager.RelayPropertyFor( + this, + model => model.ShowNsfw, + settings => settings.ModelBrowserNsfwEnabled + ); } /// @@ -238,7 +254,10 @@ public partial class CivitAiBrowserViewModel : TabViewModelBase } // Filter out unknown model types and archived/taken-down models - models = models.Where(m => m.Type.ConvertTo() > 0).Where(m => m.Mode == null).ToList(); + models = models + .Where(m => m.Type.ConvertTo() > 0) + .Where(m => m.Mode == null) + .ToList(); // Database update calls will invoke `OnModelsUpdated` // Add to database @@ -451,8 +470,7 @@ public partial class CivitAiBrowserViewModel : TabViewModelBase try { cachedQuery = await liteDbContext - .CivitModelQueryCache - .IncludeAll() + .CivitModelQueryCache.IncludeAll() .FindByIdAsync(ObjectHash.GetMd5Guid(modelRequest)); } catch (Exception e) @@ -556,7 +574,12 @@ public partial class CivitAiBrowserViewModel : TabViewModelBase TrySearchAgain().SafeFireAndForget(); settingsManager.Transaction( s => - s.ModelSearchOptions = new ModelSearchOptions(value, SortMode, SelectedModelType, SelectedBaseModelType) + s.ModelSearchOptions = new ModelSearchOptions( + value, + SortMode, + SelectedModelType, + SelectedBaseModelType + ) ); } @@ -578,7 +601,13 @@ public partial class CivitAiBrowserViewModel : TabViewModelBase { TrySearchAgain().SafeFireAndForget(); settingsManager.Transaction( - s => s.ModelSearchOptions = new ModelSearchOptions(SelectedPeriod, SortMode, value, SelectedBaseModelType) + s => + s.ModelSearchOptions = new ModelSearchOptions( + SelectedPeriod, + SortMode, + value, + SelectedBaseModelType + ) ); } @@ -586,7 +615,13 @@ public partial class CivitAiBrowserViewModel : TabViewModelBase { TrySearchAgain().SafeFireAndForget(); settingsManager.Transaction( - s => s.ModelSearchOptions = new ModelSearchOptions(SelectedPeriod, SortMode, SelectedModelType, value) + s => + s.ModelSearchOptions = new ModelSearchOptions( + SelectedPeriod, + SortMode, + SelectedModelType, + value + ) ); } diff --git a/StabilityMatrix.Avalonia/ViewModels/Inference/InferenceTextToImageViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/Inference/InferenceTextToImageViewModel.cs index 1c0caa13..052986be 100644 --- a/StabilityMatrix.Avalonia/ViewModels/Inference/InferenceTextToImageViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/Inference/InferenceTextToImageViewModel.cs @@ -114,6 +114,14 @@ public class InferenceTextToImageViewModel : InferenceGenerationViewModelBase, I SamplerCardViewModel.IsRefinerStepsEnabled = e.Sender is { IsRefinerSelectionEnabled: true, SelectedRefiner: not null }; }); + + SamplerCardViewModel + .WhenPropertyChanged(x => x.SelectedScheduler) + .Subscribe(e => + { + e.Sender.IsDenoiseStrengthEnabled = + e.Sender.SelectedScheduler?.DisplayName.Equals("SD Turbo") ?? false; + }); } /// diff --git a/StabilityMatrix.Avalonia/ViewModels/Inference/SamplerCardViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/Inference/SamplerCardViewModel.cs index a129696f..96b9de36 100644 --- a/StabilityMatrix.Avalonia/ViewModels/Inference/SamplerCardViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/Inference/SamplerCardViewModel.cs @@ -88,7 +88,10 @@ public partial class SamplerCardViewModel : LoadableViewModelBase, IParametersLo private int TotalSteps => Steps + RefinerSteps; - public SamplerCardViewModel(IInferenceClientManager clientManager, ServiceManager vmFactory) + public SamplerCardViewModel( + IInferenceClientManager clientManager, + ServiceManager vmFactory + ) { ClientManager = clientManager; ModulesCardViewModel = vmFactory.Get(modulesCard => @@ -102,7 +105,10 @@ public partial class SamplerCardViewModel : LoadableViewModelBase, IParametersLo public void ApplyStep(ModuleApplyStepEventArgs e) { // Resample the current primary if size does not match the selected size - if (e.Builder.Connections.PrimarySize.Width != Width || e.Builder.Connections.PrimarySize.Height != Height) + if ( + e.Builder.Connections.PrimarySize.Width != Width + || e.Builder.Connections.PrimarySize.Height != Height + ) { e.Builder.Connections.Primary = e.Builder.Group_Upscale( e.Nodes.GetUniqueName("Sampler_ScalePrimary"), @@ -170,7 +176,8 @@ public partial class SamplerCardViewModel : LoadableViewModelBase, IParametersLo { Name = "SDTurboScheduler", Model = e.Builder.Connections.Base.Model.Unwrap(), - Steps = Steps + Steps = Steps, + Denoise = DenoiseStrength } ); @@ -297,7 +304,10 @@ public partial class SamplerCardViewModel : LoadableViewModelBase, IParametersLo if ( !string.IsNullOrEmpty(parameters.Sampler) - && GenerationParametersConverter.TryGetSamplerScheduler(parameters.Sampler, out var samplerScheduler) + && GenerationParametersConverter.TryGetSamplerScheduler( + parameters.Sampler, + out var samplerScheduler + ) ) { SelectedSampler = ClientManager.Samplers.FirstOrDefault(s => s == samplerScheduler.Sampler); diff --git a/StabilityMatrix.Core/Models/Api/Comfy/Nodes/ComfyNodeBuilder.cs b/StabilityMatrix.Core/Models/Api/Comfy/Nodes/ComfyNodeBuilder.cs index 45f847fb..874397ef 100644 --- a/StabilityMatrix.Core/Models/Api/Comfy/Nodes/ComfyNodeBuilder.cs +++ b/StabilityMatrix.Core/Models/Api/Comfy/Nodes/ComfyNodeBuilder.cs @@ -110,6 +110,9 @@ public class ComfyNodeBuilder [Range(1, 10)] public required int Steps { get; init; } + + [Range(0, 1.0)] + public required double Denoise { get; init; } } public record EmptyLatentImage : ComfyTypedNodeBase @@ -155,7 +158,11 @@ public class ComfyNodeBuilder return new NamedComfyNode(name) { ClassType = "ImageUpscaleWithModel", - Inputs = new Dictionary { ["upscale_model"] = upscaleModel.Data, ["image"] = image.Data } + Inputs = new Dictionary + { + ["upscale_model"] = upscaleModel.Data, + ["image"] = image.Data + } }; } @@ -286,7 +293,8 @@ public class ComfyNodeBuilder public required string ControlNetName { get; init; } } - public record ControlNetApplyAdvanced : ComfyTypedNodeBase + public record ControlNetApplyAdvanced + : ComfyTypedNodeBase { public required ConditioningNodeConnection Positive { get; init; } public required ConditioningNodeConnection Negative { get; init; } @@ -409,7 +417,9 @@ public class ComfyNodeBuilder .Output, image => Nodes - .AddNamedNode(ImageScale($"{name}_ImageUpscale", image, upscaleInfo.Name, height, width, false)) + .AddNamedNode( + ImageScale($"{name}_ImageUpscale", image, upscaleInfo.Name, height, width, false) + ) .Output ); } @@ -420,7 +430,11 @@ public class ComfyNodeBuilder var samplerImage = GetPrimaryAsImage(primary, vae); // Do group upscale - var modelUpscaler = Group_UpscaleWithModel($"{name}_ModelUpscale", upscaleInfo.Name, samplerImage); + var modelUpscaler = Group_UpscaleWithModel( + $"{name}_ModelUpscale", + upscaleInfo.Name, + samplerImage + ); // Since the model upscale is fixed to model (2x/4x), scale it again to the requested size var resizedScaled = Nodes.AddNamedNode( @@ -476,7 +490,11 @@ public class ComfyNodeBuilder ); // Do group upscale - var modelUpscaler = Group_UpscaleWithModel($"{name}_ModelUpscale", upscaleInfo.Name, samplerImage.Output); + var modelUpscaler = Group_UpscaleWithModel( + $"{name}_ModelUpscale", + upscaleInfo.Name, + samplerImage.Output + ); // Since the model upscale is fixed to model (2x/4x), scale it again to the requested size var resizedScaled = Nodes.AddNamedNode( @@ -550,7 +568,11 @@ public class ComfyNodeBuilder ); // Do group upscale - var modelUpscaler = Group_UpscaleWithModel($"{name}_ModelUpscale", upscaleInfo.Name, samplerImage.Output); + var modelUpscaler = Group_UpscaleWithModel( + $"{name}_ModelUpscale", + upscaleInfo.Name, + samplerImage.Output + ); // Since the model upscale is fixed to model (2x/4x), scale it again to the requested size var resizedScaled = Nodes.AddNamedNode( @@ -750,7 +772,10 @@ public class ComfyNodeBuilder return Connections.Primary.AsT1; } - return GetPrimaryAsImage(Connections.Primary ?? throw new NullReferenceException("No primary connection"), vae); + return GetPrimaryAsImage( + Connections.Primary ?? throw new NullReferenceException("No primary connection"), + vae + ); } /// @@ -771,7 +796,7 @@ public class ComfyNodeBuilder public ClipNodeConnection? BaseClip { get; set; } public ClipVisionNodeConnection? BaseClipVision { get; set; } - + public Dictionary Models { get; } = new() { ["Base"] = new ModelConnections("Base"), ["Refiner"] = new ModelConnections("Refiner") }; @@ -796,7 +821,9 @@ public class ComfyNodeBuilder public ModelNodeConnection GetRefinerOrBaseModel() { - return Refiner.Model ?? Base.Model ?? throw new NullReferenceException("No Refiner or Base Model"); + return Refiner.Model + ?? Base.Model + ?? throw new NullReferenceException("No Refiner or Base Model"); } public ConditioningConnections GetRefinerOrBaseConditioning() diff --git a/StabilityMatrix.Core/Models/Packages/StableDiffusionDirectMl.cs b/StabilityMatrix.Core/Models/Packages/StableDiffusionDirectMl.cs index 34321d04..b1687c33 100644 --- a/StabilityMatrix.Core/Models/Packages/StableDiffusionDirectMl.cs +++ b/StabilityMatrix.Core/Models/Packages/StableDiffusionDirectMl.cs @@ -1,10 +1,8 @@ -using System.Diagnostics.CodeAnalysis; -using System.Text.Json.Nodes; -using System.Text.RegularExpressions; -using NLog; +using NLog; using StabilityMatrix.Core.Attributes; using StabilityMatrix.Core.Helper; using StabilityMatrix.Core.Helper.Cache; +using StabilityMatrix.Core.Helper.HardwareInfo; using StabilityMatrix.Core.Models.FileInterfaces; using StabilityMatrix.Core.Models.Progress; using StabilityMatrix.Core.Processes; @@ -38,9 +36,31 @@ public class StableDiffusionDirectMl( public override PackageDifficulty InstallerSortOrder => PackageDifficulty.Recommended; + public override List LaunchOptions + { + get + { + var baseLaunchOptions = base.LaunchOptions; + baseLaunchOptions.Insert( + 0, + new LaunchOptionDefinition + { + Name = "Use DirectML", + Type = LaunchOptionType.Bool, + InitialValue = HardwareHelper.PreferDirectML(), + Options = ["--use-directml"] + } + ); + + return baseLaunchOptions; + } + } + public override IEnumerable AvailableTorchVersions => new[] { TorchVersion.Cpu, TorchVersion.DirectMl }; + public override TorchVersion GetRecommendedTorchVersion() => TorchVersion.DirectMl; + public override bool ShouldIgnoreReleases => true; public override async Task InstallPackage( From 04e38d2fdcae27524d964494eb8d04751d474f70 Mon Sep 17 00:00:00 2001 From: JT Date: Wed, 3 Jan 2024 21:52:27 -0800 Subject: [PATCH 115/116] chagenlog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44c7e891..ed41a71c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,12 @@ and this project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2 ## v2.8.0-dev.4 ### Added - Auto-update support for macOS +- New package installation flow +- Added `--use-directml` launch argument for SDWebUI DirectML fork +### Changed +- Changed default Period to "AllTime" in the Model Browser +### Fixed +- Fixed SDTurboScheduler's missing denoise parameter ## v2.8.0-dev.3 ### Added From fc6ef780e74ebc771fbb3104bde0e7e0afb6f24a Mon Sep 17 00:00:00 2001 From: JT Date: Wed, 3 Jan 2024 22:44:13 -0800 Subject: [PATCH 116/116] fix build errors --- .../Dialogs/SelectModelVersionViewModel.cs | 2 ++ .../Packages/StableDiffusionDirectMl.cs | 23 ------------------- 2 files changed, 2 insertions(+), 23 deletions(-) diff --git a/StabilityMatrix.Avalonia/ViewModels/Dialogs/SelectModelVersionViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/Dialogs/SelectModelVersionViewModel.cs index 2f790761..ef7c2ddf 100644 --- a/StabilityMatrix.Avalonia/ViewModels/Dialogs/SelectModelVersionViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/Dialogs/SelectModelVersionViewModel.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.IO; using System.Linq; using System.Threading.Tasks; using Avalonia.Controls.Notifications; @@ -15,6 +16,7 @@ using StabilityMatrix.Avalonia.Services; using StabilityMatrix.Avalonia.ViewModels.Base; using StabilityMatrix.Core.Attributes; using StabilityMatrix.Core.Helper; +using StabilityMatrix.Core.Models.FileInterfaces; using StabilityMatrix.Core.Services; namespace StabilityMatrix.Avalonia.ViewModels.Dialogs; diff --git a/StabilityMatrix.Core/Models/Packages/StableDiffusionDirectMl.cs b/StabilityMatrix.Core/Models/Packages/StableDiffusionDirectMl.cs index c86db42b..341f62d0 100644 --- a/StabilityMatrix.Core/Models/Packages/StableDiffusionDirectMl.cs +++ b/StabilityMatrix.Core/Models/Packages/StableDiffusionDirectMl.cs @@ -31,7 +31,6 @@ public class StableDiffusionDirectMl( public override string LaunchCommand => "launch.py"; public override Uri PreviewImageUri => new("https://github.com/lshqqytiger/stable-diffusion-webui-directml/raw/master/screenshot.png"); - public override SharedFolderMethod RecommendedSharedFolderMethod => SharedFolderMethod.Symlink; public override TorchVersion GetRecommendedTorchVersion() => TorchVersion.DirectMl; @@ -61,30 +60,8 @@ public class StableDiffusionDirectMl( public override IEnumerable AvailableTorchVersions => new[] { TorchVersion.Cpu, TorchVersion.DirectMl }; - public override TorchVersion GetRecommendedTorchVersion() => TorchVersion.DirectMl; - public override bool ShouldIgnoreReleases => true; - public override List LaunchOptions - { - get - { - var baseLaunchOptions = base.LaunchOptions; - baseLaunchOptions.Insert( - 0, - new LaunchOptionDefinition - { - Name = "Use DirectML", - Type = LaunchOptionType.Bool, - InitialValue = HardwareHelper.PreferDirectML(), - Options = ["--use-directml"] - } - ); - - return baseLaunchOptions; - } - } - public override async Task InstallPackage( string installLocation, TorchVersion torchVersion,