Yolo duplication fix (#1713)

Somebody wanted a description, so here I am.

This PR fixes an error which caused the discoverModels function to be
rerun after each upload of a new model, but without clearing the list of
available models. This causes any models that were on the list prior to
the import to be duplicated. This PR also makes it so that uploading a
model automatically updates the list of available models.

---------

Co-authored-by: Matt Morley <matthew.morley.ca@gmail.com>
Co-authored-by: Chris Gerth <gerth2@users.noreply.github.com>
This commit is contained in:
Sam Freund
2025-01-12 19:48:39 -06:00
committed by GitHub
parent 5f75619063
commit 966b9e8c61
4 changed files with 34 additions and 21 deletions

View File

@@ -4,11 +4,12 @@ import axios from "axios";
import { useStateStore } from "@/stores/StateStore";
import { useSettingsStore } from "@/stores/settings/GeneralSettingsStore";
const showObjectDetectionImportDialog = ref(false);
const showImportDialog = ref(false);
const importRKNNFile = ref<File | null>(null);
const importLabelsFile = ref<File | null>(null);
const handleObjectDetectionImport = () => {
// TODO gray out the button when model is uploading
const handleImport = async () => {
if (importRKNNFile.value === null || importLabelsFile.value === null) return;
const formData = new FormData();
@@ -50,7 +51,8 @@ const handleObjectDetectionImport = () => {
}
});
showObjectDetectionImportDialog.value = false;
showImportDialog.value = false;
importRKNNFile.value = null;
importLabelsFile.value = null;
};
@@ -68,12 +70,12 @@ const supportedModels = computed(() => {
<div class="pa-6 pt-0">
<v-row>
<v-col cols="12 ">
<v-btn color="secondary" @click="() => (showObjectDetectionImportDialog = true)" class="justify-center">
<v-btn color="secondary" @click="() => (showImportDialog = true)" class="justify-center">
<v-icon left class="open-icon"> mdi-import </v-icon>
<span class="open-label">Import New Model</span>
</v-btn>
<v-dialog
v-model="showObjectDetectionImportDialog"
v-model="showImportDialog"
width="600"
@input="
() => {
@@ -105,7 +107,7 @@ const supportedModels = computed(() => {
<v-btn
color="secondary"
:disabled="importRKNNFile === null || importLabelsFile === null"
@click="handleObjectDetectionImport"
@click="handleImport"
>
<v-icon left class="open-icon"> mdi-import </v-icon>
<span class="open-label">Import Object Detection Model</span>