diff --git a/js/onnx.js b/js/onnx.js index b0ecf57..fc06fa0 100644 --- a/js/onnx.js +++ b/js/onnx.js @@ -6,11 +6,13 @@ import { modelData, onnxMaskToImage } from "./onnx_helper.js"; ort.env.wasm.wasmPaths = "https://cdn.jsdelivr.net/npm/onnxruntime-web/dist/"; export let model = null; +let modelType = null; // Initialize the ONNX model -export const initModel = async (modelType) => { +export const initModel = async (type) => { try { - if (!model) { + if (!model || modelType !== type) { + modelType = type; model = await ort.InferenceSession.create( `${location.protocol}//${location.host}/sam_model?type=${modelType}` );