/** * @license * Copyright 2021 Google LLC. 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 * as cocoSsd from '@tensorflow-models/coco-ssd'; import { TaskModelLoader } from '../../task_model'; import { Runtime, Task, TFJSModelCommonLoadingOption } from '../common'; import { ObjectDetectionResult, ObjectDetector } from './common'; declare type CocoSsdNS = typeof cocoSsd; /** Loading options. */ export interface CocoSsdTFJSLoadingOptions extends TFJSModelCommonLoadingOption, cocoSsd.ModelConfig { } /** Inference options. */ export interface CocoSsdTFJSInferenceOptions { /** * The maximum number of bounding boxes of detected objects. There can be * multiple objects of the same class, but at different locations. Defaults * to 20. */ maxNumBoxes?: number; /** * The minimum score of the returned bounding boxes of detected objects. Value * between 0 and 1. Defaults to 0.5. */ minScore?: number; } /** Loader for cocossd TFJS model. */ export declare class CocoSsdTFJSLoader extends TaskModelLoader { readonly metadata: { name: string; description: string; resourceUrls: { 'github': string; }; runtime: Runtime; version: string; supportedTasks: Task[]; }; readonly packageUrls: string[][]; readonly sourceModelGlobalNamespace = "cocoSsd"; protected transformSourceModel(sourceModelGlobal: CocoSsdNS, loadingOptions?: CocoSsdTFJSLoadingOptions): Promise; } /** * Pre-trained TFJS coco-ssd model. * * Usage: * * ```js * // Load the model with options (optional). * // * // By default, it uses lite_mobilenet_v2 as the base model with webgl * // backend. You can change them in the `options` parameter of the `load` * // function (see below for docs). * const model = await tfTask.ObjectDetection.CocoSsd.TFJS.load(); * * // Run detection on an image with options (optional). * const img = document.querySelector('img'); * const result = await model.predict(img, {numMaxBoxes: 5}); * console.log(result.objects); * * // Clean up. * model.cleanUp(); * ``` * * Refer to `tfTask.ObjectDetector` for the `predict` and `cleanUp` method. * * @docextratypes [ * {description: 'Options for `load`', symbol: 'CocoSsdTFJSLoadingOptions'}, * {description: 'Options for `predict`', symbol: * 'CocoSsdTFJSInferenceOptions'} * ] * * @doc {heading: 'Object Detection', subheading: 'Models'} */ export declare class CocoSsdTFJS extends ObjectDetector { private cocoSsdModel?; private loadingOptions?; constructor(cocoSsdModel?: cocoSsd.ObjectDetection, loadingOptions?: CocoSsdTFJSLoadingOptions); predict(img: ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, infereceOptions?: CocoSsdTFJSInferenceOptions): Promise; cleanUp(): void; } export declare const cocoSsdTfjsLoader: CocoSsdTFJSLoader; export {};