Browse Source

port kohya fixes to main

pull/515/head
JT 8 months ago
parent
commit
4d42cab3f4
  1. 1
      CHANGELOG.md
  2. 62
      StabilityMatrix.Core/Models/Packages/KohyaSs.cs

1
CHANGELOG.md

@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2
- Fixed [#502](https://github.com/LykosAI/StabilityMatrix/issues/502) - missing launch options for Forge
- Fixed [#500](https://github.com/LykosAI/StabilityMatrix/issues/500) - missing output images in Forge when using output sharing
- Fixed [#490](https://github.com/LykosAI/StabilityMatrix/issues/490) - `mpmath has no attribute 'rational'` error on macOS
- Fixed [#510](https://github.com/ionite34/StabilityMatrix/pull/564/files) - kohya_ss packages with v23.0.x failing to install due to missing 'packaging' dependency
- Fixed incorrect progress text when deleting a checkpoint from the Checkpoints page
- Fixed incorrect icon colors on macOS

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

@ -116,6 +116,15 @@ public class KohyaSs(
Action<ProcessOutput>? onConsoleOutput = null
)
{
progress?.Report(new ProgressReport(-1f, "Updating submodules", isIndeterminate: true));
await PrerequisiteHelper
.RunGit(
["submodule", "update", "--init", "--recursive", "--quiet"],
onConsoleOutput,
installLocation
)
.ConfigureAwait(false);
progress?.Report(new ProgressReport(-1f, "Setting up venv", isIndeterminate: true));
// Setup venv
await using var venvRunner = new PyVenvRunner(Path.Combine(installLocation, "venv"));
@ -136,18 +145,17 @@ public class KohyaSs(
await File.WriteAllTextAsync(setupSmPath, setupText).ConfigureAwait(false);
// Install
venvRunner.RunDetached("setup/setup_sm.py", onConsoleOutput);
await venvRunner.Process.WaitForExitAsync().ConfigureAwait(false);
await venvRunner.CustomInstall("setup/setup_sm.py", onConsoleOutput).ConfigureAwait(false);
await venvRunner.PipInstall("bitsandbytes-windows").ConfigureAwait(false);
}
else if (Compat.IsLinux)
{
venvRunner.RunDetached(
"setup/setup_linux.py --platform-requirements-file=requirements_linux.txt --no_run_accelerate",
onConsoleOutput
);
await venvRunner.Process.WaitForExitAsync().ConfigureAwait(false);
await venvRunner
.CustomInstall(
"setup/setup_linux.py --platform-requirements-file=requirements_linux.txt --no_run_accelerate",
onConsoleOutput
)
.ConfigureAwait(false);
}
}
@ -198,18 +206,40 @@ public class KohyaSs(
1.ToPython()
);
var filesToUpdate = new[]
var kohyaGuiDir = Path.Combine(installedPackagePath, "kohya_gui");
var guiDirExists = Directory.Exists(kohyaGuiDir);
var filesToUpdate = new List<string>();
if (guiDirExists)
{
filesToUpdate.AddRange(
[
"lora_gui.py",
"dreambooth_gui.py",
"textual_inversion_gui.py",
"wd14_caption_gui.py",
"finetune_gui.py"
]
);
}
else
{
"lora_gui.py",
"dreambooth_gui.py",
"textual_inversion_gui.py",
Path.Combine("library", "wd14_caption_gui.py"),
"finetune_gui.py"
};
filesToUpdate.AddRange(
[
"lora_gui.py",
"dreambooth_gui.py",
"textual_inversion_gui.py",
Path.Combine("library", "wd14_caption_gui.py"),
"finetune_gui.py"
]
);
}
foreach (var file in filesToUpdate)
{
var path = Path.Combine(installedPackagePath, file);
var path = Path.Combine(guiDirExists ? kohyaGuiDir : installedPackagePath, file);
if (!File.Exists(path))
continue;
var text = File.ReadAllText(path);
if (text.Contains(replacementAcceleratePath.Replace(@"\", @"\\")))
continue;

Loading…
Cancel
Save