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:
@@ -163,28 +163,17 @@
|
|||||||
return store()
|
return store()
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
var loadOtherSettings = localStorage.getItem('otherSettings')
|
let loadOtherSettings = localStorage.getItem('otherSettings')
|
||||||
if (loadOtherSettings) this.otherSettings = JSON.parse(loadOtherSettings)
|
if (loadOtherSettings) this.otherSettings = JSON.parse(loadOtherSettings)
|
||||||
|
let modelRoot = this.isCordova ? 'https://localhost' : (import.meta.env.PROD ? '.' : '..')
|
||||||
switch (this.f7route.params.region) {
|
switch (this.f7route.params.region) {
|
||||||
case 'thorax':
|
case 'thorax':
|
||||||
this.activeRegion = 0
|
this.activeRegion = 0
|
||||||
this.detectorName = 'thorax'
|
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;
|
break;
|
||||||
case 'abdomen':
|
case 'abdomen':
|
||||||
this.activeRegion = 1
|
this.activeRegion = 1
|
||||||
this.detectorName = 'abdomen'
|
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;
|
break;
|
||||||
case 'limbs':
|
case 'limbs':
|
||||||
this.activeRegion = 2
|
this.activeRegion = 2
|
||||||
@@ -194,6 +183,8 @@
|
|||||||
this.activeRegion = 3
|
this.activeRegion = 3
|
||||||
break;
|
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) => {
|
import(`../models/${this.detectorName}/classes.json`).then((mod) => {
|
||||||
this.classesList = mod.default
|
this.classesList = mod.default
|
||||||
this.detectorLabels = this.classesList.map( l => { return {'name': l, 'detect': true} } )
|
this.detectorLabels = this.classesList.map( l => { return {'name': l, 'detect': true} } )
|
||||||
@@ -207,7 +198,7 @@
|
|||||||
this.modelLoading = false
|
this.modelLoading = false
|
||||||
} else {
|
} else {
|
||||||
this.modelLoading = true
|
this.modelLoading = true
|
||||||
this.loadModel(this.isCordova ? this.modelLocationCordova : this.modelLocation, true).then(() => {
|
this.loadModel(this.modelLocation, true).then(() => {
|
||||||
this.modelLoading = false
|
this.modelLoading = false
|
||||||
}).catch((e) => {
|
}).catch((e) => {
|
||||||
console.log(e.message)
|
console.log(e.message)
|
||||||
@@ -267,7 +258,7 @@
|
|||||||
},
|
},
|
||||||
async setData () {
|
async setData () {
|
||||||
if (this.reloadModel) {
|
if (this.reloadModel) {
|
||||||
await this.loadModel(this.isCordova ? this.modelLocationCordova : this.modelLocation)
|
await this.loadModel(this.modelLocation)
|
||||||
this.reloadModel = false
|
this.reloadModel = false
|
||||||
}
|
}
|
||||||
if (this.serverSettings && this.serverSettings.use) {
|
if (this.serverSettings && this.serverSettings.use) {
|
||||||
|
|||||||
Reference in New Issue
Block a user