UNPKG

emoji-net

Version:

EmojiNet is an image to emoji recognizer based on MobileNet / Google Emoji Scavenger Hunt

46 lines 1.74 kB
/// <reference types="node" /> /** * @license * Copyright 2018 Google LLC * * 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 * * https://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 'isomorphic-fetch'; import * as tfc from '@tensorflow/tfjs-core'; import { FrozenModel } from '@tensorflow/tfjs-converter'; import { EmojiId, EmojiName } from './emoji-classes'; declare const MOBILENET_SIZE = 224; interface PredictItem { id: EmojiId; name: EmojiName; probobility: number; } declare class EmojiNet { model?: FrozenModel; load(): Promise<void>; dispose(): void; recognize(src: string | Buffer): Promise<PredictItem[]>; /** * Infer through MobileNet, assumes variables have been loaded. This does * standard ImageNet pre-processing before inferring through the model. This * method returns named activations as well as softmax logits. * * @param input un-preprocessed input Array. * @return The softmax logits. */ protected predict(input: tfc.Tensor): tfc.Tensor1D; protected getTopKClasses(predictions: tfc.Tensor1D, topK: number): PredictItem[]; } export { MOBILENET_SIZE, EmojiNet, }; //# sourceMappingURL=emoji-net.d.ts.map