/** * @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 deeplab from '@tensorflow-models/deeplab'; import { TaskModelLoader } from '../../task_model'; import { Runtime, Task, TFJSModelCommonLoadingOption } from '../common'; import { ImageSegmentationResult, ImageSegmenter } from './common'; declare type DeeplabNS = typeof deeplab; /** Loading options. */ export interface DeeplabTFJSLoadingOptions extends TFJSModelCommonLoadingOption, deeplab.ModelConfig { /** The backend to use to run TFJS models. Default to 'webgl'. */ backend: 'cpu' | 'webgl'; } /** Inference options. */ export interface DeeplabTFJSInferenceOptions extends deeplab.PredictionConfig { } /** Loader for deeplab TFJS model. */ export declare class DeeplapTFJSLoader extends TaskModelLoader { readonly metadata: { name: string; description: string; resourceUrls: { 'github': string; }; runtime: Runtime; version: string; supportedTasks: Task[]; }; readonly packageUrls: string[][]; readonly sourceModelGlobalNamespace = "deeplab"; protected transformSourceModel(sourceModelGlobal: DeeplabNS, loadingOptions?: DeeplabTFJSLoadingOptions): Promise; } /** * Pre-trained TFJS depelab model. * * Usage: * * ```js * // Load the model with options (optional). * // * // By default, it uses base='pascal' and quantizationBytes=2 with webgl * // backend. You can change them in the options parameter of the `load` * // function (see below for docs). * const model = await tfTask.ImageSegmentation.Deeplab.TFJS.load(); * * // Run inference on an image with options (optional). * const img = document.querySelector('img'); * const result = await model.predict(img); * console.log(result); * * // Clean up. * model.cleanUp(); * ``` * * Refer to `tfTask.ImageSegmenter` for the `predict` and `cleanUp` method. * * @docextratypes [ * {description: 'Options for `load`', symbol: 'DeeplabTFJSLoadingOptions'}, * {description: 'Options for `predict`', symbol: * 'DeeplabTFJSInferenceOptions'} * ] * * @doc {heading: 'Image Segmentation', subheading: 'Models'} */ export declare class DeeplabTFJS extends ImageSegmenter { private deeplabModel?; private loadingOptions?; constructor(deeplabModel?: deeplab.SemanticSegmentation, loadingOptions?: DeeplabTFJSLoadingOptions); predict(img: ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, infereceOptions?: DeeplabTFJSInferenceOptions): Promise; cleanUp(): void; } export declare const deeplabTfjsLoader: DeeplapTFJSLoader; export {};