tensorflow-helpers
Version:
Helper functions to use tensorflow in nodejs for transfer learning, image classification, and more
50 lines (49 loc) • 1.26 kB
TypeScript
import { Tensor } from '@tensorflow/tfjs-core';
import { ImageModel } from './model';
type tf = {
tidy: (...args: any[]) => any;
};
type image = string | Tensor;
type node = string | {
name: string;
};
export declare function getImageFeatures(options: {
tf: tf;
imageModel: ImageModel;
image: image;
/** default: 'Identity:0' */
outputNode?: string;
/** default: getLastSpatialNodeName(model) */
spatialNode?: node;
}): Promise<{
/** e.g. `[1 x 7 x 7 x 160]` spatial feature map */
spatialFeatures: Tensor;
/** e.g. `[1 x 1280]` global average pooled features */
pooledFeatures: Tensor;
}>;
export declare function getImageFeatures(options: {
tf: tf;
imageModel: ImageModel;
image: image;
/** default: 'Identity:0' */
outputNode?: string;
/** e.g. `imageModel.spatialNodesWithUniqueShapes` */
spatialNodes: node[];
}): Promise<{
/**
* e.g.
* ```
* [
* [1 x 56 x 56 x 24],
* [1 x 28 x 28 x 40],
* [1 x 14 x 14 x 80],
* [1 x 14 x 14 x 112],
* [1 x 7 x 7 x 160],
* ]
* ```
* */
spatialFeatures: Tensor[];
/** e.g. `[1 x 1280]` global average pooled features */
pooledFeatures: Tensor;
}>;
export {};