Skip to content

Commit 5c838e9

Browse files
committed
2 parents 9fd20a7 + c7b6381 commit 5c838e9

File tree

5 files changed

+15
-91
lines changed

5 files changed

+15
-91
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ and this project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2
1212
- Fixed more crashes when loading invalid connected model info files
1313
- Fixed pip installs not parsing comments properly
1414
- Fixed crash when sending input to a process that isn't running
15+
- Fixed breadcrumb on console page showing incorrect running package name
1516
- Fixed [#576](https://github.com/LykosAI/StabilityMatrix/issues/576) - drag & drop crashes on macOS & Linux
1617
- Fixed [#594](https://github.com/LykosAI/StabilityMatrix/issues/594) - missing thumbnails in Inference model selector
18+
- Fixed [#600](https://github.com/LykosAI/StabilityMatrix/issues/600) - kohya_ss v24+ not launching
1719
- Downgraded Avalonia back to 11.0.9 to fix [#589](https://github.com/LykosAI/StabilityMatrix/issues/589) and possibly other rendering issues
1820

1921
## v2.10.1

StabilityMatrix.Avalonia/ViewModels/RunningPackageViewModel.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public partial class RunningPackageViewModel : PageViewModelBase, IDisposable, I
2626

2727
public PackagePair RunningPackage { get; }
2828
public ConsoleViewModel Console { get; }
29-
public override string Title => RunningPackage.InstalledPackage.PackageName ?? "Running Package";
29+
public override string Title => RunningPackage.InstalledPackage.DisplayName ?? "Running Package";
3030
public override IconSource IconSource => new SymbolIconSource();
3131

3232
[ObservableProperty]

StabilityMatrix.Core/Models/Packages/KohyaSs.cs

+2-85
Original file line numberDiff line numberDiff line change
@@ -159,90 +159,7 @@ public override async Task RunPackage(
159159
Action<ProcessOutput>? onConsoleOutput
160160
)
161161
{
162-
await SetupVenv(installedPackagePath).ConfigureAwait(false);
163-
164-
// update gui files to point to venv accelerate
165-
await runner.RunInThreadWithLock(() =>
166-
{
167-
var scope = Py.CreateScope();
168-
scope.Exec(
169-
"""
170-
import ast
171-
172-
class StringReplacer(ast.NodeTransformer):
173-
def __init__(self, old: str, new: str, replace_count: int = -1):
174-
self.old = old
175-
self.new = new
176-
self.replace_count = replace_count
177-
178-
def visit_Constant(self, node: ast.Constant) -> ast.Constant:
179-
if isinstance(node.value, str) and self.old in node.value:
180-
new_value = node.value.replace(self.old, self.new, self.replace_count)
181-
node.value = new_value
182-
return node
183-
184-
def rewrite_module(self, module_text: str) -> str:
185-
tree = ast.parse(module_text)
186-
tree = self.visit(tree)
187-
return ast.unparse(tree)
188-
"""
189-
);
190-
191-
var replacementAcceleratePath = Compat.IsWindows
192-
? @".\venv\scripts\accelerate"
193-
: "./venv/bin/accelerate";
194-
195-
var replacer = scope.InvokeMethod(
196-
"StringReplacer",
197-
"accelerate".ToPython(),
198-
$"{replacementAcceleratePath}".ToPython(),
199-
1.ToPython()
200-
);
201-
202-
var kohyaGuiDir = Path.Combine(installedPackagePath, "kohya_gui");
203-
var guiDirExists = Directory.Exists(kohyaGuiDir);
204-
var filesToUpdate = new List<string>();
205-
206-
if (guiDirExists)
207-
{
208-
filesToUpdate.AddRange(
209-
[
210-
"lora_gui.py",
211-
"dreambooth_gui.py",
212-
"textual_inversion_gui.py",
213-
"wd14_caption_gui.py",
214-
"finetune_gui.py"
215-
]
216-
);
217-
}
218-
else
219-
{
220-
filesToUpdate.AddRange(
221-
[
222-
"lora_gui.py",
223-
"dreambooth_gui.py",
224-
"textual_inversion_gui.py",
225-
Path.Combine("library", "wd14_caption_gui.py"),
226-
"finetune_gui.py"
227-
]
228-
);
229-
}
230-
231-
foreach (var file in filesToUpdate)
232-
{
233-
var path = Path.Combine(guiDirExists ? kohyaGuiDir : installedPackagePath, file);
234-
if (!File.Exists(path))
235-
continue;
236-
237-
var text = File.ReadAllText(path);
238-
if (text.Contains(replacementAcceleratePath.Replace(@"\", @"\\")))
239-
continue;
240-
241-
var result = replacer.InvokeMethod("rewrite_module", text.ToPython());
242-
var resultStr = result.ToString();
243-
File.WriteAllText(path, resultStr);
244-
}
245-
});
162+
var venvRunner = await SetupVenvPure(installedPackagePath).ConfigureAwait(false);
246163

247164
void HandleConsoleOutput(ProcessOutput s)
248165
{
@@ -262,7 +179,7 @@ void HandleConsoleOutput(ProcessOutput s)
262179

263180
var args = $"\"{Path.Combine(installedPackagePath, command)}\" {arguments}";
264181

265-
VenvRunner.RunDetached(args.TrimEnd(), HandleConsoleOutput, OnExit);
182+
venvRunner.RunDetached(args.TrimEnd(), HandleConsoleOutput, OnExit);
266183
}
267184

268185
public override Dictionary<SharedFolderType, IReadOnlyList<string>>? SharedFolders { get; }

StabilityMatrix.Core/Models/Packages/SDWebForge.cs

+8-4
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,13 @@ public override async Task InstallPackage(
139139
progress?.Report(new ProgressReport(-1f, "Installing requirements...", isIndeterminate: true));
140140

141141
var requirements = new FilePath(installLocation, "requirements_versions.txt");
142+
var requirementsContent = await requirements.ReadAllTextAsync().ConfigureAwait(false);
143+
if (!requirementsContent.Contains("pydantic"))
144+
{
145+
requirementsContent += "pydantic==1.10.15";
146+
await requirements.WriteAllTextAsync(requirementsContent).ConfigureAwait(false);
147+
}
148+
142149
var pipArgs = new PipInstallArgs();
143150
if (torchVersion is TorchVersion.DirectMl)
144151
{
@@ -161,10 +168,7 @@ public override async Task InstallPackage(
161168
);
162169
}
163170

164-
pipArgs = pipArgs.WithParsedFromRequirementsTxt(
165-
await requirements.ReadAllTextAsync().ConfigureAwait(false),
166-
excludePattern: "torch"
167-
);
171+
pipArgs = pipArgs.WithParsedFromRequirementsTxt(requirementsContent, excludePattern: "torch");
168172

169173
await venvRunner.PipInstall(pipArgs, onConsoleOutput).ConfigureAwait(false);
170174
progress?.Report(new ProgressReport(1f, "Install complete", isIndeterminate: false));

StabilityMatrix.Core/Python/PyVenvRunner.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,8 @@ public void RunDetached(
545545
if (Compat.IsWindows)
546546
{
547547
var portableGitBin = GlobalConfig.LibraryDir.JoinDir("PortableGit", "bin");
548-
env["PATH"] = Compat.GetEnvPathWithExtensions(portableGitBin);
548+
var venvBin = RootPath.JoinDir(RelativeBinPath);
549+
env["PATH"] = Compat.GetEnvPathWithExtensions(portableGitBin, venvBin);
549550
env["GIT"] = portableGitBin.JoinFile("git.exe");
550551
}
551552

0 commit comments

Comments
 (0)