From 97706e54b96798a715982f73c9af3932f9ced2ef Mon Sep 17 00:00:00 2001 From: Justin Georgi Date: Mon, 25 Mar 2024 08:46:01 -0700 Subject: [PATCH 1/2] Improve model location determination Signed-off-by: Justin Georgi --- src/pages/detect.vue | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/pages/detect.vue b/src/pages/detect.vue index e11076d..c3340d0 100644 --- a/src/pages/detect.vue +++ b/src/pages/detect.vue @@ -165,26 +165,27 @@ created () { var loadOtherSettings = localStorage.getItem('otherSettings') if (loadOtherSettings) this.otherSettings = JSON.parse(loadOtherSettings) + let modelRoot = this.isCordova ? 'https://localhost' : (import.meta.env.PROD ? '.' : '..') switch (this.f7route.params.region) { case 'thorax': this.activeRegion = 0 this.detectorName = 'thorax' /* VITE setting */ - this.modelLocation = `../models/thorax${this.otherSettings.mini ? '-mini' : ''}/model.json` - this.miniLocation = `../models/thorax-mini/model.json` + this.modelLocation = `${modelRoot}/models/thorax${this.otherSettings.mini ? '-mini' : ''}/model.json` + this.miniLocation = `${modelRoot}/models/thorax-mini/model.json` /* PWA Build setting */ //this.modelLocation = `./models/thorax${this.otherSettings.mini ? '-mini' : ''}/model.json` - this.modelLocationCordova = `https://localhost/models/thorax${this.otherSettings.mini ? '-mini' : ''}/model.json` + this.modelLocationCordova = `${modelRoot}/models/thorax${this.otherSettings.mini ? '-mini' : ''}/model.json` break; case 'abdomen': this.activeRegion = 1 this.detectorName = 'abdomen' /* VITE setting */ - this.modelLocation = `../models/abdomen${this.otherSettings.mini ? '-mini' : ''}/model.json` - this.miniLocation = `../models/abdomen-mini/model.json` + this.modelLocation = `${modelRoot}/models/abdomen${this.otherSettings.mini ? '-mini' : ''}/model.json` + this.miniLocation = `${modelRoot}/models/abdomen-mini/model.json` /* PWA Build setting */ //this.modelLocation = `./models/abdomen${this.otherSettings.mini ? '-mini' : ''}/model.json` - this.modelLocationCordova = `https://localhost/models/abdomen${this.otherSettings.mini ? '-mini' : ''}/model.json` + this.modelLocationCordova = `${modelRoot}/models/abdomen${this.otherSettings.mini ? '-mini' : ''}/model.json` break; case 'limbs': this.activeRegion = 2 -- 2.49.1 From d9ea19a389695d6d1d048153eeaa80f5bdc6d1fa Mon Sep 17 00:00:00 2001 From: Justin Georgi Date: Mon, 25 Mar 2024 21:02:27 -0700 Subject: [PATCH 2/2] Fully generalize model locations Signed-off-by: Justin Georgi --- src/pages/detect.vue | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/pages/detect.vue b/src/pages/detect.vue index c3340d0..3a9468e 100644 --- a/src/pages/detect.vue +++ b/src/pages/detect.vue @@ -163,29 +163,17 @@ return store() }, created () { - var loadOtherSettings = localStorage.getItem('otherSettings') + let loadOtherSettings = localStorage.getItem('otherSettings') if (loadOtherSettings) this.otherSettings = JSON.parse(loadOtherSettings) let modelRoot = this.isCordova ? 'https://localhost' : (import.meta.env.PROD ? '.' : '..') switch (this.f7route.params.region) { case 'thorax': this.activeRegion = 0 this.detectorName = 'thorax' - /* VITE setting */ - this.modelLocation = `${modelRoot}/models/thorax${this.otherSettings.mini ? '-mini' : ''}/model.json` - this.miniLocation = `${modelRoot}/models/thorax-mini/model.json` - /* PWA Build setting */ - //this.modelLocation = `./models/thorax${this.otherSettings.mini ? '-mini' : ''}/model.json` - this.modelLocationCordova = `${modelRoot}/models/thorax${this.otherSettings.mini ? '-mini' : ''}/model.json` break; case 'abdomen': this.activeRegion = 1 this.detectorName = 'abdomen' - /* VITE setting */ - this.modelLocation = `${modelRoot}/models/abdomen${this.otherSettings.mini ? '-mini' : ''}/model.json` - this.miniLocation = `${modelRoot}/models/abdomen-mini/model.json` - /* PWA Build setting */ - //this.modelLocation = `./models/abdomen${this.otherSettings.mini ? '-mini' : ''}/model.json` - this.modelLocationCordova = `${modelRoot}/models/abdomen${this.otherSettings.mini ? '-mini' : ''}/model.json` break; case 'limbs': this.activeRegion = 2 @@ -195,6 +183,8 @@ this.activeRegion = 3 break; } + this.modelLocation = `${modelRoot}/models/${this.detectorName}${this.otherSettings.mini ? '-mini' : ''}/model.json` + this.miniLocation = `${modelRoot}/models/${this.detectorName}-mini/model.json` import(`../models/${this.detectorName}/classes.json`).then((mod) => { this.classesList = mod.default this.detectorLabels = this.classesList.map( l => { return {'name': l, 'detect': true} } ) @@ -208,7 +198,7 @@ this.modelLoading = false } else { this.modelLoading = true - this.loadModel(this.isCordova ? this.modelLocationCordova : this.modelLocation, true).then(() => { + this.loadModel(this.modelLocation, true).then(() => { this.modelLoading = false }).catch((e) => { console.log(e.message) @@ -268,7 +258,7 @@ }, async setData () { if (this.reloadModel) { - await this.loadModel(this.isCordova ? this.modelLocationCordova : this.modelLocation) + await this.loadModel(this.modelLocation) this.reloadModel = false } if (this.serverSettings && this.serverSettings.use) { -- 2.49.1