face-api/build/ops/normalize.js

16 lines
608 B
JavaScript
Raw Normal View History

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.normalize = void 0;
const tf = require("@tensorflow/tfjs-core");
function normalize(x, meanRgb) {
2020-08-18 14:04:33 +02:00
return tf.tidy(() => {
const [r, g, b] = meanRgb;
const avg_r = tf.fill([...x.shape.slice(0, 3), 1], r);
const avg_g = tf.fill([...x.shape.slice(0, 3), 1], g);
const avg_b = tf.fill([...x.shape.slice(0, 3), 1], b);
const avg_rgb = tf.concat([avg_r, avg_g, avg_b], 3);
return tf.sub(x, avg_rgb);
});
}
exports.normalize = normalize;
2020-08-18 14:04:33 +02:00
//# sourceMappingURL=normalize.js.map