Commit c493d1fd by vincent

last fixes for architecture

parent 45c9d6f8
......@@ -67,7 +67,6 @@ export function faceDetectionNet(weights: Float32Array) {
})
}
// TODO debug output
function forward(input: ImageData|ImageData[]|number[]) {
return tf.tidy(
() => forwardTensor(getImgTensor(input))
......@@ -100,10 +99,10 @@ export function faceDetectionNet(weights: Float32Array) {
.map(({ score, idx }) => ({
score,
box: {
left: Math.max(0, width * boxes.get(idx, 0)),
right: Math.min(width, width * boxes.get(idx, 1)),
top: Math.max(0, height * boxes.get(idx, 2)),
bottom: Math.min(height, height * boxes.get(idx, 3))
top: Math.max(0, height * boxes.get(idx, 0)),
left: Math.max(0, width * boxes.get(idx, 1)),
bottom: Math.min(height, height * boxes.get(idx, 2)),
right: Math.min(width, width * boxes.get(idx, 3))
}
}))
......
......@@ -21,7 +21,7 @@ function depthwiseConvLayer(
params.batch_norm_scale,
params.batch_norm_offset
)
return tf.relu(out)
return tf.clipByValue(out, 0, 6)
})
}
......@@ -35,6 +35,7 @@ export function mobileNetV1(x: tf.Tensor4D, params: FaceDetectionNet.MobileNetV1
let conv11 = null
let out = pointwiseConvLayer(x, params.conv_0_params, [2, 2])
params.conv_pair_params.forEach((param, i) => {
const layerIdx = i + 1
const depthwiseConvStrides = getStridesForLayerIdx(layerIdx)
......
......@@ -30,17 +30,17 @@ function decodeBoxesLayer(x0: tf.Tensor2D, x1: tf.Tensor2D) {
const vec = tf.unstack(tf.transpose(x1, [1, 0]))
const div0_out = tf.div(tf.mul(tf.exp(tf.div(vec[2], tf.scalar(5))), sizes[0]), tf.scalar(2))
const add0_out = tf.add(tf.mul(tf.exp(tf.div(vec[0], tf.scalar(10))), sizes[0]), centers[0])
const add0_out = tf.add(tf.mul(tf.div(vec[0], tf.scalar(10)), sizes[0]), centers[0])
const div1_out = tf.div(tf.mul(tf.exp(tf.div(vec[3], tf.scalar(5))), sizes[1]), tf.scalar(2))
const add1_out = tf.add(tf.mul(tf.exp(tf.div(vec[1], tf.scalar(10))), sizes[1]), centers[1])
const add1_out = tf.add(tf.mul(tf.div(vec[1], tf.scalar(10)), sizes[1]), centers[1])
return tf.transpose(
tf.stack([
tf.sub(div0_out, add0_out),
tf.sub(div1_out, add1_out),
tf.add(div0_out, add0_out),
tf.add(div1_out, add1_out)
tf.sub(add0_out, div0_out),
tf.sub(add1_out, div1_out),
tf.add(add0_out, div0_out),
tf.add(add1_out, div1_out)
]),
[1, 0]
)
......
......@@ -11,7 +11,7 @@ export function pointwiseConvLayer(
let out = tf.conv2d(x, params.filters, strides, 'same')
out = tf.add(out, params.batch_norm_offset)
return tf.relu(out)
return tf.clipByValue(out, 0, 6)
})
}
\ 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