@@ -49,14 +49,15 @@ export function nonMaxSuppression(
49
49
}
50
50
51
51
function IOU ( boxes : tf . Tensor2D , i : number , j : number ) {
52
- const yminI = Math . min ( boxes . arraySync ( ) [ i ] [ 0 ] , boxes . arraySync ( ) [ i ] [ 2 ] )
53
- const xminI = Math . min ( boxes . arraySync ( ) [ i ] [ 1 ] , boxes . arraySync ( ) [ i ] [ 3 ] )
54
- const ymaxI = Math . max ( boxes . arraySync ( ) [ i ] [ 0 ] , boxes . arraySync ( ) [ i ] [ 2 ] )
55
- const xmaxI = Math . max ( boxes . arraySync ( ) [ i ] [ 1 ] , boxes . arraySync ( ) [ i ] [ 3 ] )
56
- const yminJ = Math . min ( boxes . arraySync ( ) [ j ] [ 0 ] , boxes . arraySync ( ) [ j ] [ 2 ] )
57
- const xminJ = Math . min ( boxes . arraySync ( ) [ j ] [ 1 ] , boxes . arraySync ( ) [ j ] [ 3 ] )
58
- const ymaxJ = Math . max ( boxes . arraySync ( ) [ j ] [ 0 ] , boxes . arraySync ( ) [ j ] [ 2 ] )
59
- const xmaxJ = Math . max ( boxes . arraySync ( ) [ j ] [ 1 ] , boxes . arraySync ( ) [ j ] [ 3 ] )
52
+ const boxesData = boxes . arraySync ( )
53
+ const yminI = Math . min ( boxesData [ i ] [ 0 ] , boxesData [ i ] [ 2 ] )
54
+ const xminI = Math . min ( boxesData [ i ] [ 1 ] , boxesData [ i ] [ 3 ] )
55
+ const ymaxI = Math . max ( boxesData [ i ] [ 0 ] , boxesData [ i ] [ 2 ] )
56
+ const xmaxI = Math . max ( boxesData [ i ] [ 1 ] , boxesData [ i ] [ 3 ] )
57
+ const yminJ = Math . min ( boxesData [ j ] [ 0 ] , boxesData [ j ] [ 2 ] )
58
+ const xminJ = Math . min ( boxesData [ j ] [ 1 ] , boxesData [ j ] [ 3 ] )
59
+ const ymaxJ = Math . max ( boxesData [ j ] [ 0 ] , boxesData [ j ] [ 2 ] )
60
+ const xmaxJ = Math . max ( boxesData [ j ] [ 1 ] , boxesData [ j ] [ 3 ] )
60
61
const areaI = ( ymaxI - yminI ) * ( xmaxI - xminI )
61
62
const areaJ = ( ymaxJ - yminJ ) * ( xmaxJ - xminJ )
62
63
if ( areaI <= 0 || areaJ <= 0 ) {
0 commit comments