UNPKG

@timebutt/face-api.js

Version:

JavaScript API for face detection and face recognition in the browser with tensorflow.js

20 lines 1.32 kB
import * as tf from '@tensorflow/tfjs-core'; import { SeparableConvParams } from './types'; export function extractSeparableConvParamsFactory(extractWeights, paramMappings) { return function (channelsIn, channelsOut, mappedPrefix) { var depthwise_filter = tf.tensor4d(extractWeights(3 * 3 * channelsIn), [3, 3, channelsIn, 1]); var pointwise_filter = tf.tensor4d(extractWeights(channelsIn * channelsOut), [1, 1, channelsIn, channelsOut]); var bias = tf.tensor1d(extractWeights(channelsOut)); paramMappings.push({ paramPath: "".concat(mappedPrefix, "/depthwise_filter") }, { paramPath: "".concat(mappedPrefix, "/pointwise_filter") }, { paramPath: "".concat(mappedPrefix, "/bias") }); return new SeparableConvParams(depthwise_filter, pointwise_filter, bias); }; } export function loadSeparableConvParamsFactory(extractWeightEntry) { return function (prefix) { var depthwise_filter = extractWeightEntry("".concat(prefix, "/depthwise_filter"), 4); var pointwise_filter = extractWeightEntry("".concat(prefix, "/pointwise_filter"), 4); var bias = extractWeightEntry("".concat(prefix, "/bias"), 1); return new SeparableConvParams(depthwise_filter, pointwise_filter, bias); }; } //# sourceMappingURL=extractSeparableConvParamsFactory.js.map