Internal change
PiperOrigin-RevId: 489345940
This commit is contained in:
parent
ab3a5f0fbf
commit
6f3cb340e1
|
@ -25,7 +25,7 @@ mediapipe_ts_library(
|
|||
"//mediapipe/tasks/web/core",
|
||||
"//mediapipe/tasks/web/core:classifier_options",
|
||||
"//mediapipe/tasks/web/core:task_runner",
|
||||
"//mediapipe/web/graph_runner:wasm_mediapipe_lib_ts",
|
||||
"//mediapipe/web/graph_runner:graph_runner_ts",
|
||||
],
|
||||
)
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import {convertClassifierOptionsToProto} from '../../../../tasks/web/components/
|
|||
import {convertFromClassificationResultProto} from '../../../../tasks/web/components/processors/classifier_result';
|
||||
import {TaskRunner} from '../../../../tasks/web/core/task_runner';
|
||||
import {WasmLoaderOptions} from '../../../../tasks/web/core/wasm_loader_options';
|
||||
import {createMediaPipeLib, FileLocator} from '../../../../web/graph_runner/wasm_mediapipe_lib';
|
||||
import {createMediaPipeLib, FileLocator} from '../../../../web/graph_runner/graph_runner';
|
||||
// Placeholder for internal dependency on trusted resource url
|
||||
|
||||
import {AudioClassifierOptions} from './audio_classifier_options';
|
||||
|
|
|
@ -18,9 +18,9 @@ mediapipe_ts_library(
|
|||
"task_runner.ts",
|
||||
],
|
||||
deps = [
|
||||
"//mediapipe/web/graph_runner:graph_runner_image_lib_ts",
|
||||
"//mediapipe/web/graph_runner:graph_runner_ts",
|
||||
"//mediapipe/web/graph_runner:register_model_resources_graph_service_ts",
|
||||
"//mediapipe/web/graph_runner:wasm_mediapipe_image_lib_ts",
|
||||
"//mediapipe/web/graph_runner:wasm_mediapipe_lib_ts",
|
||||
],
|
||||
)
|
||||
|
||||
|
|
|
@ -15,12 +15,12 @@
|
|||
*/
|
||||
|
||||
import {SupportModelResourcesGraphService} from '../../../web/graph_runner/register_model_resources_graph_service';
|
||||
import {SupportImage} from '../../../web/graph_runner/wasm_mediapipe_image_lib';
|
||||
import {WasmMediaPipeLib, WasmModule} from '../../../web/graph_runner/wasm_mediapipe_lib';
|
||||
import {SupportImage} from '../../../web/graph_runner/graph_runner_image_lib';
|
||||
import {GraphRunner, WasmModule} from '../../../web/graph_runner/graph_runner';
|
||||
|
||||
// tslint:disable-next-line:enforce-name-casing
|
||||
const WasmMediaPipeImageLib =
|
||||
SupportModelResourcesGraphService(SupportImage(WasmMediaPipeLib));
|
||||
SupportModelResourcesGraphService(SupportImage(GraphRunner));
|
||||
|
||||
/** Base class for all MediaPipe Tasks. */
|
||||
export abstract class TaskRunner extends WasmMediaPipeImageLib {
|
||||
|
|
|
@ -26,7 +26,7 @@ mediapipe_ts_library(
|
|||
"//mediapipe/tasks/web/core",
|
||||
"//mediapipe/tasks/web/core:classifier_options",
|
||||
"//mediapipe/tasks/web/core:task_runner",
|
||||
"//mediapipe/web/graph_runner:wasm_mediapipe_lib_ts",
|
||||
"//mediapipe/web/graph_runner:graph_runner_ts",
|
||||
],
|
||||
)
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import {convertClassifierOptionsToProto} from '../../../../tasks/web/components/
|
|||
import {convertFromClassificationResultProto} from '../../../../tasks/web/components/processors/classifier_result';
|
||||
import {TaskRunner} from '../../../../tasks/web/core/task_runner';
|
||||
import {WasmLoaderOptions} from '../../../../tasks/web/core/wasm_loader_options';
|
||||
import {createMediaPipeLib, FileLocator} from '../../../../web/graph_runner/wasm_mediapipe_lib';
|
||||
import {createMediaPipeLib, FileLocator} from '../../../../web/graph_runner/graph_runner';
|
||||
// Placeholder for internal dependency on trusted resource url
|
||||
|
||||
import {TextClassifierOptions} from './text_classifier_options';
|
||||
|
|
|
@ -25,7 +25,7 @@ mediapipe_ts_library(
|
|||
"//mediapipe/tasks/web/core",
|
||||
"//mediapipe/tasks/web/core:embedder_options",
|
||||
"//mediapipe/tasks/web/core:task_runner",
|
||||
"//mediapipe/web/graph_runner:wasm_mediapipe_lib_ts",
|
||||
"//mediapipe/web/graph_runner:graph_runner_ts",
|
||||
],
|
||||
)
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import {convertEmbedderOptionsToProto} from '../../../../tasks/web/components/pr
|
|||
import {convertFromEmbeddingResultProto} from '../../../../tasks/web/components/processors/embedder_result';
|
||||
import {TaskRunner} from '../../../../tasks/web/core/task_runner';
|
||||
import {WasmLoaderOptions} from '../../../../tasks/web/core/wasm_loader_options';
|
||||
import {createMediaPipeLib, FileLocator} from '../../../../web/graph_runner/wasm_mediapipe_lib';
|
||||
import {createMediaPipeLib, FileLocator} from '../../../../web/graph_runner/graph_runner';
|
||||
// Placeholder for internal dependency on trusted resource url
|
||||
|
||||
import {TextEmbedderOptions} from './text_embedder_options';
|
||||
|
|
|
@ -21,6 +21,6 @@ mediapipe_ts_library(
|
|||
"//mediapipe/tasks/web/components/processors:base_options",
|
||||
"//mediapipe/tasks/web/core",
|
||||
"//mediapipe/tasks/web/core:task_runner",
|
||||
"//mediapipe/web/graph_runner:wasm_mediapipe_lib_ts",
|
||||
"//mediapipe/web/graph_runner:graph_runner_ts",
|
||||
],
|
||||
)
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
import {BaseOptions as BaseOptionsProto} from '../../../../tasks/cc/core/proto/base_options_pb';
|
||||
import {convertBaseOptionsToProto} from '../../../../tasks/web/components/processors/base_options';
|
||||
import {TaskRunner} from '../../../../tasks/web/core/task_runner';
|
||||
import {ImageSource} from '../../../../web/graph_runner/wasm_mediapipe_lib';
|
||||
import {ImageSource} from '../../../../web/graph_runner/graph_runner';
|
||||
|
||||
import {VisionTaskOptions} from './vision_task_options';
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ mediapipe_ts_library(
|
|||
"//mediapipe/tasks/web/core",
|
||||
"//mediapipe/tasks/web/core:classifier_options",
|
||||
"//mediapipe/tasks/web/vision/core:vision_task_runner",
|
||||
"//mediapipe/web/graph_runner:wasm_mediapipe_lib_ts",
|
||||
"//mediapipe/web/graph_runner:graph_runner_ts",
|
||||
],
|
||||
)
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ import {Landmark} from '../../../../tasks/web/components/containers/landmark';
|
|||
import {convertClassifierOptionsToProto} from '../../../../tasks/web/components/processors/classifier_options';
|
||||
import {WasmLoaderOptions} from '../../../../tasks/web/core/wasm_loader_options';
|
||||
import {VisionTaskRunner} from '../../../../tasks/web/vision/core/vision_task_runner';
|
||||
import {createMediaPipeLib, FileLocator, ImageSource, WasmModule} from '../../../../web/graph_runner/wasm_mediapipe_lib';
|
||||
import {createMediaPipeLib, FileLocator, ImageSource, WasmModule} from '../../../../web/graph_runner/graph_runner';
|
||||
// Placeholder for internal dependency on trusted resource url
|
||||
|
||||
import {GestureRecognizerOptions} from './gesture_recognizer_options';
|
||||
|
|
|
@ -27,7 +27,7 @@ mediapipe_ts_library(
|
|||
"//mediapipe/tasks/web/components/containers:landmark",
|
||||
"//mediapipe/tasks/web/core",
|
||||
"//mediapipe/tasks/web/vision/core:vision_task_runner",
|
||||
"//mediapipe/web/graph_runner:wasm_mediapipe_lib_ts",
|
||||
"//mediapipe/web/graph_runner:graph_runner_ts",
|
||||
],
|
||||
)
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ import {Category} from '../../../../tasks/web/components/containers/category';
|
|||
import {Landmark} from '../../../../tasks/web/components/containers/landmark';
|
||||
import {WasmLoaderOptions} from '../../../../tasks/web/core/wasm_loader_options';
|
||||
import {VisionTaskRunner} from '../../../../tasks/web/vision/core/vision_task_runner';
|
||||
import {createMediaPipeLib, FileLocator, ImageSource, WasmModule} from '../../../../web/graph_runner/wasm_mediapipe_lib';
|
||||
import {createMediaPipeLib, FileLocator, ImageSource, WasmModule} from '../../../../web/graph_runner/graph_runner';
|
||||
// Placeholder for internal dependency on trusted resource url
|
||||
|
||||
import {HandLandmarkerOptions} from './hand_landmarker_options';
|
||||
|
|
|
@ -25,7 +25,7 @@ mediapipe_ts_library(
|
|||
"//mediapipe/tasks/web/core",
|
||||
"//mediapipe/tasks/web/core:classifier_options",
|
||||
"//mediapipe/tasks/web/vision/core:vision_task_runner",
|
||||
"//mediapipe/web/graph_runner:wasm_mediapipe_lib_ts",
|
||||
"//mediapipe/web/graph_runner:graph_runner_ts",
|
||||
],
|
||||
)
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import {convertClassifierOptionsToProto} from '../../../../tasks/web/components/
|
|||
import {convertFromClassificationResultProto} from '../../../../tasks/web/components/processors/classifier_result';
|
||||
import {WasmLoaderOptions} from '../../../../tasks/web/core/wasm_loader_options';
|
||||
import {VisionTaskRunner} from '../../../../tasks/web/vision/core/vision_task_runner';
|
||||
import {createMediaPipeLib, FileLocator, ImageSource} from '../../../../web/graph_runner/wasm_mediapipe_lib';
|
||||
import {createMediaPipeLib, FileLocator, ImageSource} from '../../../../web/graph_runner/graph_runner';
|
||||
// Placeholder for internal dependency on trusted resource url
|
||||
|
||||
import {ImageClassifierOptions} from './image_classifier_options';
|
||||
|
|
|
@ -25,7 +25,7 @@ mediapipe_ts_library(
|
|||
"//mediapipe/tasks/web/core:embedder_options",
|
||||
"//mediapipe/tasks/web/vision/core:vision_task_options",
|
||||
"//mediapipe/tasks/web/vision/core:vision_task_runner",
|
||||
"//mediapipe/web/graph_runner:wasm_mediapipe_lib_ts",
|
||||
"//mediapipe/web/graph_runner:graph_runner_ts",
|
||||
],
|
||||
)
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import {convertEmbedderOptionsToProto} from '../../../../tasks/web/components/pr
|
|||
import {convertFromEmbeddingResultProto} from '../../../../tasks/web/components/processors/embedder_result';
|
||||
import {WasmLoaderOptions} from '../../../../tasks/web/core/wasm_loader_options';
|
||||
import {VisionTaskRunner} from '../../../../tasks/web/vision/core/vision_task_runner';
|
||||
import {createMediaPipeLib, FileLocator, ImageSource} from '../../../../web/graph_runner/wasm_mediapipe_lib';
|
||||
import {createMediaPipeLib, FileLocator, ImageSource} from '../../../../web/graph_runner/graph_runner';
|
||||
// Placeholder for internal dependency on trusted resource url
|
||||
|
||||
import {ImageEmbedderOptions} from './image_embedder_options';
|
||||
|
|
|
@ -22,7 +22,7 @@ mediapipe_ts_library(
|
|||
"//mediapipe/tasks/web/components/containers:category",
|
||||
"//mediapipe/tasks/web/core",
|
||||
"//mediapipe/tasks/web/vision/core:vision_task_runner",
|
||||
"//mediapipe/web/graph_runner:wasm_mediapipe_lib_ts",
|
||||
"//mediapipe/web/graph_runner:graph_runner_ts",
|
||||
],
|
||||
)
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ import {BaseOptions as BaseOptionsProto} from '../../../../tasks/cc/core/proto/b
|
|||
import {ObjectDetectorOptions as ObjectDetectorOptionsProto} from '../../../../tasks/cc/vision/object_detector/proto/object_detector_options_pb';
|
||||
import {WasmLoaderOptions} from '../../../../tasks/web/core/wasm_loader_options';
|
||||
import {VisionTaskRunner} from '../../../../tasks/web/vision/core/vision_task_runner';
|
||||
import {createMediaPipeLib, FileLocator, ImageSource} from '../../../../web/graph_runner/wasm_mediapipe_lib';
|
||||
import {createMediaPipeLib, FileLocator, ImageSource} from '../../../../web/graph_runner/graph_runner';
|
||||
// Placeholder for internal dependency on trusted resource url
|
||||
|
||||
import {ObjectDetectorOptions} from './object_detector_options';
|
||||
|
|
|
@ -3,32 +3,24 @@
|
|||
load("//mediapipe/framework/port:build_config.bzl", "mediapipe_ts_library")
|
||||
|
||||
package(default_visibility = [
|
||||
":internal",
|
||||
"//mediapipe/tasks:internal",
|
||||
])
|
||||
|
||||
package_group(
|
||||
name = "internal",
|
||||
packages = [
|
||||
"//mediapipe/app/pursuit/wasm/web_ml_cpu/typescript/...",
|
||||
],
|
||||
)
|
||||
|
||||
mediapipe_ts_library(
|
||||
name = "wasm_mediapipe_lib_ts",
|
||||
name = "graph_runner_ts",
|
||||
srcs = [
|
||||
":wasm_mediapipe_lib.ts",
|
||||
":graph_runner.ts",
|
||||
],
|
||||
allow_unoptimized_namespaces = True,
|
||||
)
|
||||
|
||||
mediapipe_ts_library(
|
||||
name = "wasm_mediapipe_image_lib_ts",
|
||||
name = "graph_runner_image_lib_ts",
|
||||
srcs = [
|
||||
":wasm_mediapipe_image_lib.ts",
|
||||
":graph_runner_image_lib.ts",
|
||||
],
|
||||
allow_unoptimized_namespaces = True,
|
||||
deps = [":wasm_mediapipe_lib_ts"],
|
||||
deps = [":graph_runner_ts"],
|
||||
)
|
||||
|
||||
mediapipe_ts_library(
|
||||
|
@ -37,5 +29,5 @@ mediapipe_ts_library(
|
|||
":register_model_resources_graph_service.ts",
|
||||
],
|
||||
allow_unoptimized_namespaces = True,
|
||||
deps = [":wasm_mediapipe_lib_ts"],
|
||||
deps = [":graph_runner_ts"],
|
||||
)
|
||||
|
|
|
@ -129,7 +129,7 @@ declare global {
|
|||
declare function importScripts(...urls: Array<string|URL>): void;
|
||||
|
||||
/**
|
||||
* Valid types of image sources which we can run our WasmMediaPipeLib over.
|
||||
* Valid types of image sources which we can run our GraphRunner over.
|
||||
*/
|
||||
export type ImageSource =
|
||||
HTMLCanvasElement|HTMLVideoElement|HTMLImageElement|ImageData|ImageBitmap;
|
||||
|
@ -138,7 +138,7 @@ export type ImageSource =
|
|||
/** A listener that will be invoked with an absl::StatusCode and message. */
|
||||
export type ErrorListener = (code: number, message: string) => void;
|
||||
|
||||
// Internal type of constructors used for initializing WasmMediaPipeLib and
|
||||
// Internal type of constructors used for initializing GraphRunner and
|
||||
// subclasses.
|
||||
type WasmMediaPipeConstructor<LibType> =
|
||||
(new (
|
||||
|
@ -151,7 +151,7 @@ type WasmMediaPipeConstructor<LibType> =
|
|||
* into canvas, or else return the output WebGLTexture. Takes a WebAssembly
|
||||
* Module (must be instantiated to self.Module).
|
||||
*/
|
||||
export class WasmMediaPipeLib {
|
||||
export class GraphRunner {
|
||||
// TODO: These should be protected/private, but are left exposed for
|
||||
// now so that we can use proper TS mixins with this class as a base. This
|
||||
// should be somewhat fixed when we create our .d.ts files.
|
||||
|
@ -989,7 +989,7 @@ async function runScript(scriptUrl: string) {
|
|||
/**
|
||||
* Global function to initialize Wasm blob and load runtime assets for a
|
||||
* specialized MediaPipe library. This allows us to create a requested
|
||||
* subclass inheriting from WasmMediaPipeLib.
|
||||
* subclass inheriting from GraphRunner.
|
||||
* @param constructorFcn The name of the class to instantiate via "new".
|
||||
* @param wasmLoaderScript Url for the wasm-runner script; produced by the build
|
||||
* process.
|
||||
|
@ -1043,12 +1043,12 @@ export async function createMediaPipeLib<LibType>(
|
|||
* @return promise A promise which will resolve when initialization has
|
||||
* completed successfully.
|
||||
*/
|
||||
export async function createWasmMediaPipeLib(
|
||||
export async function createGraphRunner(
|
||||
wasmLoaderScript?: string,
|
||||
assetLoaderScript?: string,
|
||||
glCanvas?: HTMLCanvasElement|OffscreenCanvas|null,
|
||||
fileLocator?: FileLocator): Promise<WasmMediaPipeLib> {
|
||||
fileLocator?: FileLocator): Promise<GraphRunner> {
|
||||
return createMediaPipeLib(
|
||||
WasmMediaPipeLib, wasmLoaderScript, assetLoaderScript, glCanvas,
|
||||
GraphRunner, wasmLoaderScript, assetLoaderScript, glCanvas,
|
||||
fileLocator);
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
import {ImageSource, WasmMediaPipeLib} from './wasm_mediapipe_lib';
|
||||
import {ImageSource, GraphRunner} from './graph_runner';
|
||||
|
||||
/**
|
||||
* We extend from a WasmMediaPipeLib constructor. This ensures our mixin has
|
||||
* We extend from a GraphRunner constructor. This ensures our mixin has
|
||||
* access to the wasmModule, among other things. The `any` type is required for
|
||||
* mixin constructors.
|
||||
*/
|
||||
// tslint:disable-next-line:no-any
|
||||
type LibConstructor = new (...args: any[]) => WasmMediaPipeLib;
|
||||
type LibConstructor = new (...args: any[]) => GraphRunner;
|
||||
|
||||
/**
|
||||
* Declarations for Emscripten's WebAssembly Module behavior, so TS compiler
|
||||
|
@ -19,10 +19,10 @@ export declare interface WasmImageModule {
|
|||
}
|
||||
|
||||
/**
|
||||
* An implementation of WasmMediaPipeLib that supports binding GPU image data as
|
||||
* An implementation of GraphRunner that supports binding GPU image data as
|
||||
* `mediapipe::Image` instances. We implement as a proper TS mixin, to allow for
|
||||
* effective multiple inheritance. Example usage:
|
||||
* `const WasmMediaPipeImageLib = SupportImage(WasmMediaPipeLib);`
|
||||
* `const WasmMediaPipeImageLib = SupportImage(GraphRunner);`
|
||||
*/
|
||||
// tslint:disable-next-line:enforce-name-casing
|
||||
export function SupportImage<TBase extends LibConstructor>(Base: TBase) {
|
|
@ -1,12 +1,12 @@
|
|||
import {WasmMediaPipeLib} from './wasm_mediapipe_lib';
|
||||
import {GraphRunner} from './graph_runner';
|
||||
|
||||
/**
|
||||
* We extend from a WasmMediaPipeLib constructor. This ensures our mixin has
|
||||
* We extend from a GraphRunner constructor. This ensures our mixin has
|
||||
* access to the wasmModule, among other things. The `any` type is required for
|
||||
* mixin constructors.
|
||||
*/
|
||||
// tslint:disable-next-line:no-any
|
||||
type LibConstructor = new (...args: any[]) => WasmMediaPipeLib;
|
||||
type LibConstructor = new (...args: any[]) => GraphRunner;
|
||||
|
||||
/**
|
||||
* Declarations for Emscripten's WebAssembly Module behavior, so TS compiler
|
||||
|
@ -17,11 +17,11 @@ export declare interface WasmModuleRegisterModelResources {
|
|||
}
|
||||
|
||||
/**
|
||||
* An implementation of WasmMediaPipeLib that supports registering model
|
||||
* An implementation of GraphRunner that supports registering model
|
||||
* resources to a cache, in the form of a GraphService C++-side. We implement as
|
||||
* a proper TS mixin, to allow for effective multiple inheritance. Sample usage:
|
||||
* `const WasmMediaPipeImageLib = SupportModelResourcesGraphService(
|
||||
* WasmMediaPipeLib);`
|
||||
* GraphRunner);`
|
||||
*/
|
||||
// tslint:disable:enforce-name-casing
|
||||
export function SupportModelResourcesGraphService<TBase extends LibConstructor>(
|
||||
|
|
Loading…
Reference in New Issue
Block a user