Commit 27ec01e6 by vincent

removed tensorTo4D as it is unused

parent 4caa0f1a
import * as tf from '@tensorflow/tfjs-core';
import { NetInput } from '../NetInput';
export declare function getImageTensor(input: tf.Tensor | NetInput): tf.Tensor4D;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tf = require("@tensorflow/tfjs-core");
var NetInput_1 = require("../NetInput");
var tensorTo4D_1 = require("./tensorTo4D");
function getImageTensor(input) {
return tf.tidy(function () {
if (input instanceof tf.Tensor) {
return tensorTo4D_1.tensorTo4D(input);
}
if (!(input instanceof NetInput_1.NetInput)) {
throw new Error('getImageTensor - expected input to be a tensor or an instance of NetInput');
}
if (input.canvases.length > 1) {
throw new Error('getImageTensor - batch input is not accepted here');
}
return tf.fromPixels(input.canvases[0]).expandDims(0).toFloat();
});
}
exports.getImageTensor = getImageTensor;
//# sourceMappingURL=getImageTensor.js.map
\ No newline at end of file
{"version":3,"file":"getImageTensor.js","sourceRoot":"","sources":["../../src/commons/getImageTensor.ts"],"names":[],"mappings":";;AAAA,0CAA4C;AAE5C,wCAAuC;AACvC,2CAA0C;AAE1C,wBAA+B,KAA2B;IACxD,OAAO,EAAE,CAAC,IAAI,CAAC;QACb,IAAI,KAAK,YAAY,EAAE,CAAC,MAAM,EAAE;YAC9B,OAAO,uBAAU,CAAC,KAAK,CAAC,CAAA;SACzB;QAED,IAAI,CAAC,CAAC,KAAK,YAAY,mBAAQ,CAAC,EAAE;YAChC,MAAM,IAAI,KAAK,CAAC,2EAA2E,CAAC,CAAA;SAC7F;QAED,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;YAC7B,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAA;SACrE;QAED,OAAO,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,OAAO,EAAiB,CAAA;IAChF,CAAC,CAAC,CAAA;AACJ,CAAC;AAhBD,wCAgBC"}
\ No newline at end of file
import * as tf from '@tensorflow/tfjs-core';
export declare function tensorTo4D(input: tf.Tensor): tf.Tensor4D;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tf = require("@tensorflow/tfjs-core");
function tensorTo4D(input) {
if (input.rank !== 3 && input.rank !== 4) {
throw new Error('tensorTo4D - input tensor must be of rank 3 or 4');
}
return tf.tidy(function () { return input.rank === 3 ? input.expandDims(0) : input; });
}
exports.tensorTo4D = tensorTo4D;
//# sourceMappingURL=tensorTo4D.js.map
\ No newline at end of file
{"version":3,"file":"tensorTo4D.js","sourceRoot":"","sources":["../../src/commons/tensorTo4D.ts"],"names":[],"mappings":";;AAAA,0CAA4C;AAE5C,oBAA2B,KAAgB;IACzC,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC,EAAE;QACxC,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAA;KACpE;IACD,OAAO,EAAE,CAAC,IAAI,CACZ,cAAM,OAAA,KAAK,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,EAA9C,CAA8C,CACtC,CAAA;AAClB,CAAC;AAPD,gCAOC"}
\ No newline at end of file
import * as tf from '@tensorflow/tfjs-core';
import { NetInput } from '../NetInput';
import { BatchReshapeInfo } from './types';
export declare function toInputTensor(input: tf.Tensor | tf.Tensor[] | NetInput, inputSize: number, center?: boolean): {
batchTensor: tf.Tensor4D;
batchInfo: BatchReshapeInfo[];
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tf = require("@tensorflow/tfjs-core");
var NetInput_1 = require("../NetInput");
var padToSquare_1 = require("../padToSquare");
var tensorTo4D_1 = require("./tensorTo4D");
function toInputTensor(input, inputSize, center) {
if (center === void 0) { center = true; }
if (!(input instanceof tf.Tensor) && !(input instanceof NetInput_1.NetInput)) {
throw new Error('toInputTensor - expected input to be a tensor of an instance of NetInput');
}
return tf.tidy(function () {
var inputTensors = input instanceof NetInput_1.NetInput
? input.canvases.map(function (c) { return tf.expandDims(tf.fromPixels(c)); })
: [tensorTo4D_1.tensorTo4D(input)];
var preprocessedTensors = [];
var batchInfo = [];
inputTensors.forEach(function (inputTensor) {
var _a = inputTensor.shape.slice(1), originalHeight = _a[0], originalWidth = _a[1];
var imgTensor = padToSquare_1.padToSquare(inputTensor.toFloat(), center);
var _b = imgTensor.shape.slice(1), heightAfterPadding = _b[0], widthAfterPadding = _b[1];
if (heightAfterPadding !== inputSize || widthAfterPadding !== inputSize) {
imgTensor = tf.image.resizeBilinear(imgTensor, [inputSize, inputSize]);
}
preprocessedTensors.push(imgTensor);
batchInfo.push({
originalWidth: originalWidth,
originalHeight: originalHeight,
paddingX: widthAfterPadding - originalWidth,
paddingY: heightAfterPadding - originalHeight
});
});
var batchSize = inputTensors.length;
return {
batchTensor: tf.stack(preprocessedTensors).as4D(batchSize, inputSize, inputSize, 3),
batchInfo: batchInfo
};
});
}
exports.toInputTensor = toInputTensor;
//# sourceMappingURL=toInputTensor.js.map
\ No newline at end of file
{"version":3,"file":"toInputTensor.js","sourceRoot":"","sources":["../../src/commons/toInputTensor.ts"],"names":[],"mappings":";;AAAA,0CAA4C;AAE5C,wCAAuC;AACvC,8CAA6C;AAC7C,2CAA0C;AAG1C,uBACE,KAAyC,EACzC,SAAiB,EACjB,MAAsB;IAAtB,uBAAA,EAAA,aAAsB;IAGtB,IAAI,CAAC,CAAC,KAAK,YAAY,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,YAAY,mBAAQ,CAAC,EAAE;QACjE,MAAM,IAAI,KAAK,CAAC,0EAA0E,CAAC,CAAA;KAC5F;IAED,OAAO,EAAE,CAAC,IAAI,CAAC;QAEb,IAAM,YAAY,GAAG,KAAK,YAAY,mBAAQ;YAC5C,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,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x: tf.Tensor4D): tf.Tensor<tf.Rank>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tf = require("@tensorflow/tfjs-core");
var resizedImageSize = [512, 512];
var weight = tf.scalar(0.007843137718737125);
var bias = tf.scalar(1);
function resizeLayer(x) {
return tf.tidy(function () {
var resized = tf.image.resizeBilinear(x, resizedImageSize, false);
return tf.sub(tf.mul(resized, weight), bias);
});
}
exports.resizeLayer = resizeLayer;
//# sourceMappingURL=resizeLayer.js.map
\ No newline at end of file
{"version":3,"file":"resizeLayer.js","sourceRoot":"","sources":["../../src/faceDetectionNet/resizeLayer.ts"],"names":[],"mappings":";;AAAA,0CAA4C;AAE5C,IAAM,gBAAgB,GAAG,CAAC,GAAG,EAAE,GAAG,CAAqB,CAAA;AACvD,IAAM,MAAM,GAAG,EAAE,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAA;AAC9C,IAAM,IAAI,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;AAEzB,qBAA4B,CAAc;IACxC,OAAO,EAAE,CAAC,IAAI,CAAC;QAEb,IAAM,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,EAAE,gBAAgB,EAAE,KAAK,CAAC,CAAA;QACnE,OAAO,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,IAAI,CAAC,CAAA;IAE9C,CAAC,CAAC,CAAA;AACJ,CAAC;AAPD,kCAOC"}
\ No newline at end of file
import * as tf from '@tensorflow/tfjs-core';
import { NetInput } from './NetInput';
import { TNetInput } from './types';
export declare function getImageTensor(input: tf.Tensor | NetInput | TNetInput): tf.Tensor4D;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tf = require("@tensorflow/tfjs-core");
var NetInput_1 = require("./NetInput");
function getImageTensor(input) {
return tf.tidy(function () {
if (input instanceof tf.Tensor) {
var rank = input.shape.length;
if (rank !== 3 && rank !== 4) {
throw new Error('input tensor must be of rank 3 or 4');
}
return (rank === 3 ? input.expandDims(0) : input).toFloat();
}
var netInput = input instanceof NetInput_1.NetInput ? input : new NetInput_1.NetInput(input);
return tf.concat(netInput.canvases.map(function (canvas) {
return tf.fromPixels(canvas).expandDims(0).toFloat();
}));
});
}
exports.getImageTensor = getImageTensor;
//# sourceMappingURL=getImageTensor.js.map
\ No newline at end of file
{"version":3,"file":"getImageTensor.js","sourceRoot":"","sources":["../src/getImageTensor.ts"],"names":[],"mappings":";;AAAA,0CAA4C;AAE5C,uCAAsC;AAGtC,wBAA+B,KAAuC;IACpE,OAAO,EAAE,CAAC,IAAI,CAAC;QACb,IAAI,KAAK,YAAY,EAAE,CAAC,MAAM,EAAE;YAC9B,IAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAAA;YAC/B,IAAI,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,EAAE;gBAC5B,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;aACvD;YAED,OAAO,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,OAAO,EAAiB,CAAA;SAC3E;QAED,IAAM,QAAQ,GAAG,KAAK,YAAY,mBAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,mBAAQ,CAAC,KAAK,CAAC,CAAA;QACxE,OAAO,EAAE,CAAC,MAAM,CACd,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAA,MAAM;YAC1B,OAAA,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE;QAA7C,CAA6C,CAC9C,CACa,CAAA;IAClB,CAAC,CAAC,CAAA;AACJ,CAAC;AAlBD,wCAkBC"}
\ No newline at end of file
import * as tf from '@tensorflow/tfjs-core';
export function tensorTo4D(input: tf.Tensor): tf.Tensor4D {
if (input.rank !== 3 && input.rank !== 4) {
throw new Error('tensorTo4D - input tensor must be of rank 3 or 4')
}
return tf.tidy(
() => input.rank === 3 ? input.expandDims(0) : input
) as tf.Tensor4D
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment