Re-use classifier options for ObjectDetector

PiperOrigin-RevId: 492206856
This commit is contained in:
Sebastian Schmidt 2022-12-01 08:45:47 -08:00 committed by Copybara-Service
parent 3ee37800e2
commit e685ac9344
3 changed files with 5 additions and 30 deletions

View File

@ -36,6 +36,7 @@ export function computeCosineSimilarity(u: Embedding, v: Embedding): number {
throw new Error(
'Cannot compute cosine similarity between quantized and float embeddings.');
}
function convertToBytes(data: Uint8Array): number[] {
return Array.from(data, v => v - 128);
}

View File

@ -35,6 +35,7 @@ mediapipe_ts_declaration(
deps = [
"//mediapipe/tasks/web/components/containers:category",
"//mediapipe/tasks/web/core",
"//mediapipe/tasks/web/core:classifier_options",
"//mediapipe/tasks/web/vision/core:vision_task_options",
],
)

View File

@ -14,36 +14,9 @@
* limitations under the License.
*/
import {ClassifierOptions} from '../../../../tasks/web/core/classifier_options';
import {VisionTaskOptions} from '../../../../tasks/web/vision/core/vision_task_options';
/** Options to configure the MediaPipe Object Detector Task */
export interface ObjectDetectorOptions extends VisionTaskOptions {
/**
* The locale to use for display names specified through the TFLite Model
* Metadata, if any. Defaults to English.
*/
displayNamesLocale?: string|undefined;
/** The maximum number of top-scored detection results to return. */
maxResults?: number|undefined;
/**
* Overrides the value provided in the model metadata. Results below this
* value are rejected.
*/
scoreThreshold?: number|undefined;
/**
* Allowlist of category names. If non-empty, detection results whose category
* name is not in this set will be filtered out. Duplicate or unknown category
* names are ignored. Mutually exclusive with `categoryDenylist`.
*/
categoryAllowlist?: string[]|undefined;
/**
* Denylist of category names. If non-empty, detection results whose category
* name is in this set will be filtered out. Duplicate or unknown category
* names are ignored. Mutually exclusive with `categoryAllowlist`.
*/
categoryDenylist?: string[]|undefined;
}
export interface ObjectDetectorOptions extends VisionTaskOptions,
ClassifierOptions {}