Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.12.3 #986

Merged
merged 19 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@ 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.12.3
### Added
- Added new package - [SimpleSDXL](https://github.com/metercai/SimpleSDXL) - many thanks to @NullDev for the contribution!
- Added new package - [FluxGym](https://github.com/cocktailpeanut/fluxgym) - many thanks to @NullDev for the contribution!
- Added more base model types to the CivitAI Model Browser & Checkpoint Manager
### Changed
- Updated Russian translations thanks to @vanja-san
- Updated Simplified Chinese translations thanks to @QL-boy
### Fixed
- Fixed some cases of FileTransferExists error when running re/Forge or Automatic1111
- Fixed update check not happening on startup for some users
- Fixed error when installing Automatic1111 on macOS
- Fixed some instances of Civitai model browser not loading new results
- Fixed "Unsupported Torch Version: Cuda" errors when installing a1111

## v2.12.2
### Added
- Added Beta scheduler to the scheduler selector in Inference
Expand Down
4 changes: 3 additions & 1 deletion StabilityMatrix.Avalonia/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
using StabilityMatrix.Core.Models.FileInterfaces;
using StabilityMatrix.Core.Models.Settings;
using StabilityMatrix.Core.Services;
using StabilityMatrix.Core.Updater;
using Application = Avalonia.Application;
using Logger = NLog.Logger;
using LogLevel = Microsoft.Extensions.Logging.LogLevel;
Expand Down Expand Up @@ -375,7 +376,8 @@ internal static void ConfigurePageViewModels(IServiceCollection services)
provider.GetRequiredService<IModelIndexService>(),
provider.GetRequiredService<Lazy<IModelDownloadLinkHandler>>(),
provider.GetRequiredService<INotificationService>(),
provider.GetRequiredService<IAnalyticsHelper>()
provider.GetRequiredService<IAnalyticsHelper>(),
provider.GetRequiredService<IUpdateHelper>()
)
{
Pages =
Expand Down
445 changes: 383 additions & 62 deletions StabilityMatrix.Avalonia/Languages/Resources.ru-ru.resx

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ or nameof(HideEarlyAccessModels)
)
.DisposeMany()
.Filter(filterPredicate)
.SortAndBind(ModelCards, sortPredicate, new SortAndBindOptions { UseBinarySearch = true })
.SortAndBind(ModelCards, sortPredicate)
.Subscribe();

settingsManager.RelayPropertyFor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ INotificationService notificationService
.Connect()
.DeferUntilLoaded()
.Filter(incompatiblePredicate)
.Filter(p => p.OfferInOneClickInstaller)
.Sort(
.Filter(p => p is { OfferInOneClickInstaller: true, PackageType: PackageType.SdInference })
.SortAndBind(
ShownPackages,
SortExpressionComparer<BasePackage>
.Ascending(p => p.InstallerSortOrder)
.ThenByAscending(p => p.DisplayName)
)
.Bind(ShownPackages)
.Subscribe();

AllPackagesCache.AddOrUpdate(packageFactory.GetAllAvailablePackages());
Expand Down
9 changes: 8 additions & 1 deletion StabilityMatrix.Avalonia/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
using StabilityMatrix.Core.Models.Settings;
using StabilityMatrix.Core.Models.Update;
using StabilityMatrix.Core.Services;
using StabilityMatrix.Core.Updater;

namespace StabilityMatrix.Avalonia.ViewModels;

Expand All @@ -46,6 +47,7 @@ public partial class MainWindowViewModel : ViewModelBase
private readonly Lazy<IModelDownloadLinkHandler> modelDownloadLinkHandler;
private readonly INotificationService notificationService;
private readonly IAnalyticsHelper analyticsHelper;
private readonly IUpdateHelper updateHelper;
public string Greeting => "Welcome to Avalonia!";

[ObservableProperty]
Expand Down Expand Up @@ -86,7 +88,8 @@ public MainWindowViewModel(
IModelIndexService modelIndexService,
Lazy<IModelDownloadLinkHandler> modelDownloadLinkHandler,
INotificationService notificationService,
IAnalyticsHelper analyticsHelper
IAnalyticsHelper analyticsHelper,
IUpdateHelper updateHelper
)
{
this.settingsManager = settingsManager;
Expand All @@ -97,6 +100,7 @@ IAnalyticsHelper analyticsHelper
this.modelDownloadLinkHandler = modelDownloadLinkHandler;
this.notificationService = notificationService;
this.analyticsHelper = analyticsHelper;
this.updateHelper = updateHelper;
ProgressManagerViewModel = dialogFactory.Get<ProgressManagerViewModel>();
UpdateViewModel = dialogFactory.Get<UpdateViewModel>();
}
Expand Down Expand Up @@ -263,6 +267,9 @@ settingsManager.Settings.Analytics.LastSeenConsentVersion is null
settingsManager.Transaction(s => s.UpdatingFromVersion = null);
}

// Start checking for updates
await updateHelper.StartCheckingForUpdates();

// Periodic launch stats
if (
settingsManager.Settings.Analytics.IsUsageDataEnabled
Expand Down
3 changes: 2 additions & 1 deletion StabilityMatrix.Avalonia/Views/CheckpointsPage.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,8 @@
DragDrop.AllowDrop="True"
IsVisible="{Binding ShowFolders}"
ItemsSource="{Binding Categories}"
SelectedItem="{Binding SelectedCategory}">
SelectedItem="{Binding SelectedCategory}"
SelectionMode="AlwaysSelected">
<TreeView.Styles>
<Style Selector="TreeViewItem">
<Setter Property="IsExpanded" Value="{Binding $self.((models1:CheckpointCategory)DataContext).IsExpanded, Mode=TwoWay}" />
Expand Down
9 changes: 8 additions & 1 deletion StabilityMatrix.Core/Helper/FileTransfers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ public static async Task MoveAllFilesAndDirectories(
DirectoryPath sourceDir,
DirectoryPath destinationDir,
bool overwrite = false,
bool overwriteIfHashMatches = false
bool overwriteIfHashMatches = false,
bool deleteSymlinks = false
)
{
// Create the destination directory if it doesn't exist
Expand All @@ -157,6 +158,12 @@ await MoveAllFiles(sourceDir, destinationDir, overwrite, overwriteIfHashMatches)
// Then move directories
foreach (var subDir in sourceDir.Info.EnumerateDirectories())
{
if (deleteSymlinks && new DirectoryPath(subDir).IsSymbolicLink)
{
subDir.Delete(false);
continue;
}

var destinationSubDir = destinationDir.JoinDir(subDir.Name);
// Recursively move sub directories
await MoveAllFilesAndDirectories(subDir, destinationSubDir, overwrite, overwriteIfHashMatches)
Expand Down
3 changes: 2 additions & 1 deletion StabilityMatrix.Core/Helper/SharedFolders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ await FileTransfers
destinationDir,
sourceDir,
overwriteIfHashMatches: true,
overwrite: overwrite
overwrite: overwrite,
deleteSymlinks: true
)
.ConfigureAwait(false);
}
Expand Down
15 changes: 15 additions & 0 deletions StabilityMatrix.Core/Models/Api/CivitBaseModelType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ public enum CivitBaseModelType
[StringValue("Flux.1 D")]
Flux1D,

[StringValue("Hunyuan 1")]
Hunyuan1,

[StringValue("Illustrious")]
Illustrious,

[StringValue("Kolors")]
Kolors,

[StringValue("Lumina")]
Lumina,

[StringValue("PixArt a")]
PixArtA,

Expand All @@ -38,6 +50,9 @@ public enum CivitBaseModelType
[StringValue("SD 3")]
Sd3,

[StringValue("SD 3.5")]
Sd35,

[StringValue("SDXL 0.9")]
Sdxl09,

Expand Down
6 changes: 3 additions & 3 deletions StabilityMatrix.Core/Models/Packages/A3WebUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,12 @@ public override async Task InstallPackage(
var torchVersion = options.PythonOptions.TorchIndex ?? GetRecommendedTorchVersion();

var requirements = new FilePath(installLocation, "requirements_versions.txt");
var pipArgs = options.PythonOptions.TorchIndex switch
var pipArgs = torchVersion switch
{
TorchIndex.Mps
=> new PipInstallArgs()
.WithTorch("==2.3.1")
.WithTorchVision("==2.3.1")
.WithTorchVision("==0.18.1")
.WithParsedFromRequirementsTxt(
await requirements.ReadAllTextAsync(cancellationToken).ConfigureAwait(false),
excludePattern: "torch"
Expand All @@ -227,7 +227,7 @@ await requirements.ReadAllTextAsync(cancellationToken).ConfigureAwait(false),
.WithTorch("==2.1.2")
.WithTorchVision("==0.16.2")
.WithTorchExtraIndex(
options.PythonOptions.TorchIndex switch
torchVersion switch
{
TorchIndex.Cpu => "cpu",
TorchIndex.Cuda => "cu121",
Expand Down
48 changes: 47 additions & 1 deletion StabilityMatrix.Core/Models/Packages/BaseGitPackage.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO.Compression;
using System.Text.RegularExpressions;
using NLog;
using Octokit;
using StabilityMatrix.Core.Helper;
Expand Down Expand Up @@ -554,6 +555,51 @@ private async Task FixInfinityFolders(DirectoryPath rootDirectory, string infini
await firstInfinity.DeleteAsync(true).ConfigureAwait(false);
}

private async Task FixForgeInfinity()
{
var modelsDir = new DirectoryPath(SettingsManager.ModelsDirectory);
var rootDirectory = modelsDir.JoinDir("StableDiffusion").JoinDir("sd");
var infinityFolderName = "sd";
var firstInfinity = rootDirectory.JoinDir(infinityFolderName);

var depth = 0;
var currentDir = rootDirectory;

while (currentDir.JoinDir(infinityFolderName) is { Exists: true, IsSymbolicLink: false } newInfinity)
{
depth++;
currentDir = newInfinity;
}

if (depth <= 5)
{
Logger.Info("not really that infinity, aborting");
return;
}

Logger.Info("Found {Depth} infinity folders from {FirstPath}", depth, firstInfinity.ToString());

// Move all items in infinity folder to root
Logger.Info("Moving infinity folders content to root: {Path}", currentDir.ToString());
await FileTransfers
.MoveAllFilesAndDirectories(currentDir, rootDirectory, overwriteIfHashMatches: true)
.ConfigureAwait(false);

// Move any files from first infinity by enumeration just in case
var leftoverFiles = firstInfinity.EnumerateFiles(searchOption: SearchOption.AllDirectories);
foreach (var file in leftoverFiles)
{
await file.MoveToWithIncrementAsync(rootDirectory.JoinFile(file.Name)).ConfigureAwait(false);
}

if (!firstInfinity.EnumerateFiles(searchOption: SearchOption.AllDirectories).Any())
{
// Delete infinity folders chain from first
Logger.Info("Deleting infinity folders: {Path}", currentDir.ToString());
await firstInfinity.DeleteAsync(true).ConfigureAwait(false);
}
}

public override async Task SetupModelFolders(
DirectoryPath installDirectory,
SharedFolderMethod sharedFolderMethod
Expand All @@ -568,7 +614,7 @@ SharedFolderMethod sharedFolderMethod

// fix infinity controlnet folders
await FixInfinityFolders(modelsDir.JoinDir("ControlNet"), "ControlNet").ConfigureAwait(false);
await FixInfinityFolders(modelsDir.JoinDir("StableDiffusion"), "sd").ConfigureAwait(false);
await FixForgeInfinity().ConfigureAwait(false);

// fix duplicate links in models dir
// see https://github.com/LykosAI/StabilityMatrix/issues/338
Expand Down
3 changes: 2 additions & 1 deletion StabilityMatrix.Core/Models/Packages/OneTrainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ public override async Task InstallPackage(
await using var venvRunner = await SetupVenvPure(installLocation).ConfigureAwait(false);

progress?.Report(new ProgressReport(-1f, "Installing requirements", isIndeterminate: true));
var requirementsFileName = options.PythonOptions.TorchIndex switch
var torchVersion = options.PythonOptions.TorchIndex ?? GetRecommendedTorchVersion();
var requirementsFileName = torchVersion switch
{
TorchIndex.Cuda => "requirements-cuda.txt",
TorchIndex.Rocm => "requirements-rocm.txt",
Expand Down
74 changes: 32 additions & 42 deletions StabilityMatrix.Core/Models/Packages/SimpleSDXL.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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;
Expand All @@ -27,9 +28,11 @@ IPrerequisiteHelper prerequisiteHelper
new("https://github.com/user-attachments/assets/98715a4d-9f4a-4846-ae62-eb8d69793d31");
public override PackageDifficulty InstallerSortOrder => PackageDifficulty.Expert;
public override IEnumerable<SharedFolderMethod> AvailableSharedFolderMethods =>
[SharedFolderMethod.Symlink, SharedFolderMethod.None];
public override SharedFolderMethod RecommendedSharedFolderMethod => SharedFolderMethod.Symlink;
[SharedFolderMethod.Configuration, SharedFolderMethod.Symlink, SharedFolderMethod.None];
public override SharedFolderMethod RecommendedSharedFolderMethod => SharedFolderMethod.Configuration;
public override string MainBranch => "SimpleSDXL";
public override IEnumerable<TorchIndex> AvailableTorchIndices => [TorchIndex.Cuda];
public override bool IsCompatible => HardwareHelper.HasNvidiaGpu();

public override List<LaunchOptionDefinition> LaunchOptions =>
[
Expand Down Expand Up @@ -157,61 +160,48 @@ public override async Task InstallPackage(
CancellationToken cancellationToken = default
)
{
const string wheelUrl =
"https://github.com/Gourieff/Assets/raw/main/Insightface/insightface-0.7.3-cp310-cp310-win_amd64.whl";
var torchVersion = options.PythonOptions.TorchIndex ?? GetRecommendedTorchVersion();
await using var venvRunner = await SetupVenvPure(installLocation, forceRecreate: true)
.ConfigureAwait(false);

if (torchVersion == TorchIndex.Cuda)
{
await using var venvRunner = await SetupVenvPure(installLocation, forceRecreate: true)
.ConfigureAwait(false);

progress?.Report(new ProgressReport(-1f, "Installing requirements...", isIndeterminate: true));

// Get necessary dependencies
await venvRunner.PipInstall("--upgrade pip", onConsoleOutput).ConfigureAwait(false);
await venvRunner.PipInstall("nvidia-pyindex pygit2", onConsoleOutput).ConfigureAwait(false);
await venvRunner.PipInstall("facexlib cpm_kernels", onConsoleOutput).ConfigureAwait(false);
progress?.Report(new ProgressReport(-1f, "Installing requirements...", isIndeterminate: true));
// Get necessary dependencies
await venvRunner.PipInstall("--upgrade pip", onConsoleOutput).ConfigureAwait(false);
await venvRunner.PipInstall("nvidia-pyindex pygit2", onConsoleOutput).ConfigureAwait(false);
await venvRunner.PipInstall("facexlib cpm_kernels", onConsoleOutput).ConfigureAwait(false);

if (Compat.IsWindows)
{
// Download and Install pre-built insightface
const string wheelUrl =
"https://github.com/Gourieff/Assets/raw/main/Insightface/insightface-0.7.3-cp310-cp310-win_amd64.whl";

var wheelPath = new FilePath(installLocation, "insightface-0.7.3-cp310-cp310-win_amd64.whl");
await DownloadService
.DownloadToFileAsync(wheelUrl, wheelPath, cancellationToken: cancellationToken)
.ConfigureAwait(false);
await venvRunner.PipInstall($"{wheelPath}", onConsoleOutput).ConfigureAwait(false);
await wheelPath.DeleteAsync(cancellationToken).ConfigureAwait(false);
}

var requirements = new FilePath(installLocation, "requirements_versions.txt");
var pipArgs = new PipInstallArgs()
.WithTorch("==2.3.1")
.WithTorchVision("==0.18.1")
.WithTorchAudio("==2.3.1")
.WithTorchExtraIndex("cu121")
.WithParsedFromRequirementsTxt(
await requirements.ReadAllTextAsync(cancellationToken).ConfigureAwait(false),
"torch"
);
var requirements = new FilePath(installLocation, "requirements_versions.txt");

if (installedPackage.PipOverrides != null)
{
pipArgs = pipArgs.WithUserOverrides(installedPackage.PipOverrides);
}
var pipArgs = new PipInstallArgs()
.WithTorch("==2.3.1")
.WithTorchVision("==0.18.1")
.WithTorchAudio("==2.3.1")
.WithTorchExtraIndex("cu121")
.WithParsedFromRequirementsTxt(
await requirements.ReadAllTextAsync(cancellationToken).ConfigureAwait(false),
"torch"
);

await venvRunner.PipInstall(pipArgs, onConsoleOutput).ConfigureAwait(false);
}
else
if (installedPackage.PipOverrides != null)
{
await base.InstallPackage(
installLocation,
installedPackage,
options,
progress,
onConsoleOutput,
cancellationToken
)
.ConfigureAwait(false);
pipArgs = pipArgs.WithUserOverrides(installedPackage.PipOverrides);
}

await venvRunner.PipInstall(pipArgs, onConsoleOutput).ConfigureAwait(false);

// Create output folder since it's not created by default
var outputFolder = new DirectoryPath(installLocation, OutputFolderName);
outputFolder.Create();
Expand Down
Loading