Improve model location determination (#148)

Vite and cordova properties now automatically determine the path to the models.

Reviewed-on: #148
This commit is contained in:
2024-03-25 21:03:56 -07:00
parent 53869aa268
commit 90d23a70b3

View File

@@ -163,28 +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 = `../models/thorax${this.otherSettings.mini ? '-mini' : ''}/model.json`
this.miniLocation = `../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`
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`
/* 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`
break;
case 'limbs':
this.activeRegion = 2
@@ -194,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} } )
@@ -207,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)
@@ -267,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) {