/** * @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 mobilenet from '@tensorflow-models/mobilenet'; import { TaskModelLoader } from '../../task_model'; import { Runtime, Task, TFJSModelCommonLoadingOption } from '../common'; import { ImageClassificationResult, ImageClassifier } from './common'; declare type MobilenetNS = typeof mobilenet; /** Loading options. */ export interface MobilenetTFJSLoadingOptions extends TFJSModelCommonLoadingOption, mobilenet.ModelConfig { } /** Inference options. */ export interface MobilenetTFJSInferenceOptions { /** Number of top classes to return. */ topK?: number; } /** Loader for mobilenet TFJS model. */ export declare class MobilenetTFJSLoader extends TaskModelLoader { readonly metadata: { name: string; description: string; resourceUrls: { 'github': string; }; runtime: Runtime; version: string; supportedTasks: Task[]; }; readonly packageUrls: string[][]; readonly sourceModelGlobalNamespace = "mobilenet"; protected transformSourceModel(sourceModelGlobal: MobilenetNS, loadingOptions?: MobilenetTFJSLoadingOptions): Promise; } /** * Pre-trained TFJS mobilenet model. * * Usage: * * ```js * // Load the model with options (optional). * // * // By default, it uses mobilenet V1 with webgl backend. You can change them * // in the options parameter of the `load` function (see below for docs). * const model = await tfTask.ImageClassification.Mobilenet.TFJS.load(); * * // Run inference on an image with options (optional). * const img = document.querySelector('img'); * const result = await model.predict(img, {topK: 5}); * console.log(result.classes); * * // Clean up. * model.cleanUp(); * ``` * * Refer to `tfTask.ImageClassifier` for the `predict` and `cleanUp` method. * * @docextratypes [ * {description: 'Options for `load`', symbol: 'MobilenetTFJSLoadingOptions'}, * {description: 'Options for `predict`', symbol: * 'MobilenetTFJSInferenceOptions'} * ] * * @doc {heading: 'Image Classification', subheading: 'Models'} */ export declare class MobilenetTFJS extends ImageClassifier { private mobilenetModel?; private loadingOptions?; constructor(mobilenetModel?: mobilenet.MobileNet, loadingOptions?: MobilenetTFJSLoadingOptions); predict(img: ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, infereceOptions?: MobilenetTFJSInferenceOptions): Promise; } export declare const mobilenetTfjsLoader: MobilenetTFJSLoader; export {};