Add shared options for Text and Audio Tasks

PiperOrigin-RevId: 489186644
This commit is contained in:
Sebastian Schmidt 2022-11-17 05:26:56 -08:00 committed by Copybara-Service
parent ea4989b6f1
commit 3ccf7308e0
18 changed files with 121 additions and 18 deletions

View File

@ -65,8 +65,8 @@ public abstract class AudioEmbedderResult implements TaskResult {
/**
* Contains one set of results per classifier head. A {@link EmbeddingResult} usually represents
* one audio embedding result in an audio stream, and s only available when running with the audio
* stream mode.
* one audio embedding result in an audio stream, and is only available when running with the
* audio stream mode.
*/
public abstract Optional<EmbeddingResult> embeddingResult();

View File

@ -20,7 +20,7 @@ package com.google.mediapipe.tasks.audio.core;
* <ul>
* <li>AUDIO_CLIPS: The mode for running a mediapipe audio task on independent audio clips.
* <li>AUDIO_STREAM: The mode for running a mediapipe audio task on an audio stream, such as from
* microphone.
* a microphone.
* </ul>
*/
public enum RunningMode {

View File

@ -36,6 +36,7 @@ mediapipe_ts_declaration(
"audio_classifier_result.d.ts",
],
deps = [
"//mediapipe/tasks/web/audio/core:audio_task_options",
"//mediapipe/tasks/web/components/containers:category",
"//mediapipe/tasks/web/components/containers:classification_result",
"//mediapipe/tasks/web/core",

View File

@ -14,4 +14,9 @@
* limitations under the License.
*/
export {ClassifierOptions as AudioClassifierOptions} from '../../../../tasks/web/core/classifier_options';
import {AudioTaskOptions} from '../../../../tasks/web/audio/core/audio_task_options';
import {ClassifierOptions} from '../../../../tasks/web/core/classifier_options';
/** Options to configure the MediaPipe Audio Classifier Task */
export declare interface AudioClassifierOptions extends ClassifierOptions,
AudioTaskOptions {}

View File

@ -0,0 +1,13 @@
# This package contains options shared by all MediaPipe Audio Tasks for Web.
load("//mediapipe/framework/port:build_config.bzl", "mediapipe_ts_declaration")
package(default_visibility = ["//mediapipe/tasks:internal"])
mediapipe_ts_declaration(
name = "audio_task_options",
srcs = ["audio_task_options.d.ts"],
deps = [
"//mediapipe/tasks/web/core",
],
)

View File

@ -0,0 +1,44 @@
/**
* Copyright 2022 The MediaPipe Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {BaseOptions} from '../../../../tasks/web/core/base_options';
/**
* MediaPipe audio task running mode. A MediaPipe audio task can be run with
* two different modes:
* - audio_clips: The mode for running a mediapipe audio task on independent
* audio clips.
* - audio_stream: The mode for running a mediapipe audio task on an audio
* stream, such as from a microphone.
* </ul>
*/
export type RunningMode = 'audio_clips'|'audio_stream';
/** The options for configuring a MediaPipe Audio Task. */
export declare interface AudioTaskOptions {
/** Options to configure the loading of the model assets. */
baseOptions?: BaseOptions;
/**
* The running mode of the task. Default to the audio_clips mode.
* Audio tasks have two running modes:
* 1) The mode for running a mediapipe audio task on independent
* audio clips.
* 2) The mode for running a mediapipe audio task on an audio
* stream, such as from a microphone.
*/
runningMode?: RunningMode;
}

View File

@ -16,11 +16,8 @@
import {BaseOptions} from '../../../tasks/web/core/base_options';
/** Options to configure the Mediapipe Classifier Task. */
/** Options to configure a MediaPipe Classifier Task. */
export declare interface ClassifierOptions {
/** Options to configure the loading of the model assets. */
baseOptions?: BaseOptions;
/**
* The locale to use for display names specified through the TFLite Model
* Metadata, if any. Defaults to English.

View File

@ -16,11 +16,8 @@
import {BaseOptions} from '../../../tasks/web/core/base_options';
/** Options to configure the MediaPipe Embedder Task */
/** Options to configure a MediaPipe Embedder Task */
export declare interface EmbedderOptions {
/** Options to configure the loading of the model assets. */
baseOptions?: BaseOptions;
/**
* Whether to normalize the returned feature vector with L2 norm. Use this
* option only if the model does not already contain a native L2_NORMALIZATION

View File

@ -0,0 +1,11 @@
# This package contains options shared by all MediaPipe Texxt Tasks for Web.
load("//mediapipe/framework/port:build_config.bzl", "mediapipe_ts_declaration")
package(default_visibility = ["//mediapipe/tasks:internal"])
mediapipe_ts_declaration(
name = "text_task_options",
srcs = ["text_task_options.d.ts"],
deps = ["//mediapipe/tasks/web/core"],
)

View File

@ -0,0 +1,23 @@
/**
* Copyright 2022 The MediaPipe Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {BaseOptions} from '../../../../tasks/web/core/base_options';
/** The options for configuring a MediaPipe Text task. */
export declare interface TextTaskOptions {
/** Options to configure the loading of the model assets. */
baseOptions?: BaseOptions;
}

View File

@ -40,5 +40,6 @@ mediapipe_ts_declaration(
"//mediapipe/tasks/web/components/containers:category",
"//mediapipe/tasks/web/components/containers:classification_result",
"//mediapipe/tasks/web/core:classifier_options",
"//mediapipe/tasks/web/text/core:text_task_options",
],
)

View File

@ -14,4 +14,9 @@
* limitations under the License.
*/
export {ClassifierOptions as TextClassifierOptions} from '../../../../tasks/web/core/classifier_options';
import {ClassifierOptions} from '../../../../tasks/web/core/classifier_options';
import {TextTaskOptions} from '../../../../tasks/web/text/core/text_task_options';
/** Options to configure the MediaPipe Text Classifier Task */
export declare interface TextClassifierOptions extends ClassifierOptions,
TextTaskOptions {}

View File

@ -39,5 +39,6 @@ mediapipe_ts_declaration(
"//mediapipe/tasks/web/components/containers:embedding_result",
"//mediapipe/tasks/web/core",
"//mediapipe/tasks/web/core:embedder_options",
"//mediapipe/tasks/web/text/core:text_task_options",
],
)

View File

@ -14,4 +14,9 @@
* limitations under the License.
*/
export {EmbedderOptions as TextEmbedderOptions} from '../../../../tasks/web/core/embedder_options';
import {EmbedderOptions} from '../../../../tasks/web/core/embedder_options';
import {TextTaskOptions} from '../../../../tasks/web/text/core/text_task_options';
/** Options to configure the MediaPipe Text Embedder Task */
export declare interface TextEmbedderOptions extends EmbedderOptions,
TextTaskOptions {}

View File

@ -1,4 +1,4 @@
# This package contains options shared by all MediaPipe Tasks for Web.
# This package contains options shared by all MediaPipe Vision Tasks for Web.
load("//mediapipe/framework/port:build_config.bzl", "mediapipe_ts_declaration", "mediapipe_ts_library")

View File

@ -17,7 +17,7 @@
import {BaseOptions} from '../../../../tasks/web/core/base_options';
/**
* The two running modes of a video task.
* The two running modes of a vision task.
* 1) The image mode for processing single image inputs.
* 2) The video mode for processing decoded frames of a video.
*/

View File

@ -17,6 +17,6 @@
import {ClassifierOptions} from '../../../../tasks/web/core/classifier_options';
import {VisionTaskOptions} from '../../../../tasks/web/vision/core/vision_task_options';
/** Ooptions to configure the image classifier task. */
/** Options to configure the MediaPipe Image Classifier Task. */
export declare interface ImageClassifierOptions extends ClassifierOptions,
VisionTaskOptions {}

View File

@ -17,6 +17,6 @@
import {EmbedderOptions} from '../../../../tasks/web/core/embedder_options';
import {VisionTaskOptions} from '../../../../tasks/web/vision/core/vision_task_options';
/** The options for configuring a MediaPipe image embedder task. */
/** Options for configuring a MediaPipe Image Embedder task. */
export declare interface ImageEmbedderOptions extends EmbedderOptions,
VisionTaskOptions {}