diff --git a/mediapipe/tasks/web/core/task_runner.ts b/mediapipe/tasks/web/core/task_runner.ts index 8b43b272..666b0104 100644 --- a/mediapipe/tasks/web/core/task_runner.ts +++ b/mediapipe/tasks/web/core/task_runner.ts @@ -52,13 +52,14 @@ export async function createTaskRunner( fileset: WasmFileset, options: TaskRunnerOptions): Promise { const fileLocator: FileLocator = { locateFile(file): string { - const wasm = fileset.wasmBinaryPath.toString(); - if (wasm.includes(file)) { - return wasm; - } - const asset = fileset.assetBinaryPath?.toString(); - if (asset?.includes(file)) { - return asset; + // We currently only use a single .wasm file and a single .data file (for + // the tasks that have to load assets). We need to revisit how we + // initialize the file locator if we ever need to differentiate between + // diffferent files. + if (file.endsWith('.wasm')) { + return fileset.wasmBinaryPath.toString(); + } else if (fileset.assetBinaryPath && file.endsWith('.data')) { + return fileset.assetBinaryPath.toString(); } return file; }