From 48bc532b0b1e2b00662c6cd64c0cc64f33736a26 Mon Sep 17 00:00:00 2001 From: JT Date: Tue, 22 Aug 2023 22:30:24 -0700 Subject: [PATCH] Buncha Stuff - Added "Skip to First/Last Page" buttons to the Model Browser - Added VAE as a checkpoint category in the Model Browser - Model Browser navigation buttons are no longer disabled while changing pages - Fixed issue where Open Web UI button would try to load 0.0.0.0 addresses - Added missing CivitModelFpTypes - Made a property for "OfferInOneClickInstaller" so we can selectively show things (for stuff like kohya eventually) - Fix Show Web UI button not appearing for Fooocus --- CHANGELOG.md | 4 ++ .../ViewModels/CheckpointBrowserViewModel.cs | 58 +++++++++++++++---- .../Dialogs/OneClickInstallViewModel.cs | 4 +- .../ViewModels/LaunchPageViewModel.cs | 2 +- .../Views/CheckpointBrowserPage.axaml | 28 +++++++-- .../Models/Api/CivitModelFpType.cs | 4 +- .../Models/Api/CivitModelType.cs | 16 +++-- .../Models/Packages/BasePackage.cs | 1 + .../Models/Packages/Fooocus.cs | 2 +- 9 files changed, 95 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 67c3732a..88267e83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,14 +9,18 @@ and this project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2 ### Added - New installable Package - [Fooocus](https://github.com/lllyasviel/Fooocus) - Added "Select New Data Directory" button to Settings +- Added "Skip to First/Last Page" buttons to the Model Browser +- Added VAE as a checkpoint category in the Model Browser - Pause/Resume/Cancel buttons on downloads popup. Paused downloads persists and may be resumed after restarting the app ### Fixed - Fixed issue where model version wouldn't be selected in the "All Versions" section of the Model Browser - Improved Checkpoints page indexing performance - Fixed issue where Checkpoints page may not show all checkpoints after clearing search filter - Fixed issue where Checkpoints page may show incorrect checkpoints for the given filter after changing pages +- Fixed issue where Open Web UI button would try to load 0.0.0.0 addresses ### Changed - Changed update method for SD.Next to use the built-in upgrade functionality +- Model Browser navigation buttons are no longer disabled while changing pages ## v2.2.1 ### Fixed diff --git a/StabilityMatrix.Avalonia/ViewModels/CheckpointBrowserViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/CheckpointBrowserViewModel.cs index 5e332efe..42bad566 100644 --- a/StabilityMatrix.Avalonia/ViewModels/CheckpointBrowserViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/CheckpointBrowserViewModel.cs @@ -1,14 +1,19 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.ComponentModel; using System.Diagnostics; using System.Linq; using System.Net.Http; +using System.Reactive; +using System.Reactive.Linq; +using System.Reactive.Threading.Tasks; +using System.Threading; using System.Threading.Tasks; using AsyncAwaitBestPractices; using Avalonia.Collections; using Avalonia.Controls; -using Avalonia.Controls.Notifications; +using AvaloniaEdit.Utils; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using FluentAvalonia.UI.Controls; @@ -29,6 +34,7 @@ using StabilityMatrix.Core.Models; using StabilityMatrix.Core.Models.Api; using StabilityMatrix.Core.Models.Settings; using StabilityMatrix.Core.Services; +using Notification = Avalonia.Controls.Notifications.Notification; using Symbol = FluentIcons.Common.Symbol; using SymbolIconSource = FluentIcons.FluentAvalonia.SymbolIconSource; @@ -61,6 +67,8 @@ public partial class CheckpointBrowserViewModel : PageViewModelBase [ObservableProperty] private bool hasSearched; [ObservableProperty] private bool canGoToNextPage; [ObservableProperty] private bool canGoToPreviousPage; + [ObservableProperty] private bool canGoToFirstPage; + [ObservableProperty] private bool canGoToLastPage; [ObservableProperty] private bool isIndeterminate; [ObservableProperty] private bool noResultsFound; [ObservableProperty] private string noResultsText = string.Empty; @@ -95,6 +103,16 @@ public partial class CheckpointBrowserViewModel : PageViewModelBase CurrentPageNumber = 1; CanGoToNextPage = true; + CanGoToLastPage = true; + + Observable + .FromEventPattern(this, nameof(PropertyChanged)) + .Where(x => x.EventArgs.PropertyName == nameof(CurrentPageNumber)) + .Throttle(TimeSpan.FromMilliseconds(250)) + .Select(_ => CurrentPageNumber) + .Where(page => page <= TotalPages && page > 0) + .ObserveOn(SynchronizationContext.Current) + .Subscribe(_ => TrySearchAgain(false).SafeFireAndForget(), err => Logger.Error(err)); } public override void OnLoaded() @@ -103,6 +121,14 @@ public partial class CheckpointBrowserViewModel : PageViewModelBase var searchOptions = settingsManager.Settings.ModelSearchOptions; + // Fix SelectedModelType if someone had selected the obsolete "Model" option + if (searchOptions is {SelectedModelType: CivitModelType.Model}) + { + settingsManager.Transaction(s => s.ModelSearchOptions = new ModelSearchOptions( + SelectedPeriod, SortMode, CivitModelType.Checkpoint, SelectedBaseModelType)); + searchOptions = settingsManager.Settings.ModelSearchOptions; + } + SelectedPeriod = searchOptions?.SelectedPeriod ?? CivitPeriod.Month; SortMode = searchOptions?.SortMode ?? CivitSortMode.HighestRated; SelectedModelType = searchOptions?.SelectedModelType ?? CivitModelType.Checkpoint; @@ -262,8 +288,10 @@ public partial class CheckpointBrowserViewModel : PageViewModelBase ModelCards =new ObservableCollection(filteredCards); } TotalPages = metadata?.TotalPages ?? 1; + CanGoToFirstPage = CurrentPageNumber != 1; CanGoToPreviousPage = CurrentPageNumber > 1; CanGoToNextPage = CurrentPageNumber < TotalPages; + CanGoToLastPage = CurrentPageNumber != TotalPages; // Status update ShowMainLoadingSpinner = false; IsIndeterminate = false; @@ -371,22 +399,32 @@ public partial class CheckpointBrowserViewModel : PageViewModelBase UpdateResultsText(); } - [RelayCommand] - private async Task PreviousPage() + public void FirstPage() { - if (CurrentPageNumber == 1) return; + CurrentPageNumber = 1; + } + public void PreviousPage() + { + if (CurrentPageNumber == 1) + return; + CurrentPageNumber--; - await TrySearchAgain(false); } - - [RelayCommand] - private async Task NextPage() + + public void NextPage() { + if (CurrentPageNumber == TotalPages) + return; + CurrentPageNumber++; - await TrySearchAgain(false); } - + + public void LastPage() + { + CurrentPageNumber = TotalPages; + } + partial void OnShowNsfwChanged(bool value) { settingsManager.Transaction(s => s.ModelBrowserNsfwEnabled, value); diff --git a/StabilityMatrix.Avalonia/ViewModels/Dialogs/OneClickInstallViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/Dialogs/OneClickInstallViewModel.cs index 42208679..e2ff39cb 100644 --- a/StabilityMatrix.Avalonia/ViewModels/Dialogs/OneClickInstallViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/Dialogs/OneClickInstallViewModel.cs @@ -1,6 +1,7 @@ using System; using System.Collections.ObjectModel; using System.IO; +using System.Linq; using System.Threading.Tasks; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; @@ -55,7 +56,8 @@ public partial class OneClickInstallViewModel : ViewModelBase SubHeaderText = "Choose your preferred interface and click Install to get started!"; ShowInstallButton = true; AllPackages = - new ObservableCollection(this.packageFactory.GetAllAvailablePackages()); + new ObservableCollection(this.packageFactory.GetAllAvailablePackages() + .Where(p => p.OfferInOneClickInstaller)); SelectedPackage = AllPackages[0]; } diff --git a/StabilityMatrix.Avalonia/ViewModels/LaunchPageViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/LaunchPageViewModel.cs index 355ed12c..9bafc659 100644 --- a/StabilityMatrix.Avalonia/ViewModels/LaunchPageViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/LaunchPageViewModel.cs @@ -448,7 +448,7 @@ public partial class LaunchPageViewModel : PageViewModelBase, IDisposable, IAsyn private void RunningPackageOnStartupComplete(object? sender, string e) { - webUiUrl = e; + webUiUrl = e.Replace("0.0.0.0", "127.0.0.1"); ShowWebUiButton = !string.IsNullOrWhiteSpace(webUiUrl); } diff --git a/StabilityMatrix.Avalonia/Views/CheckpointBrowserPage.axaml b/StabilityMatrix.Avalonia/Views/CheckpointBrowserPage.axaml index 19a3b3ed..2a4a3541 100644 --- a/StabilityMatrix.Avalonia/Views/CheckpointBrowserPage.axaml +++ b/StabilityMatrix.Avalonia/Views/CheckpointBrowserPage.axaml @@ -8,7 +8,8 @@ xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia" xmlns:vm="clr-namespace:StabilityMatrix.Avalonia.ViewModels.CheckpointManager" xmlns:checkpointBrowser="clr-namespace:StabilityMatrix.Avalonia.ViewModels.CheckpointBrowser" - mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="600" + xmlns:avalonia="clr-namespace:Projektanker.Icons.Avalonia;assembly=Projektanker.Icons.Avalonia" + mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="700" x:DataType="viewModels:CheckpointBrowserViewModel" d:DataContext="{x:Static designData:DesignData.CheckpointBrowserViewModel}" x:CompileBindings="True" @@ -274,13 +275,30 @@ + - + diff --git a/StabilityMatrix.Core/Models/Api/CivitModelFpType.cs b/StabilityMatrix.Core/Models/Api/CivitModelFpType.cs index f1250c3f..817e2ea2 100644 --- a/StabilityMatrix.Core/Models/Api/CivitModelFpType.cs +++ b/StabilityMatrix.Core/Models/Api/CivitModelFpType.cs @@ -8,6 +8,8 @@ namespace StabilityMatrix.Core.Models.Api; [SuppressMessage("ReSharper", "InconsistentNaming")] public enum CivitModelFpType { + bf16, fp16, - fp32 + fp32, + tf32 } diff --git a/StabilityMatrix.Core/Models/Api/CivitModelType.cs b/StabilityMatrix.Core/Models/Api/CivitModelType.cs index 944115be..0331e252 100644 --- a/StabilityMatrix.Core/Models/Api/CivitModelType.cs +++ b/StabilityMatrix.Core/Models/Api/CivitModelType.cs @@ -9,23 +9,29 @@ namespace StabilityMatrix.Core.Models.Api; [SuppressMessage("ReSharper", "InconsistentNaming")] public enum CivitModelType { - Unknown, [ConvertTo(SharedFolderType.StableDiffusion)] Checkpoint, [ConvertTo(SharedFolderType.TextualInversion)] TextualInversion, [ConvertTo(SharedFolderType.Hypernetwork)] Hypernetwork, - AestheticGradient, [ConvertTo(SharedFolderType.Lora)] LORA, [ConvertTo(SharedFolderType.ControlNet)] Controlnet, - Poses, - [ConvertTo(SharedFolderType.StableDiffusion)] - Model, [ConvertTo(SharedFolderType.LyCORIS)] LoCon, + [ConvertTo(SharedFolderType.VAE)] + VAE, + + // Unused/obsolete/unknown/meta options + AestheticGradient, + Model, + Poses, + Upscaler, + Wildcards, + Workflows, Other, All, + Unknown } diff --git a/StabilityMatrix.Core/Models/Packages/BasePackage.cs b/StabilityMatrix.Core/Models/Packages/BasePackage.cs index 06cff8a4..bfe321b2 100644 --- a/StabilityMatrix.Core/Models/Packages/BasePackage.cs +++ b/StabilityMatrix.Core/Models/Packages/BasePackage.cs @@ -18,6 +18,7 @@ public abstract class BasePackage public abstract string LicenseType { get; } public abstract string LicenseUrl { get; } public virtual string Disclaimer => string.Empty; + public virtual bool OfferInOneClickInstaller => true; /// /// Primary command to launch the package. 'Launch' buttons uses this. diff --git a/StabilityMatrix.Core/Models/Packages/Fooocus.cs b/StabilityMatrix.Core/Models/Packages/Fooocus.cs index 965599f6..b9324f3e 100644 --- a/StabilityMatrix.Core/Models/Packages/Fooocus.cs +++ b/StabilityMatrix.Core/Models/Packages/Fooocus.cs @@ -94,7 +94,7 @@ public class Fooocus : BaseGitPackage { OnConsoleOutput(s); - if (s.Text.Contains("To see the GUI go to", StringComparison.OrdinalIgnoreCase)) + if (s.Text.Contains("Use the app with", StringComparison.OrdinalIgnoreCase)) { var regex = new Regex(@"(https?:\/\/)([^:\s]+):(\d+)"); var match = regex.Match(s.Text);