From 1b947df0c2a6ce6b4c631cc396b9da7902a0469a Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Tue, 11 Apr 2023 19:20:53 -0700 Subject: [PATCH] Allow relative URLs for WASM loading PiperOrigin-RevId: 523572715 --- mediapipe/tasks/web/core/fileset_resolver.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mediapipe/tasks/web/core/fileset_resolver.ts b/mediapipe/tasks/web/core/fileset_resolver.ts index ae17c5775..5c845b80c 100644 --- a/mediapipe/tasks/web/core/fileset_resolver.ts +++ b/mediapipe/tasks/web/core/fileset_resolver.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -// Placeholder for internal dependency on trusted resource URL builder +// Placeholder for internal dependency on resourceUrlSafeByReview import {WasmFileset} from './wasm_fileset'; @@ -30,6 +30,9 @@ const WASM_SIMD_CHECK = new Uint8Array([ 2, 1, 0, 10, 10, 1, 8, 0, 65, 0, 253, 15, 253, 98, 11 ]); +/** The categories of tasks supported by MediaPipe. */ +type MediapipeTaskCategory = 'audio'|'text'|'vision'; + async function isSimdSupported(): Promise { if (supportsSimd === undefined) { try { @@ -44,7 +47,7 @@ async function isSimdSupported(): Promise { } async function createFileset( - taskName: string, basePath = ''): Promise { + taskName: MediapipeTaskCategory, basePath = ''): Promise { const suffix = await isSimdSupported() ? 'wasm_internal' : 'wasm_nosimd_internal';