Skip to content

Commit 9d74c3c

Browse files
committed
win32: multiple fixes for model training
1 parent 4071bff commit 9d74c3c

File tree

3 files changed

+32
-14
lines changed

3 files changed

+32
-14
lines changed

qml/Main.qml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ ApplicationWindow {
1616

1717
// CUDA availability check
1818
readonly property bool hasCuda: System.availableCudaDevice() > 0
19+
readonly property bool isWin32: Qt.platform.os === "windows"
1920

2021
// Required packages
2122
readonly property var requiredPackages: [

qml/koaia/Views/MainView.qml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ import koaia
99

1010
Pane {
1111
id: mainView
12-
12+
13+
readonly property bool isWin32: Qt.platform.os === "windows"
14+
1315
property bool isProcessing: false
1416
onIsProcessingChanged: (isProcessing)? Score.play() : Score.stop()
1517

@@ -217,7 +219,7 @@ Pane {
217219
console.log("No file selected")
218220
return
219221
}
220-
var filePath = new URL(selectedFile).pathname.substr(Qt.platform.os === "windows" ? 1 : 0);
222+
var filePath = new URL(selectedFile).pathname.substr(isWin32 ? 1 : 0);
221223
imagePathField.text = filePath
222224
}
223225
}
@@ -363,7 +365,7 @@ Pane {
363365
console.log("No folder selected")
364366
return
365367
}
366-
var folderPath = new URL(selectedFolder).pathname.substr(Qt.platform.os === "windows" ? 1 : 0);
368+
var folderPath = new URL(selectedFolder).pathname.substr(isWin32 ? 1 : 0);
367369
enginePathField.text = folderPath
368370
}
369371
}

qml/koaia/Views/ModelView.qml

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@ Pane {
2020
property string rootPath: ""
2121
}
2222

23+
readonly property bool isWin32: Qt.platform.os === "windows"
24+
2325
// Computed paths based on Library root
2426
readonly property string libraryRoot: librarySettings.rootPath
25-
readonly property string uvPath: libraryRoot + "/packages/uv/uv"
27+
28+
readonly property string uvPath: libraryRoot + "/packages/python-uv/uv"
2629
readonly property string scriptPath: libraryRoot + "/packages/librediffusion/train-loras.py"
2730
readonly property string scriptDir: libraryRoot + "/packages/librediffusion"
2831

@@ -33,7 +36,7 @@ Pane {
3336
UI.Process {
3437
id: syncProcess
3538
program: uvPath
36-
arguments: ["sync"]
39+
arguments: isWin32? ["sync", "--cache-dir", "c:\\uv"] : ["sync"]
3740

3841
onLineReceived: (line, isError) => {
3942
if (isError) {
@@ -81,6 +84,15 @@ Pane {
8184
if (!running) {
8285
outputTextArea.append("\n----------------------------------------")
8386
outputTextArea.append("[Build finished with exit code: " + exitCode + "]")
87+
if(exitCode === 0) {
88+
89+
var folderPath = outputPathField.text;
90+
if(isWin32) {
91+
folderPath = folderPath.replace(/\\/g, '/');
92+
}
93+
94+
Qt.openUrlExternally(Qt.resolvedUrl(folderPath));
95+
}
8496
}
8597
}
8698

@@ -157,15 +169,14 @@ Pane {
157169
}
158170

159171
CustomLabel {
160-
text: "Build TensorRT engines from Stable Diffusion models"
172+
text: "Build TensorRT engines from Stable Diffusion models.\nNote that this is a long process: roughly fifteen minutes for a given model."
161173
font.pixelSize: appStyle.fontSizeBody
162174
color: appStyle.textColorSecondary
163175
}
164176

165177
// Configuration controls
166178
ScrollView {
167179
Layout.fillWidth: true
168-
Layout.fillHeight: true
169180
clip: true
170181
contentWidth: availableWidth
171182

@@ -183,7 +194,7 @@ Pane {
183194
ComboBox {
184195
id: modelTypeCombo
185196
Layout.fillWidth: true
186-
model: ["SD 1.5", "SDXL"]
197+
model: ["SD 1.5 / Turbo", "SDXL"]
187198
currentIndex: 0
188199
font.pixelSize: appStyle.fontSizeBody
189200
property string modelTypeArg: currentIndex === 0 ? "sd15" : "sdxl"
@@ -209,7 +220,7 @@ Pane {
209220
id: outputPathField
210221
Layout.fillWidth: true
211222
font.pixelSize: appStyle.fontSizeBody
212-
text: "./engines"
223+
text: ""
213224
placeholderText: "Path to save engine files"
214225
}
215226
Button {
@@ -224,7 +235,7 @@ Pane {
224235
title: "Select Output Folder"
225236
onAccepted: {
226237
if (!selectedFolder) return
227-
var folderPath = new URL(selectedFolder).pathname.substr(Qt.platform.os === "windows" ? 1 : 0)
238+
var folderPath = new URL(selectedFolder).pathname.substr(isWin32 ? 1 : 0)
228239
outputPathField.text = folderPath
229240
}
230241
}
@@ -314,7 +325,7 @@ Pane {
314325
property int currentLoraIndex: -1
315326
onAccepted: {
316327
if (!selectedFile || currentLoraIndex < 0) return
317-
var filePath = new URL(selectedFile).pathname.substr(Qt.platform.os === "windows" ? 1 : 0)
328+
var filePath = new URL(selectedFile).pathname.substr(isWin32 ? 1 : 0)
318329
loraListModel.setProperty(currentLoraIndex, "path", filePath)
319330
}
320331
}
@@ -525,15 +536,19 @@ Pane {
525536

526537
// Set working directory and start sync
527538
syncProcess.workingDirectory = scriptDir
539+
buildProcess.workingDirectory = scriptDir
528540
syncProcess.start()
529541
}
530542

531543
// Called after successful sync
532544
function runBuildProcess() {
533545
// Build argument list with argparse-style flags
534-
var args = [
546+
var args = [];
547+
if(isWin32)
548+
args.push("--cache-dir", "c:\\uv");
549+
args.push(
535550
"run",
536-
"train-loras.py",
551+
"train-lora.py",
537552
"--type", modelTypeCombo.modelTypeArg,
538553
"--model", modelSourceField.text,
539554
"--output", outputPathField.text,
@@ -544,7 +559,7 @@ Pane {
544559
"--max-resolution", maxResolutionSpinBox.value.toString(),
545560
"--opt-width", optWidthSpinBox.value.toString(),
546561
"--opt-height", optHeightSpinBox.value.toString()
547-
]
562+
);
548563

549564
// Add LoRAs with weights
550565
for (var i = 0; i < loraListModel.count; i++) {

0 commit comments

Comments
 (0)