Commit 4968e0fc by Javier Ledo Vázquez

change more arraySync

parent 7fbc49c1
...@@ -85,15 +85,16 @@ export class SsdMobilenetv1 extends NeuralNetwork<NetParams> { ...@@ -85,15 +85,16 @@ export class SsdMobilenetv1 extends NeuralNetwork<NetParams> {
const padX = inputSize / reshapedDims.width const padX = inputSize / reshapedDims.width
const padY = inputSize / reshapedDims.height const padY = inputSize / reshapedDims.height
const boxesData = boxes.arraySync()
const results = indices const results = indices
.map(idx => { .map(idx => {
const [top, bottom] = [ const [top, bottom] = [
Math.max(0, boxes.arraySync()[idx][0]), Math.max(0, boxesData[idx][0]),
Math.min(1.0, boxes.arraySync()[idx][2]) Math.min(1.0, boxesData[idx][2])
].map(val => val * padY) ].map(val => val * padY)
const [left, right] = [ const [left, right] = [
Math.max(0, boxes.arraySync()[idx][1]), Math.max(0, boxesData[idx][1]),
Math.min(1.0, boxes.arraySync()[idx][3]) Math.min(1.0, boxesData[idx][3])
].map(val => val * padX) ].map(val => val * padX)
return new FaceDetection( return new FaceDetection(
scoresData[idx], scoresData[idx],
......
...@@ -49,14 +49,15 @@ export function nonMaxSuppression( ...@@ -49,14 +49,15 @@ export function nonMaxSuppression(
} }
function IOU(boxes: tf.Tensor2D, i: number, j: number) { function IOU(boxes: tf.Tensor2D, i: number, j: number) {
const yminI = Math.min(boxes.arraySync()[i][0], boxes.arraySync()[i][2]) const boxesData = boxes.arraySync()
const xminI = Math.min(boxes.arraySync()[i][1], boxes.arraySync()[i][3]) const yminI = Math.min(boxesData[i][0], boxesData[i][2])
const ymaxI = Math.max(boxes.arraySync()[i][0], boxes.arraySync()[i][2]) const xminI = Math.min(boxesData[i][1], boxesData[i][3])
const xmaxI = Math.max(boxes.arraySync()[i][1], boxes.arraySync()[i][3]) const ymaxI = Math.max(boxesData[i][0], boxesData[i][2])
const yminJ = Math.min(boxes.arraySync()[j][0], boxes.arraySync()[j][2]) const xmaxI = Math.max(boxesData[i][1], boxesData[i][3])
const xminJ = Math.min(boxes.arraySync()[j][1], boxes.arraySync()[j][3]) const yminJ = Math.min(boxesData[j][0], boxesData[j][2])
const ymaxJ = Math.max(boxes.arraySync()[j][0], boxes.arraySync()[j][2]) const xminJ = Math.min(boxesData[j][1], boxesData[j][3])
const xmaxJ = Math.max(boxes.arraySync()[j][1], boxes.arraySync()[j][3]) const ymaxJ = Math.max(boxesData[j][0], boxesData[j][2])
const xmaxJ = Math.max(boxesData[j][1], boxesData[j][3])
const areaI = (ymaxI - yminI) * (xmaxI - xminI) const areaI = (ymaxI - yminI) * (xmaxI - xminI)
const areaJ = (ymaxJ - yminJ) * (xmaxJ - xminJ) const areaJ = (ymaxJ - yminJ) * (xmaxJ - xminJ)
if (areaI <= 0 || areaJ <= 0) { if (areaI <= 0 || areaJ <= 0) {
......
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