Skip to content

Commit 88fe07b

Browse files
committed
Allow use of labels.txt file on desktop
1 parent 165c593 commit 88fe07b

File tree

2 files changed

+54
-2
lines changed

2 files changed

+54
-2
lines changed

client/platform/desktop/backend/native/viame.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,13 @@ async function train(
400400
command.push(runTrainingArgs.fineTuneModel.path);
401401
}
402402

403+
if (runTrainingArgs.labelText) {
404+
const labelsPath = `${jobWorkDir}/labels.txt`;
405+
fs.writeFileSync(labelsPath, runTrainingArgs.labelText);
406+
command.push('--labels');
407+
command.push(labelsPath);
408+
}
409+
403410
const job = observeChild(spawn(command.join(' '), {
404411
shell: viameConstants.shell,
405412
cwd: jobWorkDir,

client/platform/desktop/frontend/components/MultiTrainingMenu.vue

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@
22
import type { DataTableHeader } from 'vuetify';
33
44
import {
5-
computed, defineComponent, onBeforeMount, set, del, reactive, ref,
5+
computed,
6+
defineComponent,
7+
onBeforeMount,
8+
set,
9+
del,
10+
reactive,
11+
ref,
12+
watch,
613
} from 'vue';
714
import {
815
DatasetMeta, Pipelines, TrainingConfigs, useApi, Pipe,
@@ -25,6 +32,22 @@ export default defineComponent({
2532
const router = useRouter();
2633
2734
const unsortedPipelines = ref({} as Pipelines);
35+
const labelFile = ref(null as File | null);
36+
const labelText = ref('');
37+
38+
function clearLabelText() {
39+
labelText.value = '';
40+
}
41+
42+
watch(labelFile, () => {
43+
if (labelFile.value) {
44+
const reader = new FileReader();
45+
reader.onload = (evt) => {
46+
labelText.value = evt.target?.result as string;
47+
};
48+
reader.readAsText(labelFile.value);
49+
}
50+
});
2851
2952
onBeforeMount(async () => {
3053
unsortedPipelines.value = await getPipelineList();
@@ -198,7 +221,7 @@ export default defineComponent({
198221
data.trainingOutputName,
199222
data.selectedTrainingConfig,
200223
data.annotatedFramesOnly,
201-
undefined,
224+
labelText.value || undefined,
202225
foundTrainingModel,
203226
);
204227
router.push({ name: 'jobs' });
@@ -217,6 +240,8 @@ export default defineComponent({
217240
218241
return {
219242
data,
243+
labelFile,
244+
clearLabelText,
220245
toggleStaged,
221246
deleteModel,
222247
exportModel,
@@ -311,6 +336,26 @@ export default defineComponent({
311336
</v-select>
312337
</v-col>
313338
</v-row>
339+
<v-row
340+
class="my-4 pt-0"
341+
dense
342+
>
343+
<v-col sm="5">
344+
<v-file-input
345+
v-model="labelFile"
346+
icon="mdi-folder-open"
347+
label="Labels.txt mapping file (optional)"
348+
hint="Combine or rename output classes using a labels.txt file"
349+
persistant-hint
350+
dense
351+
outlined
352+
hide-details
353+
clearable
354+
@click:clear="clearLabelText"
355+
/>
356+
</v-col>
357+
<v-spacer />
358+
</v-row>
314359
<v-data-table
315360
v-bind="{ headers: staged.headers, items: staged.items.value }"
316361
hide-default-footer

0 commit comments

Comments
 (0)