From e40f2fc80434e600355c7d9dc532b33898bd9415 Mon Sep 17 00:00:00 2001 From: EmojiPati Date: Sun, 17 Dec 2023 23:32:44 +0300 Subject: [PATCH 1/3] Update Resources.tr-TR.resx translation corrections and improvements. --- .../Languages/Resources.tr-TR.resx | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/StabilityMatrix.Avalonia/Languages/Resources.tr-TR.resx b/StabilityMatrix.Avalonia/Languages/Resources.tr-TR.resx index 0726efc0..f1568143 100644 --- a/StabilityMatrix.Avalonia/Languages/Resources.tr-TR.resx +++ b/StabilityMatrix.Avalonia/Languages/Resources.tr-TR.resx @@ -133,7 +133,7 @@ Dil - Yeni dil seçeneğinin etkili olması için yeniden başlatma gerekiyor + Yeni dil seçeneğinin etkili olması için yeniden başlatma gerekir. Yeniden başlat @@ -166,7 +166,7 @@ Dallar - İçe aktarmak için chekpoints'leri buraya sürükleyip bırakın + İçe aktarmak için chekpoints'leri buraya sürükleyip bırakın. Vurgu @@ -235,7 +235,7 @@ Sponsor Ol - Discord Sunucusuna Katıl + Discord Sunucumuza Katıl İndirmeler @@ -313,22 +313,22 @@ Tüm Sürümler - Modelleri, #etiketleri veya @kullanıcıları ara + Modelleri,Tagları (#tag) veya Kullanıcıları (@user) Buradan Arayabilirsin Ara - Sırala + Sıralama Tipi - Süre + Sıralama Tarihi Model Türü - Temel Model + Model Altyapısı NSFW İçerik Göster @@ -376,10 +376,10 @@ Klasör - İçe aktarma için dosyayı buraya bırakın + Dosyayı içeri aktarmak için lütfen sürükleyip işaretlenen alana bırakın. - Metadata ile içeri aktar + Dosyaları metadata ile içeri aktar Yeni yerel içe aktarmalar için bağlı meta veri arayın @@ -448,7 +448,7 @@ Entegrasyonlar - Discord Zengin Varlık + Discord Etkinliğini StabilityMatrix Olarak Göster. Sistem @@ -469,10 +469,10 @@ Tüm Kullanıcılar İçin Ekle - Yeni Veri Dizini Seç + Yeni Dosya Dizinini Seç - Mevcut veriyi taşımaz + Bu işlem mevcut veriyi yeni dizine taşımaz. Dizin Seçin @@ -490,7 +490,7 @@ Başlamak için Başlat'a tıklayın! - Dur + Durdur Giriş Gönder @@ -694,10 +694,10 @@ {0} resim seçildi - Çıkış Klasörü + Çıktı Klasörü - Çıkış Türü + Çıktı Türü Seçimi Temizle @@ -721,7 +721,7 @@ Upscale - Çıkış Tarayıcısı + Medya Kitaplığı 1 resim seçildi From 2d17a51231ac8253d34d2351df33c77ede9a6783 Mon Sep 17 00:00:00 2001 From: JT Date: Wed, 3 Jan 2024 22:02:31 -0800 Subject: [PATCH 2/3] Some fixes from dev --- CHANGELOG.md | 11 ++++ .../StabilityMatrix.Avalonia.csproj | 14 ++--- .../CivitAiBrowserViewModel.cs | 57 +++++++++++++++---- .../Dialogs/SelectDataDirectoryViewModel.cs | 14 +++-- .../Dialogs/SelectModelVersionViewModel.cs | 28 ++++----- .../InferenceTextToImageViewModel.cs | 43 +++++++++----- .../Inference/SamplerCardViewModel.cs | 24 ++++++-- .../Api/Comfy/Nodes/ComfyNodeBuilder.cs | 43 +++++++++++--- .../Packages/StableDiffusionDirectMl.cs | 23 ++++++++ 9 files changed, 194 insertions(+), 63 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 48a70fca..903abd15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,17 @@ All notable changes to Stability Matrix will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2.0.0.html). +## v2.7.7 +### Added +- Added `--use-directml` launch argument for SDWebUI DirectML fork +### Changed +- Model Browser downloads will no longer be disabled if the free drive space is unavailable +- Default Linux installation folder changed to prevent issues with hidden folders +- Changed default Period to "AllTime" in the Model Browser +### Fixed +- Fixed error where Environment Variables were not editable +- Fixed SDTurboScheduler's missing denoise parameter + ## v2.7.6 ### Added - Added SDXL Turbo and Stable Video Diffusion to the Hugging Face tab diff --git a/StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj b/StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj index 3d2bf552..54e5d85b 100644 --- a/StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj +++ b/StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj @@ -24,16 +24,16 @@ - - - + + + - + - + - - + + 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/Dialogs/SelectDataDirectoryViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/Dialogs/SelectDataDirectoryViewModel.cs index 9c20bdf0..9db2e0ec 100644 --- a/StabilityMatrix.Avalonia/ViewModels/Dialogs/SelectDataDirectoryViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/Dialogs/SelectDataDirectoryViewModel.cs @@ -24,13 +24,19 @@ namespace StabilityMatrix.Avalonia.ViewModels.Dialogs; public partial class SelectDataDirectoryViewModel : ContentDialogViewModelBase { private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - public static string DefaultInstallLocation => Compat.AppDataHome; + + public static string DefaultInstallLocation => + Compat.IsLinux + ? Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), + "StabilityMatrix" + ) + : Compat.AppDataHome; private readonly ISettingsManager settingsManager; private const string ValidExistingDirectoryText = "Valid existing data directory found"; - private const string InvalidDirectoryText = - "Directory must be empty or have a valid settings.json file"; + private const string InvalidDirectoryText = "Directory must be empty or have a valid settings.json file"; private const string NotEnoughFreeSpaceText = "Not enough free space on the selected drive"; private const string FatWarningText = "FAT32 / exFAT drives are not supported at this time"; @@ -38,7 +44,7 @@ public partial class SelectDataDirectoryViewModel : ContentDialogViewModelBase private string dataDirectory = DefaultInstallLocation; [ObservableProperty] - private bool isPortableMode; + private bool isPortableMode = Compat.IsLinux; [ObservableProperty] private string directoryStatusText = string.Empty; diff --git a/StabilityMatrix.Avalonia/ViewModels/Dialogs/SelectModelVersionViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/Dialogs/SelectModelVersionViewModel.cs index 61221efa..b5cb4be9 100644 --- a/StabilityMatrix.Avalonia/ViewModels/Dialogs/SelectModelVersionViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/Dialogs/SelectModelVersionViewModel.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; -using System.IO; using System.Linq; using Avalonia.Media.Imaging; using Avalonia.Threading; @@ -11,7 +10,6 @@ using StabilityMatrix.Avalonia.Models; 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; @@ -90,15 +88,13 @@ public partial class SelectModelVersionViewModel : ContentDialogViewModelBase CanGoToNextImage = allImages.Count > 1; } - Dispatcher - .UIThread - .Post(() => - { - CanGoToPreviousImage = false; - SelectedFile = SelectedVersionViewModel?.CivitFileViewModels.FirstOrDefault(); - ImageUrls = new ObservableCollection(allImages); - SelectedImageIndex = 0; - }); + Dispatcher.UIThread.Post(() => + { + CanGoToPreviousImage = false; + SelectedFile = SelectedVersionViewModel?.CivitFileViewModels.FirstOrDefault(); + ImageUrls = new ObservableCollection(allImages); + SelectedImageIndex = 0; + }); } partial void OnSelectedFileChanged(CivitFileViewModel? value) @@ -107,10 +103,16 @@ public partial class SelectModelVersionViewModel : ContentDialogViewModelBase if (settingsManager.IsLibraryDirSet) { var fileSizeBytes = value?.CivitFile.SizeKb * 1024; - var freeSizeBytes = SystemInfo.GetDiskFreeSpaceBytes(settingsManager.ModelsDirectory); + var freeSizeBytes = + SystemInfo.GetDiskFreeSpaceBytes(settingsManager.ModelsDirectory) ?? long.MaxValue; canImport = fileSizeBytes < freeSizeBytes; ImportTooltip = canImport - ? $"Free space after download: {Size.FormatBytes(Convert.ToUInt64(freeSizeBytes - fileSizeBytes))}" + ? "Free space after download: " + + ( + freeSizeBytes < long.MaxValue + ? Size.FormatBytes(Convert.ToUInt64(freeSizeBytes - fileSizeBytes)) + : "Unknown" + ) : $"Not enough space on disk. Need {Size.FormatBytes(Convert.ToUInt64(fileSizeBytes))} but only have {Size.FormatBytes(Convert.ToUInt64(freeSizeBytes))}"; } else diff --git a/StabilityMatrix.Avalonia/ViewModels/Inference/InferenceTextToImageViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/Inference/InferenceTextToImageViewModel.cs index c51e540c..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; + }); } /// @@ -162,18 +170,21 @@ public class InferenceTextToImageViewModel : InferenceGenerationViewModelBase, I protected override IEnumerable GetInputImages() { var samplerImages = SamplerCardViewModel - .ModulesCardViewModel - .Cards - .OfType() + .ModulesCardViewModel.Cards.OfType() .SelectMany(m => m.GetInputImages()); - var moduleImages = ModulesCardViewModel.Cards.OfType().SelectMany(m => m.GetInputImages()); + var moduleImages = ModulesCardViewModel + .Cards.OfType() + .SelectMany(m => m.GetInputImages()); return samplerImages.Concat(moduleImages); } /// - protected override async Task GenerateImageImpl(GenerateOverrides overrides, CancellationToken cancellationToken) + protected override async Task GenerateImageImpl( + GenerateOverrides overrides, + CancellationToken cancellationToken + ) { // Validate the prompts if (!await PromptCardViewModel.ValidatePrompts()) @@ -267,12 +278,16 @@ public class InferenceTextToImageViewModel : InferenceGenerationViewModelBase, I if (state.TryGetPropertyValue("HiresSampler", out var hiresSamplerState)) { - module.GetCard().LoadStateFromJsonObject(hiresSamplerState!.AsObject()); + module + .GetCard() + .LoadStateFromJsonObject(hiresSamplerState!.AsObject()); } if (state.TryGetPropertyValue("HiresUpscaler", out var hiresUpscalerState)) { - module.GetCard().LoadStateFromJsonObject(hiresUpscalerState!.AsObject()); + module + .GetCard() + .LoadStateFromJsonObject(hiresUpscalerState!.AsObject()); } }); @@ -282,17 +297,17 @@ public class InferenceTextToImageViewModel : InferenceGenerationViewModelBase, I if (state.TryGetPropertyValue("Upscaler", out var upscalerState)) { - module.GetCard().LoadStateFromJsonObject(upscalerState!.AsObject()); + module + .GetCard() + .LoadStateFromJsonObject(upscalerState!.AsObject()); } }); // Add FreeU to sampler - SamplerCardViewModel - .ModulesCardViewModel - .AddModule(module => - { - module.IsEnabled = state.GetPropertyValueOrDefault("IsFreeUEnabled"); - }); + SamplerCardViewModel.ModulesCardViewModel.AddModule(module => + { + module.IsEnabled = state.GetPropertyValueOrDefault("IsFreeUEnabled"); + }); } base.LoadStateFromJsonObject(state); diff --git a/StabilityMatrix.Avalonia/ViewModels/Inference/SamplerCardViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/Inference/SamplerCardViewModel.cs index 32640d8e..a0d300a1 100644 --- a/StabilityMatrix.Avalonia/ViewModels/Inference/SamplerCardViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/Inference/SamplerCardViewModel.cs @@ -87,7 +87,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 => @@ -101,7 +104,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"), @@ -147,7 +153,8 @@ public partial class SamplerCardViewModel : LoadableViewModelBase, IParametersLo var primaryLatent = e.Builder.GetPrimaryAsLatent(); // Set primary sampler and scheduler - e.Builder.Connections.PrimarySampler = SelectedSampler ?? throw new ValidationException("Sampler not selected"); + e.Builder.Connections.PrimarySampler = + SelectedSampler ?? throw new ValidationException("Sampler not selected"); e.Builder.Connections.PrimaryScheduler = SelectedScheduler ?? throw new ValidationException("Scheduler not selected"); @@ -173,7 +180,8 @@ public partial class SamplerCardViewModel : LoadableViewModelBase, IParametersLo { Name = "SDTurboScheduler", Model = e.Builder.Connections.BaseModel ?? throw new ArgumentException("No BaseModel"), - Steps = Steps + Steps = Steps, + Denoise = DenoiseStrength } ); @@ -249,7 +257,8 @@ public partial class SamplerCardViewModel : LoadableViewModelBase, IParametersLo new ComfyNodeBuilder.KSamplerAdvanced { Name = "Refiner_Sampler", - Model = e.Builder.Connections.RefinerModel ?? throw new ArgumentException("No RefinerModel"), + Model = + e.Builder.Connections.RefinerModel ?? throw new ArgumentException("No RefinerModel"), AddNoise = false, NoiseSeed = e.Builder.Connections.Seed, Steps = TotalSteps, @@ -295,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 25d3f9cf..48fa3a79 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 @@ -147,7 +150,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 + } }; } @@ -272,7 +279,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; } @@ -365,7 +373,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 ); } @@ -376,7 +386,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( @@ -432,7 +446,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( @@ -506,7 +524,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( @@ -706,7 +728,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 + ); } /// @@ -756,7 +781,9 @@ public class ComfyNodeBuilder public ConditioningNodeConnection GetRefinerOrBaseConditioning() { - return RefinerConditioning ?? BaseConditioning ?? throw new NullReferenceException("No Conditioning"); + return RefinerConditioning + ?? BaseConditioning + ?? throw new NullReferenceException("No Conditioning"); } public ConditioningNodeConnection GetRefinerOrBaseNegativeConditioning() diff --git a/StabilityMatrix.Core/Models/Packages/StableDiffusionDirectMl.cs b/StabilityMatrix.Core/Models/Packages/StableDiffusionDirectMl.cs index 34321d04..d7dec894 100644 --- a/StabilityMatrix.Core/Models/Packages/StableDiffusionDirectMl.cs +++ b/StabilityMatrix.Core/Models/Packages/StableDiffusionDirectMl.cs @@ -5,6 +5,7 @@ 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; @@ -36,6 +37,8 @@ public class StableDiffusionDirectMl( public override SharedFolderMethod RecommendedSharedFolderMethod => SharedFolderMethod.Symlink; + public override TorchVersion GetRecommendedTorchVersion() => TorchVersion.DirectMl; + public override PackageDifficulty InstallerSortOrder => PackageDifficulty.Recommended; public override IEnumerable AvailableTorchVersions => @@ -43,6 +46,26 @@ public class StableDiffusionDirectMl( 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, From fc6ef780e74ebc771fbb3104bde0e7e0afb6f24a Mon Sep 17 00:00:00 2001 From: JT Date: Wed, 3 Jan 2024 22:44:13 -0800 Subject: [PATCH 3/3] 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,