From 56a6d85f75a2877cb0ee9986b646b9e5d98eab6c Mon Sep 17 00:00:00 2001 From: Justin Georgi Date: Tue, 20 Aug 2024 17:06:47 -0700 Subject: [PATCH] Get better model root using import.meta Signed-off-by: Justin Georgi --- src/pages/detect.vue | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pages/detect.vue b/src/pages/detect.vue index f22404a..0a70acc 100644 --- a/src/pages/detect.vue +++ b/src/pages/detect.vue @@ -141,6 +141,8 @@ import cameraMixin from './camera-mixin' import detectionWorker from '../assets/detect-worker.js?worker&inline' +// import thoraxModel from '/models/thorax/model.json?url' +// import thoraxModelMini from '/models/thorax-mini/model.json?url' export default { mixins: [submitMixin, detectionMixin, cameraMixin], @@ -190,7 +192,7 @@ created () { let loadOtherSettings = localStorage.getItem('otherSettings') if (loadOtherSettings) this.otherSettings = JSON.parse(loadOtherSettings) - let modelRoot = this.isCordova ? 'https://localhost' : '' + let modelRoot = new URL(import.meta.url).origin this.detectorName = this.f7route.params.region switch (this.detectorName) { case 'thorax': @@ -206,8 +208,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` + this.modelLocation = new URL(`/models/${this.detectorName}${this.otherSettings.mini ? '-mini' : ''}/model.json`,modelRoot).href + this.miniLocation = new URL(`./models/${this.detectorName}-mini/model.json`,modelRoot).href fetch(`${modelRoot}/models/${this.detectorName}/classes.json`) .then((mod) => { return mod.json() }) .then((classes) => {