Browse Source

Invoke fixes & other misc changes

- Added IPAdapter SharedFolderType
- Moved GetLatestVersion to BaseGitPackage
- Added MainBranch property to each package for defining the default "main" branch
- Fixed update check when package is a prerelease version
- Setup model folders before running invokeai-configure so it can do its conversion stuff
pull/240/head
JT 1 year ago
parent
commit
2baef5903b
  1. 13
      StabilityMatrix.Avalonia/ViewModels/Dialogs/InstallerViewModel.cs
  2. 12
      StabilityMatrix.Avalonia/ViewModels/Dialogs/OneClickInstallViewModel.cs
  3. 2
      StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageCardViewModel.cs
  4. 1
      StabilityMatrix.Core/Models/DownloadPackageVersionOptions.cs
  5. 9
      StabilityMatrix.Core/Models/InstalledPackage.cs
  6. 1
      StabilityMatrix.Core/Models/InstalledPackageVersion.cs
  7. 12
      StabilityMatrix.Core/Models/PackageModification/InstallPackageStep.cs
  8. 7
      StabilityMatrix.Core/Models/Packages/A3WebUI.cs
  9. 50
      StabilityMatrix.Core/Models/Packages/BaseGitPackage.cs
  10. 6
      StabilityMatrix.Core/Models/Packages/BasePackage.cs
  11. 3
      StabilityMatrix.Core/Models/Packages/ComfyUI.cs
  12. 6
      StabilityMatrix.Core/Models/Packages/DankDiffusion.cs
  13. 3
      StabilityMatrix.Core/Models/Packages/FocusControlNet.cs
  14. 3
      StabilityMatrix.Core/Models/Packages/Fooocus.cs
  15. 7
      StabilityMatrix.Core/Models/Packages/FooocusMre.cs
  16. 53
      StabilityMatrix.Core/Models/Packages/InvokeAI.cs
  17. 7
      StabilityMatrix.Core/Models/Packages/KohyaSs.cs
  18. 4
      StabilityMatrix.Core/Models/Packages/PackageVersionOptions.cs
  19. 166
      StabilityMatrix.Core/Models/Packages/StableDiffusionDirectMl.cs
  20. 3
      StabilityMatrix.Core/Models/Packages/StableDiffusionUx.cs
  21. 10
      StabilityMatrix.Core/Models/Packages/UnknownPackage.cs
  22. 9
      StabilityMatrix.Core/Models/Packages/VladAutomatic.cs
  23. 5
      StabilityMatrix.Core/Models/Packages/VoltaML.cs
  24. 3
      StabilityMatrix.Core/Models/SharedFolderType.cs

13
StabilityMatrix.Avalonia/ViewModels/Dialogs/InstallerViewModel.cs

@ -249,8 +249,10 @@ public partial class InstallerViewModel : ContentDialogViewModelBase
?? throw new NullReferenceException("Selected version is null"); ?? throw new NullReferenceException("Selected version is null");
downloadOptions.IsLatest = downloadOptions.IsLatest =
AvailableVersions?.First().TagName == downloadOptions.VersionTag; AvailableVersions?.First().TagName == downloadOptions.VersionTag;
downloadOptions.IsPrerelease = SelectedVersion.IsPrerelease;
installedVersion.InstalledReleaseVersion = downloadOptions.VersionTag; installedVersion.InstalledReleaseVersion = downloadOptions.VersionTag;
installedVersion.IsPrerelease = SelectedVersion.IsPrerelease;
} }
else else
{ {
@ -275,6 +277,7 @@ public partial class InstallerViewModel : ContentDialogViewModelBase
var installStep = new InstallPackageStep( var installStep = new InstallPackageStep(
SelectedPackage, SelectedPackage,
SelectedTorchVersion, SelectedTorchVersion,
SelectedSharedFolderMethod,
downloadOptions, downloadOptions,
installLocation installLocation
); );
@ -337,14 +340,12 @@ public partial class InstallerViewModel : ContentDialogViewModelBase
{ {
SelectedVersion = null; SelectedVersion = null;
} }
else if (SelectedPackage is FooocusMre)
{
SelectedVersion = AvailableVersions.FirstOrDefault(x => x.TagName == "moonride-main");
}
else else
{ {
// First try to find master // First try to find the package-defined main branch
var version = AvailableVersions.FirstOrDefault(x => x.TagName == "master"); var version = AvailableVersions.FirstOrDefault(
x => x.TagName == SelectedPackage.MainBranch
);
// If not found, try main // If not found, try main
version ??= AvailableVersions.FirstOrDefault(x => x.TagName == "main"); version ??= AvailableVersions.FirstOrDefault(x => x.TagName == "main");

12
StabilityMatrix.Avalonia/ViewModels/Dialogs/OneClickInstallViewModel.cs

@ -140,8 +140,12 @@ public partial class OneClickInstallViewModel : ContentDialogViewModelBase
SelectedPackage.Name SelectedPackage.Name
); );
var downloadVersion = new DownloadPackageVersionOptions { IsLatest = true }; var downloadVersion = new DownloadPackageVersionOptions
var installedVersion = new InstalledPackageVersion(); {
IsLatest = true,
IsPrerelease = false
};
var installedVersion = new InstalledPackageVersion { IsPrerelease = false };
var versionOptions = await SelectedPackage.GetAllVersionOptions(); var versionOptions = await SelectedPackage.GetAllVersionOptions();
if (versionOptions.AvailableVersions != null && versionOptions.AvailableVersions.Any()) if (versionOptions.AvailableVersions != null && versionOptions.AvailableVersions.Any())
@ -151,7 +155,8 @@ public partial class OneClickInstallViewModel : ContentDialogViewModelBase
} }
else else
{ {
downloadVersion.BranchName = await SelectedPackage.GetLatestVersion(); var latestVersion = await SelectedPackage.GetLatestVersion();
downloadVersion.BranchName = latestVersion.BranchName;
downloadVersion.CommitHash = downloadVersion.CommitHash =
(await SelectedPackage.GetAllCommits(downloadVersion.BranchName)) (await SelectedPackage.GetAllCommits(downloadVersion.BranchName))
?.FirstOrDefault() ?.FirstOrDefault()
@ -174,6 +179,7 @@ public partial class OneClickInstallViewModel : ContentDialogViewModelBase
var installStep = new InstallPackageStep( var installStep = new InstallPackageStep(
SelectedPackage, SelectedPackage,
torchVersion, torchVersion,
recommendedSharedFolderMethod,
downloadVersion, downloadVersion,
installLocation installLocation
); );

2
StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageCardViewModel.cs

@ -265,7 +265,7 @@ public partial class PackageCardViewModel : ProgressViewModel
var versionOptions = new DownloadPackageVersionOptions { IsLatest = true }; var versionOptions = new DownloadPackageVersionOptions { IsLatest = true };
if (Package.Version.IsReleaseMode) if (Package.Version.IsReleaseMode)
{ {
versionOptions.VersionTag = await basePackage.GetLatestVersion(); versionOptions = await basePackage.GetLatestVersion(Package.Version.IsPrerelease);
} }
else else
{ {

1
StabilityMatrix.Core/Models/DownloadPackageVersionOptions.cs

@ -6,4 +6,5 @@ public class DownloadPackageVersionOptions
public string? CommitHash { get; set; } public string? CommitHash { get; set; }
public string? VersionTag { get; set; } public string? VersionTag { get; set; }
public bool IsLatest { get; set; } public bool IsLatest { get; set; }
public bool IsPrerelease { get; set; }
} }

9
StabilityMatrix.Core/Models/InstalledPackage.cs

@ -239,14 +239,19 @@ public class InstalledPackage : IJsonOnDeserialized
) )
{ {
// release mode // release mode
Version = new InstalledPackageVersion { InstalledReleaseVersion = PackageVersion }; Version = new InstalledPackageVersion
{
InstalledReleaseVersion = PackageVersion,
IsPrerelease = false
};
} }
else if (!string.IsNullOrWhiteSpace(PackageVersion)) else if (!string.IsNullOrWhiteSpace(PackageVersion))
{ {
Version = new InstalledPackageVersion Version = new InstalledPackageVersion
{ {
InstalledBranch = InstalledBranch, InstalledBranch = InstalledBranch,
InstalledCommitSha = PackageVersion InstalledCommitSha = PackageVersion,
IsPrerelease = false
}; };
} }
} }

1
StabilityMatrix.Core/Models/InstalledPackageVersion.cs

@ -7,6 +7,7 @@ public class InstalledPackageVersion
public string? InstalledReleaseVersion { get; set; } public string? InstalledReleaseVersion { get; set; }
public string? InstalledBranch { get; set; } public string? InstalledBranch { get; set; }
public string? InstalledCommitSha { get; set; } public string? InstalledCommitSha { get; set; }
public bool IsPrerelease { get; set; }
[JsonIgnore] [JsonIgnore]
public bool IsReleaseMode => string.IsNullOrWhiteSpace(InstalledBranch); public bool IsReleaseMode => string.IsNullOrWhiteSpace(InstalledBranch);

12
StabilityMatrix.Core/Models/PackageModification/InstallPackageStep.cs

@ -8,18 +8,21 @@ public class InstallPackageStep : IPackageStep
{ {
private readonly BasePackage package; private readonly BasePackage package;
private readonly TorchVersion torchVersion; private readonly TorchVersion torchVersion;
private readonly SharedFolderMethod selectedSharedFolderMethod;
private readonly DownloadPackageVersionOptions versionOptions; private readonly DownloadPackageVersionOptions versionOptions;
private readonly string installPath; private readonly string installPath;
public InstallPackageStep( public InstallPackageStep(
BasePackage package, BasePackage package,
TorchVersion torchVersion, TorchVersion torchVersion,
SharedFolderMethod selectedSharedFolderMethod,
DownloadPackageVersionOptions versionOptions, DownloadPackageVersionOptions versionOptions,
string installPath string installPath
) )
{ {
this.package = package; this.package = package;
this.torchVersion = torchVersion; this.torchVersion = torchVersion;
this.selectedSharedFolderMethod = selectedSharedFolderMethod;
this.versionOptions = versionOptions; this.versionOptions = versionOptions;
this.installPath = installPath; this.installPath = installPath;
} }
@ -32,7 +35,14 @@ public class InstallPackageStep : IPackageStep
} }
await package await package
.InstallPackage(installPath, torchVersion, versionOptions, progress, OnConsoleOutput) .InstallPackage(
installPath,
torchVersion,
selectedSharedFolderMethod,
versionOptions,
progress,
OnConsoleOutput
)
.ConfigureAwait(false); .ConfigureAwait(false);
} }

7
StabilityMatrix.Core/Models/Packages/A3WebUI.cs

@ -174,17 +174,14 @@ public class A3WebUI : BaseGitPackage
public override IEnumerable<TorchVersion> AvailableTorchVersions => public override IEnumerable<TorchVersion> AvailableTorchVersions =>
new[] { TorchVersion.Cpu, TorchVersion.Cuda, TorchVersion.Rocm }; new[] { TorchVersion.Cpu, TorchVersion.Cuda, TorchVersion.Rocm };
public override async Task<string> GetLatestVersion() public override string MainBranch => "master";
{
var release = await GetLatestRelease().ConfigureAwait(false);
return release.TagName!;
}
public override string OutputFolderName => "outputs"; public override string OutputFolderName => "outputs";
public override async Task InstallPackage( public override async Task InstallPackage(
string installLocation, string installLocation,
TorchVersion torchVersion, TorchVersion torchVersion,
SharedFolderMethod selectedSharedFolderMethod,
DownloadPackageVersionOptions versionOptions, DownloadPackageVersionOptions versionOptions,
IProgress<ProgressReport>? progress = null, IProgress<ProgressReport>? progress = null,
Action<ProcessOutput>? onConsoleOutput = null Action<ProcessOutput>? onConsoleOutput = null

50
StabilityMatrix.Core/Models/Packages/BaseGitPackage.cs

@ -72,6 +72,29 @@ public abstract class BaseGitPackage : BasePackage
PrerequisiteHelper = prerequisiteHelper; PrerequisiteHelper = prerequisiteHelper;
} }
public override async Task<DownloadPackageVersionOptions> GetLatestVersion(
bool includePrerelease = false
)
{
if (ShouldIgnoreReleases)
{
return new DownloadPackageVersionOptions
{
IsLatest = true,
IsPrerelease = false,
VersionTag = MainBranch
};
}
var release = await GetLatestRelease(includePrerelease).ConfigureAwait(false);
return new DownloadPackageVersionOptions
{
IsLatest = true,
IsPrerelease = release.Prerelease,
VersionTag = release.TagName!
};
}
protected async Task<Release> GetLatestRelease(bool includePrerelease = false) protected async Task<Release> GetLatestRelease(bool includePrerelease = false)
{ {
var releases = await GithubApi.GetAllReleases(Author, Name).ConfigureAwait(false); var releases = await GithubApi.GetAllReleases(Author, Name).ConfigureAwait(false);
@ -267,14 +290,17 @@ public abstract class BaseGitPackage : BasePackage
{ {
if (currentVersion.IsReleaseMode) if (currentVersion.IsReleaseMode)
{ {
var latestVersion = await GetLatestVersion().ConfigureAwait(false); var latestVersion = await GetLatestVersion(currentVersion.IsPrerelease)
UpdateAvailable = latestVersion != currentVersion.InstalledReleaseVersion; .ConfigureAwait(false);
UpdateAvailable =
latestVersion.VersionTag != currentVersion.InstalledReleaseVersion;
return UpdateAvailable; return UpdateAvailable;
} }
var allCommits = ( var allCommits = (
await GetAllCommits(currentVersion.InstalledBranch!).ConfigureAwait(false) await GetAllCommits(currentVersion.InstalledBranch!).ConfigureAwait(false)
)?.ToList(); )?.ToList();
if (allCommits == null || !allCommits.Any()) if (allCommits == null || !allCommits.Any())
{ {
Logger.Warn("No commits found for {Package}", package.PackageName); Logger.Warn("No commits found for {Package}", package.PackageName);
@ -350,11 +376,8 @@ public abstract class BaseGitPackage : BasePackage
await InstallPackage( await InstallPackage(
installedPackage.FullPath!, installedPackage.FullPath!,
torchVersion, torchVersion,
new DownloadPackageVersionOptions installedPackage.PreferredSharedFolderMethod ?? SharedFolderMethod.Symlink,
{ versionOptions,
VersionTag = versionOptions.VersionTag,
IsLatest = versionOptions.IsLatest
},
progress, progress,
onConsoleOutput onConsoleOutput
) )
@ -362,7 +385,8 @@ public abstract class BaseGitPackage : BasePackage
return new InstalledPackageVersion return new InstalledPackageVersion
{ {
InstalledReleaseVersion = versionOptions.VersionTag InstalledReleaseVersion = versionOptions.VersionTag,
IsPrerelease = versionOptions.IsPrerelease
}; };
} }
@ -428,11 +452,8 @@ public abstract class BaseGitPackage : BasePackage
await InstallPackage( await InstallPackage(
installedPackage.FullPath, installedPackage.FullPath,
torchVersion, torchVersion,
new DownloadPackageVersionOptions installedPackage.PreferredSharedFolderMethod ?? SharedFolderMethod.Symlink,
{ versionOptions,
CommitHash = versionOptions.CommitHash,
IsLatest = versionOptions.IsLatest
},
progress, progress,
onConsoleOutput onConsoleOutput
) )
@ -441,7 +462,8 @@ public abstract class BaseGitPackage : BasePackage
return new InstalledPackageVersion return new InstalledPackageVersion
{ {
InstalledBranch = versionOptions.BranchName, InstalledBranch = versionOptions.BranchName,
InstalledCommitSha = versionOptions.CommitHash InstalledCommitSha = versionOptions.CommitHash,
IsPrerelease = versionOptions.IsPrerelease
}; };
} }

6
StabilityMatrix.Core/Models/Packages/BasePackage.cs

@ -55,6 +55,7 @@ public abstract class BasePackage
public abstract Task InstallPackage( public abstract Task InstallPackage(
string installLocation, string installLocation,
TorchVersion torchVersion, TorchVersion torchVersion,
SharedFolderMethod selectedSharedFolderMethod,
DownloadPackageVersionOptions versionOptions, DownloadPackageVersionOptions versionOptions,
IProgress<ProgressReport>? progress = null, IProgress<ProgressReport>? progress = null,
Action<ProcessOutput>? onConsoleOutput = null Action<ProcessOutput>? onConsoleOutput = null
@ -159,7 +160,6 @@ public abstract class BasePackage
IReadOnlyList<string> IReadOnlyList<string>
>? SharedOutputFolders { get; } >? SharedOutputFolders { get; }
public abstract Task<string> GetLatestVersion();
public abstract Task<PackageVersionOptions> GetAllVersionOptions(); public abstract Task<PackageVersionOptions> GetAllVersionOptions();
public abstract Task<IEnumerable<GitCommit>?> GetAllCommits( public abstract Task<IEnumerable<GitCommit>?> GetAllCommits(
string branch, string branch,
@ -168,6 +168,10 @@ public abstract class BasePackage
); );
public abstract Task<IEnumerable<Branch>> GetAllBranches(); public abstract Task<IEnumerable<Branch>> GetAllBranches();
public abstract Task<IEnumerable<Release>> GetAllReleases(); public abstract Task<IEnumerable<Release>> GetAllReleases();
public abstract Task<DownloadPackageVersionOptions> GetLatestVersion(
bool includePrerelease = false
);
public abstract string MainBranch { get; }
public event EventHandler<int>? Exited; public event EventHandler<int>? Exited;
public event EventHandler<string>? StartupComplete; public event EventHandler<string>? StartupComplete;

3
StabilityMatrix.Core/Models/Packages/ComfyUI.cs

@ -146,7 +146,7 @@ public class ComfyUI : BaseGitPackage
LaunchOptionDefinition.Extras LaunchOptionDefinition.Extras
}; };
public override Task<string> GetLatestVersion() => Task.FromResult("master"); public override string MainBranch => "master";
public override IEnumerable<TorchVersion> AvailableTorchVersions => public override IEnumerable<TorchVersion> AvailableTorchVersions =>
new[] new[]
@ -161,6 +161,7 @@ public class ComfyUI : BaseGitPackage
public override async Task InstallPackage( public override async Task InstallPackage(
string installLocation, string installLocation,
TorchVersion torchVersion, TorchVersion torchVersion,
SharedFolderMethod selectedSharedFolderMethod,
DownloadPackageVersionOptions versionOptions, DownloadPackageVersionOptions versionOptions,
IProgress<ProgressReport>? progress = null, IProgress<ProgressReport>? progress = null,
Action<ProcessOutput>? onConsoleOutput = null Action<ProcessOutput>? onConsoleOutput = null

6
StabilityMatrix.Core/Models/Packages/DankDiffusion.cs

@ -37,6 +37,7 @@ public class DankDiffusion : BaseGitPackage
public override Task InstallPackage( public override Task InstallPackage(
string installLocation, string installLocation,
TorchVersion torchVersion, TorchVersion torchVersion,
SharedFolderMethod selectedSharedFolderMethod,
DownloadPackageVersionOptions versionOptions, DownloadPackageVersionOptions versionOptions,
IProgress<ProgressReport>? progress = null, IProgress<ProgressReport>? progress = null,
Action<ProcessOutput>? onConsoleOutput = null Action<ProcessOutput>? onConsoleOutput = null
@ -89,8 +90,5 @@ public class DankDiffusion : BaseGitPackage
IReadOnlyList<string> IReadOnlyList<string>
>? SharedOutputFolders { get; } >? SharedOutputFolders { get; }
public override Task<string> GetLatestVersion() public override string MainBranch { get; }
{
throw new NotImplementedException();
}
} }

3
StabilityMatrix.Core/Models/Packages/FocusControlNet.cs

@ -33,5 +33,6 @@ public class FocusControlNet : Fooocus
public override string LaunchCommand => "launch.py"; public override string LaunchCommand => "launch.py";
public override Uri PreviewImageUri => public override Uri PreviewImageUri =>
new("https://github.com/fenneishi/Fooocus-ControlNet-SDXL/raw/main/asset/canny/snip.png"); new("https://github.com/fenneishi/Fooocus-ControlNet-SDXL/raw/main/asset/canny/snip.png");
public override PackageDifficulty InstallerSortOrder => PackageDifficulty.Advanced; public override PackageDifficulty InstallerSortOrder => PackageDifficulty.Expert;
public override bool OfferInOneClickInstaller => false;
} }

3
StabilityMatrix.Core/Models/Packages/Fooocus.cs

@ -141,7 +141,7 @@ public class Fooocus : BaseGitPackage
public override IEnumerable<TorchVersion> AvailableTorchVersions => public override IEnumerable<TorchVersion> AvailableTorchVersions =>
new[] { TorchVersion.Cpu, TorchVersion.Cuda, TorchVersion.DirectMl, TorchVersion.Rocm }; new[] { TorchVersion.Cpu, TorchVersion.Cuda, TorchVersion.DirectMl, TorchVersion.Rocm };
public override Task<string> GetLatestVersion() => Task.FromResult("main"); public override string MainBranch => "main";
public override bool ShouldIgnoreReleases => true; public override bool ShouldIgnoreReleases => true;
@ -152,6 +152,7 @@ public class Fooocus : BaseGitPackage
public override async Task InstallPackage( public override async Task InstallPackage(
string installLocation, string installLocation,
TorchVersion torchVersion, TorchVersion torchVersion,
SharedFolderMethod selectedSharedFolderMethod,
DownloadPackageVersionOptions versionOptions, DownloadPackageVersionOptions versionOptions,
IProgress<ProgressReport>? progress = null, IProgress<ProgressReport>? progress = null,
Action<ProcessOutput>? onConsoleOutput = null Action<ProcessOutput>? onConsoleOutput = null

7
StabilityMatrix.Core/Models/Packages/FooocusMre.cs

@ -99,17 +99,14 @@ public class FooocusMre : BaseGitPackage
public override IEnumerable<TorchVersion> AvailableTorchVersions => public override IEnumerable<TorchVersion> AvailableTorchVersions =>
new[] { TorchVersion.Cpu, TorchVersion.Cuda, TorchVersion.Rocm }; new[] { TorchVersion.Cpu, TorchVersion.Cuda, TorchVersion.Rocm };
public override async Task<string> GetLatestVersion() public override string MainBranch => "moonride-main";
{
var release = await GetLatestRelease().ConfigureAwait(false);
return release.TagName!;
}
public override string OutputFolderName => "outputs"; public override string OutputFolderName => "outputs";
public override async Task InstallPackage( public override async Task InstallPackage(
string installLocation, string installLocation,
TorchVersion torchVersion, TorchVersion torchVersion,
SharedFolderMethod selectedSharedFolderMethod,
DownloadPackageVersionOptions versionOptions, DownloadPackageVersionOptions versionOptions,
IProgress<ProgressReport>? progress = null, IProgress<ProgressReport>? progress = null,
Action<ProcessOutput>? onConsoleOutput = null Action<ProcessOutput>? onConsoleOutput = null

53
StabilityMatrix.Core/Models/Packages/InvokeAI.cs

@ -50,6 +50,8 @@ public class InvokeAI : BaseGitPackage
new[] { SharedFolderMethod.Symlink, SharedFolderMethod.None }; new[] { SharedFolderMethod.Symlink, SharedFolderMethod.None };
public override SharedFolderMethod RecommendedSharedFolderMethod => SharedFolderMethod.Symlink; public override SharedFolderMethod RecommendedSharedFolderMethod => SharedFolderMethod.Symlink;
public override string MainBranch => "main";
public InvokeAI( public InvokeAI(
IGithubApiCache githubApi, IGithubApiCache githubApi,
ISettingsManager settingsManager, ISettingsManager settingsManager,
@ -76,6 +78,10 @@ public class InvokeAI : BaseGitPackage
[SharedFolderType.ControlNet] = new[] [SharedFolderType.ControlNet] = new[]
{ {
Path.Combine(RelativeRootPath, "autoimport", "controlnet") Path.Combine(RelativeRootPath, "autoimport", "controlnet")
},
[SharedFolderType.IpAdapter] = new[]
{
Path.Combine(RelativeRootPath, "autoimport", "ip_adapter")
} }
}; };
@ -144,12 +150,6 @@ public class InvokeAI : BaseGitPackage
LaunchOptionDefinition.Extras LaunchOptionDefinition.Extras
}; };
public override async Task<string> GetLatestVersion()
{
var release = await GetLatestRelease().ConfigureAwait(false);
return release.TagName!;
}
public override IEnumerable<TorchVersion> AvailableTorchVersions => public override IEnumerable<TorchVersion> AvailableTorchVersions =>
new[] { TorchVersion.Cpu, TorchVersion.Cuda, TorchVersion.Rocm, TorchVersion.Mps }; new[] { TorchVersion.Cpu, TorchVersion.Cuda, TorchVersion.Rocm, TorchVersion.Mps };
@ -166,6 +166,7 @@ public class InvokeAI : BaseGitPackage
public override async Task InstallPackage( public override async Task InstallPackage(
string installLocation, string installLocation,
TorchVersion torchVersion, TorchVersion torchVersion,
SharedFolderMethod selectedSharedFolderMethod,
DownloadPackageVersionOptions versionOptions, DownloadPackageVersionOptions versionOptions,
IProgress<ProgressReport>? progress = null, IProgress<ProgressReport>? progress = null,
Action<ProcessOutput>? onConsoleOutput = null Action<ProcessOutput>? onConsoleOutput = null
@ -228,15 +229,21 @@ public class InvokeAI : BaseGitPackage
progress?.Report(new ProgressReport(-1f, "Configuring InvokeAI", isIndeterminate: true)); progress?.Report(new ProgressReport(-1f, "Configuring InvokeAI", isIndeterminate: true));
// need to setup model links before running invokeai-configure so it can do its conversion
await SetupModelFolders(installLocation, selectedSharedFolderMethod).ConfigureAwait(false);
await RunInvokeCommand( await RunInvokeCommand(
installLocation, installLocation,
"invokeai-configure", "invokeai-configure",
"--yes --skip-sd-weights", "--yes --skip-sd-weights",
false, true,
onConsoleOutput onConsoleOutput,
spam3: true
) )
.ConfigureAwait(false); .ConfigureAwait(false);
await VenvRunner.Process.WaitForExitAsync();
progress?.Report(new ProgressReport(1f, "Done!", isIndeterminate: false)); progress?.Report(new ProgressReport(1f, "Done!", isIndeterminate: false));
} }
@ -252,9 +259,15 @@ public class InvokeAI : BaseGitPackage
string command, string command,
string arguments, string arguments,
bool runDetached, bool runDetached,
Action<ProcessOutput>? onConsoleOutput Action<ProcessOutput>? onConsoleOutput,
bool spam3 = false
) )
{ {
if (spam3 && !runDetached)
{
throw new InvalidOperationException("Cannot spam 3 if not running detached");
}
await SetupVenv(installedPackagePath).ConfigureAwait(false); await SetupVenv(installedPackagePath).ConfigureAwait(false);
arguments = command switch arguments = command switch
@ -304,10 +317,32 @@ public class InvokeAI : BaseGitPackage
if (runDetached) if (runDetached)
{ {
var foundPrompt = false;
void HandleConsoleOutput(ProcessOutput s) void HandleConsoleOutput(ProcessOutput s)
{ {
onConsoleOutput?.Invoke(s); onConsoleOutput?.Invoke(s);
if (
spam3
&& s.Text.Contains(
"[3] Accept the best guess; you can fix it in the Web UI later",
StringComparison.OrdinalIgnoreCase
)
)
{
foundPrompt = true;
Task.Delay(100)
.ContinueWith(_ => VenvRunner.Process?.StandardInput.WriteLine("3"));
return;
}
if (foundPrompt)
{
VenvRunner.Process?.StandardInput.WriteLine("3");
foundPrompt = false;
}
if (!s.Text.Contains("running on", StringComparison.OrdinalIgnoreCase)) if (!s.Text.Contains("running on", StringComparison.OrdinalIgnoreCase))
return; return;

7
StabilityMatrix.Core/Models/Packages/KohyaSs.cs

@ -111,6 +111,7 @@ public class KohyaSs : BaseGitPackage
public override async Task InstallPackage( public override async Task InstallPackage(
string installLocation, string installLocation,
TorchVersion torchVersion, TorchVersion torchVersion,
SharedFolderMethod selectedSharedFolderMethod,
DownloadPackageVersionOptions versionOptions, DownloadPackageVersionOptions versionOptions,
IProgress<ProgressReport>? progress = null, IProgress<ProgressReport>? progress = null,
Action<ProcessOutput>? onConsoleOutput = null Action<ProcessOutput>? onConsoleOutput = null
@ -218,11 +219,7 @@ public class KohyaSs : BaseGitPackage
IReadOnlyList<string> IReadOnlyList<string>
>? SharedOutputFolders { get; } >? SharedOutputFolders { get; }
public override async Task<string> GetLatestVersion() public override string MainBranch => "master";
{
var release = await GetLatestRelease().ConfigureAwait(false);
return release.TagName!;
}
private Dictionary<string, string> GetEnvVars(string installDirectory) private Dictionary<string, string> GetEnvVars(string installDirectory)
{ {

4
StabilityMatrix.Core/Models/Packages/PackageVersionOptions.cs

@ -2,8 +2,8 @@
public class PackageVersionOptions public class PackageVersionOptions
{ {
public IEnumerable<PackageVersion> AvailableVersions { get; set; } = public IEnumerable<PackageVersion>? AvailableVersions { get; set; } =
Enumerable.Empty<PackageVersion>(); Enumerable.Empty<PackageVersion>();
public IEnumerable<PackageVersion> AvailableBranches { get; set; } = public IEnumerable<PackageVersion>? AvailableBranches { get; set; } =
Enumerable.Empty<PackageVersion>(); Enumerable.Empty<PackageVersion>();
} }

166
StabilityMatrix.Core/Models/Packages/StableDiffusionDirectMl.cs

@ -14,7 +14,7 @@ using StabilityMatrix.Core.Services;
namespace StabilityMatrix.Core.Models.Packages; namespace StabilityMatrix.Core.Models.Packages;
[Singleton(typeof(BasePackage))] [Singleton(typeof(BasePackage))]
public class StableDiffusionDirectMl : BaseGitPackage public class StableDiffusionDirectMl : A3WebUI
{ {
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
@ -44,145 +44,15 @@ public class StableDiffusionDirectMl : BaseGitPackage
) )
: base(githubApi, settingsManager, downloadService, prerequisiteHelper) { } : base(githubApi, settingsManager, downloadService, prerequisiteHelper) { }
public override Dictionary<SharedFolderType, IReadOnlyList<string>> SharedFolders =>
new()
{
[SharedFolderType.StableDiffusion] = new[] { "models/Stable-diffusion" },
[SharedFolderType.ESRGAN] = new[] { "models/ESRGAN" },
[SharedFolderType.RealESRGAN] = new[] { "models/RealESRGAN" },
[SharedFolderType.SwinIR] = new[] { "models/SwinIR" },
[SharedFolderType.Lora] = new[] { "models/Lora" },
[SharedFolderType.LyCORIS] = new[] { "models/LyCORIS" },
[SharedFolderType.ApproxVAE] = new[] { "models/VAE-approx" },
[SharedFolderType.VAE] = new[] { "models/VAE" },
[SharedFolderType.DeepDanbooru] = new[] { "models/deepbooru" },
[SharedFolderType.Karlo] = new[] { "models/karlo" },
[SharedFolderType.TextualInversion] = new[] { "embeddings" },
[SharedFolderType.Hypernetwork] = new[] { "models/hypernetworks" },
[SharedFolderType.ControlNet] = new[] { "models/ControlNet" },
[SharedFolderType.Codeformer] = new[] { "models/Codeformer" },
[SharedFolderType.LDSR] = new[] { "models/LDSR" },
[SharedFolderType.AfterDetailer] = new[] { "models/adetailer" }
};
public override Dictionary<SharedOutputType, IReadOnlyList<string>>? SharedOutputFolders =>
new()
{
[SharedOutputType.Extras] = new[] { "outputs/extras-images" },
[SharedOutputType.Saved] = new[] { "log/images" },
[SharedOutputType.Img2Img] = new[] { "outputs/img2img-images" },
[SharedOutputType.Text2Img] = new[] { "outputs/txt2img-images" },
[SharedOutputType.Img2ImgGrids] = new[] { "outputs/img2img-grids" },
[SharedOutputType.Text2ImgGrids] = new[] { "outputs/txt2img-grids" }
};
[SuppressMessage("ReSharper", "ArrangeObjectCreationWhenTypeNotEvident")]
public override List<LaunchOptionDefinition> LaunchOptions =>
new()
{
new()
{
Name = "Host",
Type = LaunchOptionType.String,
DefaultValue = "localhost",
Options = new() { "--server-name" }
},
new()
{
Name = "Port",
Type = LaunchOptionType.String,
DefaultValue = "7860",
Options = new() { "--port" }
},
new()
{
Name = "VRAM",
Type = LaunchOptionType.Bool,
InitialValue = HardwareHelper
.IterGpuInfo()
.Select(gpu => gpu.MemoryLevel)
.Max() switch
{
Level.Low => "--lowvram",
Level.Medium => "--medvram",
_ => null
},
Options = new() { "--lowvram", "--medvram", "--medvram-sdxl" }
},
new()
{
Name = "Xformers",
Type = LaunchOptionType.Bool,
InitialValue = HardwareHelper.HasNvidiaGpu(),
Options = new() { "--xformers" }
},
new()
{
Name = "API",
Type = LaunchOptionType.Bool,
InitialValue = true,
Options = new() { "--api" }
},
new()
{
Name = "Auto Launch Web UI",
Type = LaunchOptionType.Bool,
InitialValue = false,
Options = new() { "--autolaunch" }
},
new()
{
Name = "Skip Torch CUDA Check",
Type = LaunchOptionType.Bool,
InitialValue = !HardwareHelper.HasNvidiaGpu(),
Options = new() { "--skip-torch-cuda-test" }
},
new()
{
Name = "Skip Python Version Check",
Type = LaunchOptionType.Bool,
InitialValue = true,
Options = new() { "--skip-python-version-check" }
},
new()
{
Name = "No Half",
Type = LaunchOptionType.Bool,
Description = "Do not switch the model to 16-bit floats",
InitialValue = HardwareHelper.HasAmdGpu(),
Options = new() { "--no-half" }
},
new()
{
Name = "Skip SD Model Download",
Type = LaunchOptionType.Bool,
InitialValue = false,
Options = new() { "--no-download-sd-model" }
},
new()
{
Name = "Skip Install",
Type = LaunchOptionType.Bool,
Options = new() { "--skip-install" }
},
LaunchOptionDefinition.Extras
};
public override IEnumerable<SharedFolderMethod> AvailableSharedFolderMethods =>
new[] { SharedFolderMethod.Symlink, SharedFolderMethod.None };
public override IEnumerable<TorchVersion> AvailableTorchVersions => public override IEnumerable<TorchVersion> AvailableTorchVersions =>
new[] { TorchVersion.Cpu, TorchVersion.DirectMl }; new[] { TorchVersion.Cpu, TorchVersion.DirectMl };
public override Task<string> GetLatestVersion() => Task.FromResult("master");
public override bool ShouldIgnoreReleases => true; public override bool ShouldIgnoreReleases => true;
public override string OutputFolderName => "outputs";
public override async Task InstallPackage( public override async Task InstallPackage(
string installLocation, string installLocation,
TorchVersion torchVersion, TorchVersion torchVersion,
SharedFolderMethod selectedSharedFolderMethod,
DownloadPackageVersionOptions versionOptions, DownloadPackageVersionOptions versionOptions,
IProgress<ProgressReport>? progress = null, IProgress<ProgressReport>? progress = null,
Action<ProcessOutput>? onConsoleOutput = null Action<ProcessOutput>? onConsoleOutput = null
@ -205,6 +75,8 @@ public class StableDiffusionDirectMl : BaseGitPackage
break; break;
} }
await venvRunner.PipInstall("httpx==0.24.1").ConfigureAwait(false);
// Install requirements file // Install requirements file
progress?.Report( progress?.Report(
new ProgressReport(-1f, "Installing Package Requirements", isIndeterminate: true) new ProgressReport(-1f, "Installing Package Requirements", isIndeterminate: true)
@ -218,34 +90,4 @@ public class StableDiffusionDirectMl : BaseGitPackage
progress?.Report(new ProgressReport(1f, "Install complete", isIndeterminate: false)); progress?.Report(new ProgressReport(1f, "Install complete", isIndeterminate: false));
} }
public override async Task RunPackage(
string installedPackagePath,
string command,
string arguments,
Action<ProcessOutput>? onConsoleOutput
)
{
await SetupVenv(installedPackagePath).ConfigureAwait(false);
void HandleConsoleOutput(ProcessOutput s)
{
onConsoleOutput?.Invoke(s);
if (!s.Text.Contains("Running on", StringComparison.OrdinalIgnoreCase))
return;
var regex = new Regex(@"(https?:\/\/)([^:\s]+):(\d+)");
var match = regex.Match(s.Text);
if (!match.Success)
return;
WebUrl = match.Value;
OnStartupComplete(WebUrl);
}
var args = $"\"{Path.Combine(installedPackagePath, command)}\" {arguments}";
VenvRunner.RunDetached(args.TrimEnd(), HandleConsoleOutput, OnExit);
}
} }

3
StabilityMatrix.Core/Models/Packages/StableDiffusionUx.cs

@ -175,7 +175,7 @@ public class StableDiffusionUx : BaseGitPackage
public override IEnumerable<TorchVersion> AvailableTorchVersions => public override IEnumerable<TorchVersion> AvailableTorchVersions =>
new[] { TorchVersion.Cpu, TorchVersion.Cuda, TorchVersion.Rocm }; new[] { TorchVersion.Cpu, TorchVersion.Cuda, TorchVersion.Rocm };
public override Task<string> GetLatestVersion() => Task.FromResult("master"); public override string MainBranch => "master";
public override bool ShouldIgnoreReleases => true; public override bool ShouldIgnoreReleases => true;
@ -184,6 +184,7 @@ public class StableDiffusionUx : BaseGitPackage
public override async Task InstallPackage( public override async Task InstallPackage(
string installLocation, string installLocation,
TorchVersion torchVersion, TorchVersion torchVersion,
SharedFolderMethod selectedSharedFolderMethod,
DownloadPackageVersionOptions versionOptions, DownloadPackageVersionOptions versionOptions,
IProgress<ProgressReport>? progress = null, IProgress<ProgressReport>? progress = null,
Action<ProcessOutput>? onConsoleOutput = null Action<ProcessOutput>? onConsoleOutput = null

10
StabilityMatrix.Core/Models/Packages/UnknownPackage.cs

@ -43,6 +43,7 @@ public class UnknownPackage : BasePackage
public override Task InstallPackage( public override Task InstallPackage(
string installLocation, string installLocation,
TorchVersion torchVersion, TorchVersion torchVersion,
SharedFolderMethod selectedSharedFolderMethod,
DownloadPackageVersionOptions versionOptions, DownloadPackageVersionOptions versionOptions,
IProgress<ProgressReport>? progress = null, IProgress<ProgressReport>? progress = null,
Action<ProcessOutput>? onConsoleOutput = null Action<ProcessOutput>? onConsoleOutput = null
@ -144,7 +145,14 @@ public class UnknownPackage : BasePackage
IReadOnlyList<string> IReadOnlyList<string>
>? SharedOutputFolders { get; } >? SharedOutputFolders { get; }
public override Task<string> GetLatestVersion() => Task.FromResult(string.Empty); public override Task<DownloadPackageVersionOptions> GetLatestVersion(
bool includePrerelease = false
)
{
throw new NotImplementedException();
}
public override string MainBranch { get; }
public override Task<PackageVersionOptions> GetAllVersionOptions() => public override Task<PackageVersionOptions> GetAllVersionOptions() =>
Task.FromResult(new PackageVersionOptions()); Task.FromResult(new PackageVersionOptions());

9
StabilityMatrix.Core/Models/Packages/VladAutomatic.cs

@ -172,11 +172,12 @@ public class VladAutomatic : BaseGitPackage
public override string ExtraLaunchArguments => ""; public override string ExtraLaunchArguments => "";
public override Task<string> GetLatestVersion() => Task.FromResult("master"); public override string MainBranch => "master";
public override async Task InstallPackage( public override async Task InstallPackage(
string installLocation, string installLocation,
TorchVersion torchVersion, TorchVersion torchVersion,
SharedFolderMethod selectedSharedFolderMethod,
DownloadPackageVersionOptions versionOptions, DownloadPackageVersionOptions versionOptions,
IProgress<ProgressReport>? progress = null, IProgress<ProgressReport>? progress = null,
Action<ProcessOutput>? onConsoleOutput = null Action<ProcessOutput>? onConsoleOutput = null
@ -348,7 +349,8 @@ public class VladAutomatic : BaseGitPackage
return new InstalledPackageVersion return new InstalledPackageVersion
{ {
InstalledBranch = versionOptions.BranchName, InstalledBranch = versionOptions.BranchName,
InstalledCommitSha = output.Replace(Environment.NewLine, "").Replace("\n", "") InstalledCommitSha = output.Replace(Environment.NewLine, "").Replace("\n", ""),
IsPrerelease = false
}; };
} }
catch (Exception e) catch (Exception e)
@ -369,7 +371,8 @@ public class VladAutomatic : BaseGitPackage
return new InstalledPackageVersion return new InstalledPackageVersion
{ {
InstalledBranch = installedPackage.Version.InstalledBranch InstalledBranch = installedPackage.Version.InstalledBranch,
IsPrerelease = false
}; };
} }

5
StabilityMatrix.Core/Models/Packages/VoltaML.cs

@ -26,7 +26,7 @@ public class VoltaML : BaseGitPackage
"https://github.com/LykosAI/StabilityMatrix/assets/13956642/d9a908ed-5665-41a5-a380-98458f4679a8" "https://github.com/LykosAI/StabilityMatrix/assets/13956642/d9a908ed-5665-41a5-a380-98458f4679a8"
); );
public override PackageDifficulty InstallerSortOrder => PackageDifficulty.Advanced; public override PackageDifficulty InstallerSortOrder => PackageDifficulty.Simple;
// There are releases but the manager just downloads the latest commit anyways, // There are releases but the manager just downloads the latest commit anyways,
// so we'll just limit to commit mode to be more consistent // so we'll just limit to commit mode to be more consistent
@ -146,11 +146,12 @@ public class VoltaML : BaseGitPackage
LaunchOptionDefinition.Extras LaunchOptionDefinition.Extras
}; };
public override Task<string> GetLatestVersion() => Task.FromResult("main"); public override string MainBranch => "main";
public override async Task InstallPackage( public override async Task InstallPackage(
string installLocation, string installLocation,
TorchVersion torchVersion, TorchVersion torchVersion,
SharedFolderMethod selectedSharedFolderMethod,
DownloadPackageVersionOptions versionOptions, DownloadPackageVersionOptions versionOptions,
IProgress<ProgressReport>? progress = null, IProgress<ProgressReport>? progress = null,
Action<ProcessOutput>? onConsoleOutput = null Action<ProcessOutput>? onConsoleOutput = null

3
StabilityMatrix.Core/Models/SharedFolderType.cs

@ -28,5 +28,6 @@ public enum SharedFolderType
CLIP = 1 << 18, CLIP = 1 << 18,
ScuNET = 1 << 19, ScuNET = 1 << 19,
GLIGEN = 1 << 20, GLIGEN = 1 << 20,
AfterDetailer = 1 << 21 AfterDetailer = 1 << 21,
IpAdapter = 1 << 22
} }

Loading…
Cancel
Save