From a5a3e9d36b87ece085e1d8e88f454726120b13d6 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Tue, 12 Sep 2023 18:38:34 -0700 Subject: [PATCH] No public description PiperOrigin-RevId: 564894013 --- mediapipe/tasks/web/core/fileset_resolver.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/mediapipe/tasks/web/core/fileset_resolver.ts b/mediapipe/tasks/web/core/fileset_resolver.ts index 289ee4d92..34df13999 100644 --- a/mediapipe/tasks/web/core/fileset_resolver.ts +++ b/mediapipe/tasks/web/core/fileset_resolver.ts @@ -47,10 +47,15 @@ async function isSimdSupported(): Promise { } async function createFileset( - taskName: MediapipeTaskCategory, basePath = ''): Promise { + taskName: MediapipeTaskCategory, basePath?: string): Promise { const suffix = await isSimdSupported() ? 'wasm_internal' : 'wasm_nosimd_internal'; + // For backwards compatiblity, we treat an unset `basePath` as a relative + // path. FilesetResolver provides an empty path as a default, which is not + // rewritten to '.'. + basePath = basePath ?? '.'; + return { wasmLoaderPath: `${basePath}/${taskName}_${suffix}.js`, wasmBinaryPath: `${basePath}/${taskName}_${suffix}.wasm`, @@ -93,7 +98,7 @@ export class FilesetResolver { * @return A `WasmFileset` that can be used to initialize MediaPipe Audio * tasks. */ - static forAudioTasks(basePath?: string): Promise { + static forAudioTasks(basePath = ''): Promise { return createFileset('audio', basePath); } @@ -107,7 +112,7 @@ export class FilesetResolver { * @return A `WasmFileset` that can be used to initialize MediaPipe Text * tasks. */ - static forTextTasks(basePath?: string): Promise { + static forTextTasks(basePath = ''): Promise { return createFileset('text', basePath); } @@ -121,7 +126,7 @@ export class FilesetResolver { * @return A `WasmFileset` that can be used to initialize MediaPipe Vision * tasks. */ - static forVisionTasks(basePath?: string): Promise { + static forVisionTasks(basePath = ''): Promise { return createFileset('vision', basePath); } }