Migrate remaining MP Tasks Libraries to ts_declarations

PiperOrigin-RevId: 488752799
This commit is contained in:
Sebastian Schmidt 2022-11-15 14:03:17 -08:00 committed by Copybara-Service
parent 1689112b23
commit 496720308c
18 changed files with 79 additions and 41 deletions

View File

@ -2,7 +2,7 @@
# #
# This task takes audio data and outputs the classification result. # This task takes audio data and outputs the classification result.
load("//mediapipe/framework/port:build_config.bzl", "mediapipe_ts_library") load("//mediapipe/framework/port:build_config.bzl", "mediapipe_ts_declaration", "mediapipe_ts_library")
package(default_visibility = ["//mediapipe/tasks:internal"]) package(default_visibility = ["//mediapipe/tasks:internal"])
@ -10,12 +10,9 @@ licenses(["notice"])
mediapipe_ts_library( mediapipe_ts_library(
name = "audio_classifier", name = "audio_classifier",
srcs = [ srcs = ["audio_classifier.ts"],
"audio_classifier.ts",
"audio_classifier_options.ts",
"audio_classifier_result.ts",
],
deps = [ deps = [
":audio_classifier_types",
"//mediapipe/framework:calculator_jspb_proto", "//mediapipe/framework:calculator_jspb_proto",
"//mediapipe/framework:calculator_options_jspb_proto", "//mediapipe/framework:calculator_options_jspb_proto",
"//mediapipe/tasks/cc/audio/audio_classifier/proto:audio_classifier_graph_options_jspb_proto", "//mediapipe/tasks/cc/audio/audio_classifier/proto:audio_classifier_graph_options_jspb_proto",
@ -31,3 +28,17 @@ mediapipe_ts_library(
"//mediapipe/web/graph_runner:wasm_mediapipe_lib_ts", "//mediapipe/web/graph_runner:wasm_mediapipe_lib_ts",
], ],
) )
mediapipe_ts_declaration(
name = "audio_classifier_types",
srcs = [
"audio_classifier_options.d.ts",
"audio_classifier_result.d.ts",
],
deps = [
"//mediapipe/tasks/web/components/containers:category",
"//mediapipe/tasks/web/components/containers:classification_result",
"//mediapipe/tasks/web/core",
"//mediapipe/tasks/web/core:classifier_options",
],
)

View File

@ -29,6 +29,9 @@ import {createMediaPipeLib, FileLocator} from '../../../../web/graph_runner/wasm
import {AudioClassifierOptions} from './audio_classifier_options'; import {AudioClassifierOptions} from './audio_classifier_options';
import {AudioClassifierResult} from './audio_classifier_result'; import {AudioClassifierResult} from './audio_classifier_result';
export * from './audio_classifier_options';
export * from './audio_classifier_result';
const MEDIAPIPE_GRAPH = const MEDIAPIPE_GRAPH =
'mediapipe.tasks.audio.audio_classifier.AudioClassifierGraph'; 'mediapipe.tasks.audio.audio_classifier.AudioClassifierGraph';

View File

@ -14,7 +14,4 @@
* limitations under the License. * limitations under the License.
*/ */
// Audio Classifier
export * from '../../../tasks/web/audio/audio_classifier/audio_classifier_options';
export * from '../../../tasks/web/audio/audio_classifier/audio_classifier_result';
export * from '../../../tasks/web/audio/audio_classifier/audio_classifier'; export * from '../../../tasks/web/audio/audio_classifier/audio_classifier';

View File

@ -9,5 +9,6 @@ mediapipe_ts_library(
srcs = ["index.ts"], srcs = ["index.ts"],
deps = [ deps = [
"//mediapipe/tasks/web/text/text_classifier", "//mediapipe/tasks/web/text/text_classifier",
"//mediapipe/tasks/web/text/text_embedder",
], ],
) )

View File

@ -14,7 +14,5 @@
* limitations under the License. * limitations under the License.
*/ */
// Text Classifier
export * from '../../../tasks/web/text/text_classifier/text_classifier_options';
export * from '../../../tasks/web/text/text_classifier/text_classifier_result';
export * from '../../../tasks/web/text/text_classifier/text_classifier'; export * from '../../../tasks/web/text/text_classifier/text_classifier';
export * from '../../../tasks/web/text/text_embedder/text_embedder';

View File

@ -3,7 +3,7 @@
# This task takes text input performs Natural Language classification (including # This task takes text input performs Natural Language classification (including
# BERT-based text classification). # BERT-based text classification).
load("//mediapipe/framework/port:build_config.bzl", "mediapipe_ts_library") load("//mediapipe/framework/port:build_config.bzl", "mediapipe_ts_declaration", "mediapipe_ts_library")
package(default_visibility = ["//mediapipe/tasks:internal"]) package(default_visibility = ["//mediapipe/tasks:internal"])
@ -11,12 +11,9 @@ licenses(["notice"])
mediapipe_ts_library( mediapipe_ts_library(
name = "text_classifier", name = "text_classifier",
srcs = [ srcs = ["text_classifier.ts"],
"text_classifier.ts",
"text_classifier_options.ts",
"text_classifier_result.ts",
],
deps = [ deps = [
":text_classifier_types",
"//mediapipe/framework:calculator_jspb_proto", "//mediapipe/framework:calculator_jspb_proto",
"//mediapipe/framework:calculator_options_jspb_proto", "//mediapipe/framework:calculator_options_jspb_proto",
"//mediapipe/tasks/cc/components/containers/proto:classifications_jspb_proto", "//mediapipe/tasks/cc/components/containers/proto:classifications_jspb_proto",
@ -32,3 +29,16 @@ mediapipe_ts_library(
"//mediapipe/web/graph_runner:wasm_mediapipe_lib_ts", "//mediapipe/web/graph_runner:wasm_mediapipe_lib_ts",
], ],
) )
mediapipe_ts_declaration(
name = "text_classifier_types",
srcs = [
"text_classifier_options.d.ts",
"text_classifier_result.d.ts",
],
deps = [
"//mediapipe/tasks/web/components/containers:category",
"//mediapipe/tasks/web/components/containers:classification_result",
"//mediapipe/tasks/web/core:classifier_options",
],
)

View File

@ -29,6 +29,9 @@ import {createMediaPipeLib, FileLocator} from '../../../../web/graph_runner/wasm
import {TextClassifierOptions} from './text_classifier_options'; import {TextClassifierOptions} from './text_classifier_options';
import {TextClassifierResult} from './text_classifier_result'; import {TextClassifierResult} from './text_classifier_result';
export * from './text_classifier_options';
export * from './text_classifier_result';
const INPUT_STREAM = 'text_in'; const INPUT_STREAM = 'text_in';
const CLASSIFICATIONS_STREAM = 'classifications_out'; const CLASSIFICATIONS_STREAM = 'classifications_out';
const TEXT_CLASSIFIER_GRAPH = const TEXT_CLASSIFIER_GRAPH =

View File

@ -3,7 +3,7 @@
# This task takes text input and performs embedding # This task takes text input and performs embedding
# #
load("//mediapipe/framework/port:build_config.bzl", "mediapipe_ts_library") load("//mediapipe/framework/port:build_config.bzl", "mediapipe_ts_declaration", "mediapipe_ts_library")
package(default_visibility = ["//mediapipe/tasks:internal"]) package(default_visibility = ["//mediapipe/tasks:internal"])
@ -11,13 +11,11 @@ licenses(["notice"])
mediapipe_ts_library( mediapipe_ts_library(
name = "text_embedder", name = "text_embedder",
srcs = [ srcs = ["text_embedder.ts"],
"text_embedder.ts",
"text_embedder_options.d.ts",
"text_embedder_result.d.ts",
],
deps = [ deps = [
":text_embedder_types",
"//mediapipe/framework:calculator_jspb_proto", "//mediapipe/framework:calculator_jspb_proto",
"//mediapipe/framework:calculator_options_jspb_proto",
"//mediapipe/tasks/cc/components/containers/proto:embeddings_jspb_proto", "//mediapipe/tasks/cc/components/containers/proto:embeddings_jspb_proto",
"//mediapipe/tasks/cc/text/text_embedder/proto:text_embedder_graph_options_jspb_proto", "//mediapipe/tasks/cc/text/text_embedder/proto:text_embedder_graph_options_jspb_proto",
"//mediapipe/tasks/web/components/containers:embedding_result", "//mediapipe/tasks/web/components/containers:embedding_result",
@ -30,3 +28,16 @@ mediapipe_ts_library(
"//mediapipe/web/graph_runner:wasm_mediapipe_lib_ts", "//mediapipe/web/graph_runner:wasm_mediapipe_lib_ts",
], ],
) )
mediapipe_ts_declaration(
name = "text_embedder_types",
srcs = [
"text_embedder_options.d.ts",
"text_embedder_result.d.ts",
],
deps = [
"//mediapipe/tasks/web/components/containers:embedding_result",
"//mediapipe/tasks/web/core",
"//mediapipe/tasks/web/core:embedder_options",
],
)

View File

@ -29,6 +29,8 @@ import {createMediaPipeLib, FileLocator} from '../../../../web/graph_runner/wasm
import {TextEmbedderOptions} from './text_embedder_options'; import {TextEmbedderOptions} from './text_embedder_options';
import {TextEmbedderResult} from './text_embedder_result'; import {TextEmbedderResult} from './text_embedder_result';
export * from './text_embedder_options';
export * from './text_embedder_result';
// The OSS JS API does not support the builder pattern. // The OSS JS API does not support the builder pattern.
// tslint:disable:jspb-use-builder-pattern // tslint:disable:jspb-use-builder-pattern

View File

@ -2,7 +2,7 @@
# #
# This task performs embedding extraction on images. # This task performs embedding extraction on images.
load("//mediapipe/framework/port:build_config.bzl", "mediapipe_ts_library") load("//mediapipe/framework/port:build_config.bzl", "mediapipe_ts_declaration", "mediapipe_ts_library")
package(default_visibility = ["//mediapipe/tasks:internal"]) package(default_visibility = ["//mediapipe/tasks:internal"])
@ -10,12 +10,9 @@ licenses(["notice"])
mediapipe_ts_library( mediapipe_ts_library(
name = "image_embedder", name = "image_embedder",
srcs = [ srcs = ["image_embedder.ts"],
"image_embedder.ts",
"image_embedder_options.ts",
"image_embedder_result.ts",
],
deps = [ deps = [
":image_embedder_types",
"//mediapipe/framework:calculator_jspb_proto", "//mediapipe/framework:calculator_jspb_proto",
"//mediapipe/framework:calculator_options_jspb_proto", "//mediapipe/framework:calculator_options_jspb_proto",
"//mediapipe/tasks/cc/components/containers/proto:embeddings_jspb_proto", "//mediapipe/tasks/cc/components/containers/proto:embeddings_jspb_proto",
@ -31,3 +28,17 @@ mediapipe_ts_library(
"//mediapipe/web/graph_runner:wasm_mediapipe_lib_ts", "//mediapipe/web/graph_runner:wasm_mediapipe_lib_ts",
], ],
) )
mediapipe_ts_declaration(
name = "image_embedder_types",
srcs = [
"image_embedder_options.d.ts",
"image_embedder_result.d.ts",
],
deps = [
"//mediapipe/tasks/web/components/containers:embedding_result",
"//mediapipe/tasks/web/core",
"//mediapipe/tasks/web/core:embedder_options",
"//mediapipe/tasks/web/vision/core:running_mode",
],
)

View File

@ -38,6 +38,8 @@ const EMBEDDINGS_STREAM = 'embeddings_out';
const TEXT_EMBEDDER_CALCULATOR = const TEXT_EMBEDDER_CALCULATOR =
'mediapipe.tasks.vision.image_embedder.ImageEmbedderGraph'; 'mediapipe.tasks.vision.image_embedder.ImageEmbedderGraph';
export * from './image_embedder_options';
export * from './image_embedder_result';
export {ImageSource}; // Used in the public API export {ImageSource}; // Used in the public API
/** Performs embedding extraction on images. */ /** Performs embedding extraction on images. */

View File

@ -14,19 +14,8 @@
* limitations under the License. * limitations under the License.
*/ */
// Image Classifier
export * from '../../../tasks/web/vision/image_classifier/image_classifier'; export * from '../../../tasks/web/vision/image_classifier/image_classifier';
// Image Embedder
export * from '../../../tasks/web/vision/image_embedder/image_embedder_options';
export * from '../../../tasks/web/vision/image_embedder/image_embedder_result';
export * from '../../../tasks/web/vision/image_embedder/image_embedder'; export * from '../../../tasks/web/vision/image_embedder/image_embedder';
// Gesture Recognizer
export * from '../../../tasks/web/vision/gesture_recognizer/gesture_recognizer'; export * from '../../../tasks/web/vision/gesture_recognizer/gesture_recognizer';
// Hand Landmarker
export * from '../../../tasks/web/vision/hand_landmarker/hand_landmarker'; export * from '../../../tasks/web/vision/hand_landmarker/hand_landmarker';
// Object Detector
export * from '../../../tasks/web/vision/object_detector/object_detector'; export * from '../../../tasks/web/vision/object_detector/object_detector';