Skip to content

Commit b9b3cf9

Browse files
author
brendlij
committed
Add performance optimization for image loading and enhance classification handling
1 parent 21fdc88 commit b9b3cf9

1 file changed

Lines changed: 48 additions & 4 deletions

File tree

ui/src/App.vue

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ const uploadPrediction = ref<Prediction | null>(null);
109109
const uploadError = ref("");
110110
const uploadLoading = ref(false);
111111
112+
// Performance: avoid loading thousands of images unless requested
113+
const loadAllImages = ref(false);
114+
const imageLimit = 400;
115+
112116
let pollInterval: number | null = null;
113117
114118
// ============ Computed ============
@@ -172,6 +176,9 @@ const skystateOptions = [
172176
async function fetchImages() {
173177
try {
174178
const params = new URLSearchParams();
179+
if (!loadAllImages.value) {
180+
params.set("limit", String(imageLimit));
181+
}
175182
if (showUnlabeledOnly.value) params.set("unlabeled", "1");
176183
177184
const query = params.toString();
@@ -495,6 +502,7 @@ function resetUploadPreview() {
495502
uploadFile.value = null;
496503
uploadFileName.value = "";
497504
uploadPrediction.value = null;
505+
uploadError.value = "";
498506
}
499507
500508
function onUploadFileChange(e: Event) {
@@ -503,6 +511,7 @@ function onUploadFileChange(e: Event) {
503511
uploadFile.value = file;
504512
uploadPrediction.value = null;
505513
uploadError.value = "";
514+
classifyError.value = "";
506515
resetUploadPreview();
507516
508517
if (file) {
@@ -541,6 +550,18 @@ async function submitUploadClassification() {
541550
}
542551
}
543552
553+
const classifyActionLoading = computed(
554+
() => classifyLoading.value || uploadLoading.value
555+
);
556+
557+
async function handleClassifyAction() {
558+
if (uploadFile.value) {
559+
await submitUploadClassification();
560+
} else {
561+
await classifyLatest();
562+
}
563+
}
564+
544565
// Update model list on mount and after training
545566
onMounted(() => {
546567
fetchModelVersions();
@@ -730,6 +751,18 @@ onUnmounted(() => {
730751
<span class="toggle-slider"></span>
731752
<span class="toggle-label">Unlabeled only</span>
732753
</label>
754+
<label class="toggle">
755+
<input
756+
type="checkbox"
757+
v-model="loadAllImages"
758+
@change="
759+
fetchImages();
760+
currentIndex = 0;
761+
"
762+
/>
763+
<span class="toggle-slider"></span>
764+
<span class="toggle-label">Load all (slower)</span>
765+
</label>
733766
<button class="icon-btn" @click="fetchImages()" title="Refresh">
734767
<span class="mdi mdi-refresh"></span>
735768
</button>
@@ -911,11 +944,22 @@ onUnmounted(() => {
911944
<div class="toolbar-right">
912945
<button
913946
class="btn-primary ghost"
914-
@click="classifyLatest"
915-
:disabled="classifyLoading"
947+
@click="handleClassifyAction"
948+
:disabled="classifyActionLoading"
916949
>
917-
<span class="mdi mdi-camera-iris"></span>
918-
{{ classifyLoading ? "Classifying..." : "Classify now" }}
950+
<span
951+
class="mdi"
952+
:class="uploadFile ? 'mdi-ray-start-arrow' : 'mdi-camera-iris'"
953+
></span>
954+
{{
955+
uploadFile
956+
? uploadLoading
957+
? "Classifying..."
958+
: "Classify upload"
959+
: classifyLoading
960+
? "Classifying..."
961+
: "Classify now"
962+
}}
919963
</button>
920964
</div>
921965
</div>

0 commit comments

Comments
 (0)