diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c231e7e9..51fb47352 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2 - Better error reporting including outputs for git subprocess errors during package install / update - Fixed `'accelerate' is not recognized as an internal or external command` error when starting training in kohya_ss - Fixed some instances of `ModuleNotFoundError: No module named 'bitsandbytes.cuda_setup.paths'` error when using 8-bit optimizers in kohya_ss +- Fixed errors preventing Inference outputs from loading in the img2img tabs of other packages ## v2.6.1 ### Changed diff --git a/StabilityMatrix.Avalonia/Helpers/PngDataHelper.cs b/StabilityMatrix.Avalonia/Helpers/PngDataHelper.cs index 1d729cfed..f7d7e7c23 100644 --- a/StabilityMatrix.Avalonia/Helpers/PngDataHelper.cs +++ b/StabilityMatrix.Avalonia/Helpers/PngDataHelper.cs @@ -104,7 +104,7 @@ private static byte[] BuildTextChunk(string key, string value) var dataBytes = Encoding.UTF8.GetBytes(textData); var textDataLength = BitConverter.GetBytes(dataBytes.Length).Reverse(); var textDataBytes = Text.Concat(dataBytes).ToArray(); - var crc = BitConverter.GetBytes(Crc32Algorithm.Compute(textDataBytes)); + var crc = BitConverter.GetBytes(Crc32Algorithm.Compute(textDataBytes)).Reverse(); return textDataLength.Concat(textDataBytes).Concat(crc).ToArray(); } diff --git a/StabilityMatrix.Avalonia/ViewModels/Dialogs/InstallerViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/Dialogs/InstallerViewModel.cs index 55b40f305..c98d41bf7 100644 --- a/StabilityMatrix.Avalonia/ViewModels/Dialogs/InstallerViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/Dialogs/InstallerViewModel.cs @@ -14,8 +14,9 @@ using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using FluentAvalonia.UI.Controls; -using NLog; +using Microsoft.Extensions.Logging; using StabilityMatrix.Avalonia.Controls; +using StabilityMatrix.Avalonia.Extensions; using StabilityMatrix.Avalonia.Languages; using StabilityMatrix.Avalonia.Services; using StabilityMatrix.Avalonia.ViewModels.Base; @@ -24,6 +25,7 @@ using StabilityMatrix.Core.Helper.Factory; using StabilityMatrix.Core.Models; using StabilityMatrix.Core.Models.Database; +using StabilityMatrix.Core.Models.FileInterfaces; using StabilityMatrix.Core.Models.PackageModification; using StabilityMatrix.Core.Models.Packages; using StabilityMatrix.Core.Processes; @@ -36,14 +38,13 @@ namespace StabilityMatrix.Avalonia.ViewModels.Dialogs; [Transient] public partial class InstallerViewModel : ContentDialogViewModelBase { - private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - private readonly ISettingsManager settingsManager; private readonly IPackageFactory packageFactory; private readonly IPyRunner pyRunner; private readonly IDownloadService downloadService; private readonly INotificationService notificationService; private readonly IPrerequisiteHelper prerequisiteHelper; + private readonly ILogger logger; [ObservableProperty] private BasePackage selectedPackage; @@ -130,7 +131,8 @@ public InstallerViewModel( IPyRunner pyRunner, IDownloadService downloadService, INotificationService notificationService, - IPrerequisiteHelper prerequisiteHelper + IPrerequisiteHelper prerequisiteHelper, + ILogger logger ) { this.settingsManager = settingsManager; @@ -139,6 +141,7 @@ IPrerequisiteHelper prerequisiteHelper this.downloadService = downloadService; this.notificationService = notificationService; this.prerequisiteHelper = prerequisiteHelper; + this.logger = logger; var filtered = packageFactory.GetAllAvailablePackages().Where(p => p.IsCompatible).ToList(); @@ -187,7 +190,7 @@ public override async Task OnLoadedAsync() } catch (Exception e) { - Logger.Warn("Error getting versions: {Exception}", e.ToString()); + logger.LogWarning("Error getting versions: {Exception}", e.ToString()); } finally { @@ -209,7 +212,7 @@ private async Task Install() else { var ex = result.Exception!; - Logger.Error(ex, $"Error installing package: {ex}"); + logger.LogError(ex, $"Error installing package: {ex}"); var dialog = new BetterContentDialog { @@ -221,7 +224,7 @@ private async Task Install() } } - private Task ActuallyInstall() + private async Task ActuallyInstall() { if (string.IsNullOrWhiteSpace(InstallName)) { @@ -232,12 +235,18 @@ private Task ActuallyInstall() NotificationType.Error ) ); - return Task.CompletedTask; + return; } var setPackageInstallingStep = new SetPackageInstallingStep(settingsManager, InstallName); var installLocation = Path.Combine(settingsManager.LibraryDir, "Packages", InstallName); + if (Directory.Exists(installLocation)) + { + var installPath = new DirectoryPath(installLocation); + await installPath.DeleteVerboseAsync(logger); + } + var prereqStep = new SetupPrerequisitesStep(prerequisiteHelper, pyRunner); var downloadOptions = new DownloadPackageVersionOptions(); @@ -313,7 +322,6 @@ private Task ActuallyInstall() }; Steps = steps; - return Task.CompletedTask; } public void Cancel() @@ -401,7 +409,7 @@ partial void OnSelectedVersionTypeChanged(PackageVersionType value) Dispatcher.UIThread .InvokeAsync(async () => { - Logger.Debug($"Release mode: {IsReleaseMode}"); + logger.LogDebug($"Release mode: {IsReleaseMode}"); var versionOptions = await SelectedPackage.GetAllVersionOptions(); AvailableVersions = IsReleaseMode @@ -413,7 +421,7 @@ partial void OnSelectedVersionTypeChanged(PackageVersionType value) return; ReleaseNotes = SelectedVersion.ReleaseNotesMarkdown; - Logger.Debug($"Loaded release notes for {ReleaseNotes}"); + logger.LogDebug($"Loaded release notes for {ReleaseNotes}"); if (!IsReleaseMode) { @@ -492,7 +500,7 @@ partial void OnSelectedVersionChanged(PackageVersion? value) } catch (Exception e) { - Logger.Warn($"Error getting commits: {e.Message}"); + logger.LogWarning(e, $"Error getting commits: {e.Message}"); } }) .SafeFireAndForget(); diff --git a/StabilityMatrix.Avalonia/ViewModels/Dialogs/OneClickInstallViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/Dialogs/OneClickInstallViewModel.cs index 41d250232..e18e710ef 100644 --- a/StabilityMatrix.Avalonia/ViewModels/Dialogs/OneClickInstallViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/Dialogs/OneClickInstallViewModel.cs @@ -7,6 +7,7 @@ using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using Microsoft.Extensions.Logging; +using StabilityMatrix.Avalonia.Extensions; using StabilityMatrix.Avalonia.Languages; using StabilityMatrix.Avalonia.Services; using StabilityMatrix.Avalonia.ViewModels.Base; @@ -14,6 +15,7 @@ using StabilityMatrix.Core.Helper; using StabilityMatrix.Core.Helper.Factory; using StabilityMatrix.Core.Models; +using StabilityMatrix.Core.Models.FileInterfaces; using StabilityMatrix.Core.Models.PackageModification; using StabilityMatrix.Core.Models.Packages; using StabilityMatrix.Core.Python; @@ -139,6 +141,11 @@ private async Task DoInstall() "Packages", SelectedPackage.Name ); + if (Directory.Exists(installLocation)) + { + var installPath = new DirectoryPath(installLocation); + await installPath.DeleteVerboseAsync(logger); + } var downloadVersion = await SelectedPackage.GetLatestVersion(); var installedVersion = new InstalledPackageVersion { IsPrerelease = false }; diff --git a/StabilityMatrix.Core/Models/Packages/BaseGitPackage.cs b/StabilityMatrix.Core/Models/Packages/BaseGitPackage.cs index 2d4be8129..e2686bb25 100644 --- a/StabilityMatrix.Core/Models/Packages/BaseGitPackage.cs +++ b/StabilityMatrix.Core/Models/Packages/BaseGitPackage.cs @@ -181,36 +181,20 @@ public override async Task DownloadPackage( IProgress? progress = null ) { - if (!string.IsNullOrWhiteSpace(versionOptions.VersionTag)) - { - await PrerequisiteHelper - .RunGit( - new[] - { - "clone", - "--branch", - versionOptions.VersionTag, - GithubUrl, - installLocation - } - ) - .ConfigureAwait(false); - } - else if (!string.IsNullOrWhiteSpace(versionOptions.BranchName)) - { - await PrerequisiteHelper - .RunGit( - new[] - { - "clone", - "--branch", - versionOptions.BranchName, - GithubUrl, - installLocation - } - ) - .ConfigureAwait(false); - } + await PrerequisiteHelper + .RunGit( + new[] + { + "clone", + "--branch", + !string.IsNullOrWhiteSpace(versionOptions.VersionTag) + ? versionOptions.VersionTag + : versionOptions.BranchName ?? MainBranch, + GithubUrl, + installLocation + } + ) + .ConfigureAwait(false); if (!versionOptions.IsLatest && !string.IsNullOrWhiteSpace(versionOptions.CommitHash)) {