tfjs-tiny-yolov2
Version:
Tiny YOLO v2 object detection with tensorflow.js.
54 lines (53 loc) • 2.38 kB
TypeScript
import * as tf from '@tensorflow/tfjs-core';
import { Dimensions, IDimensions, Point } from 'tfjs-image-recognition-base';
import { TinyYolov2TrainableConfig } from './config';
import { GroundTruth, GroundTruthWithGridPosition } from './types';
export declare class TinyYolov2LossFunction {
private _config;
private _reshapedImgDims;
private _outputTensor;
private _groundTruth;
private _predictedBoxes;
noObjectLossMask: tf.Tensor4D;
objectLossMask: tf.Tensor4D;
coordBoxOffsetMask: tf.Tensor4D;
coordBoxSizeMask: tf.Tensor4D;
groundTruthClassScoresMask: tf.Tensor4D;
constructor(outputTensor: tf.Tensor4D, groundTruth: GroundTruth[], predictedBoxes: GroundTruthWithGridPosition[], reshapedImgDims: IDimensions, config: TinyYolov2TrainableConfig);
readonly config: TinyYolov2TrainableConfig;
readonly reshapedImgDims: Dimensions;
readonly outputTensor: tf.Tensor4D;
readonly groundTruth: GroundTruthWithGridPosition[];
readonly predictedBoxes: GroundTruthWithGridPosition[];
readonly inputSize: number;
readonly withClassScores: boolean;
readonly boxEncodingSize: number;
readonly anchors: Point[];
readonly numBoxes: number;
readonly numCells: number;
readonly gridCellEncodingSize: number;
toOutputTensorShape(tensor: tf.Tensor): tf.Tensor<tf.Rank>;
computeLoss(): {
noObjectLoss: tf.Tensor<tf.Rank.R0>;
objectLoss: tf.Tensor<tf.Rank.R0>;
coordLoss: tf.Tensor<tf.Rank.R0>;
classLoss: tf.Tensor<tf.Rank.R0>;
totalLoss: tf.Tensor<tf.Rank.R0>;
};
computeNoObjectLoss(): tf.Tensor<tf.Rank.R0>;
computeObjectLoss(): tf.Tensor<tf.Rank.R0>;
computeClassLoss(): tf.Tensor<tf.Rank.R0>;
computeCoordLoss(): tf.Tensor<tf.Rank.R0>;
computeCoordBoxOffsetError(): tf.Tensor4D;
computeCoordBoxSizeError(): tf.Tensor4D;
private computeLossTerm(scale, mask, lossTensor);
private squaredSumOverMask(mask, lossTensor);
private validateGroundTruthBoxes(groundTruth);
private assignGroundTruthToAnchors(groundTruth);
private createGroundTruthMask();
private createCoordAndScoreMasks();
private createOneHotClassScoreMask();
private computeIous();
computeCoordBoxOffsets(): tf.Tensor<tf.Rank>;
computeCoordBoxSizes(): tf.Tensor<tf.Rank>;
}