@@ -9,7 +9,7 @@ Heavily derived from https://github.com/ModelDepot/tfjs-yolo-tiny (ModelDepot: m
9
9
*/
10
10
import * as tf from '@tensorflow/tfjs' ;
11
11
import CLASS_NAMES from './../utils/COCO_CLASSES' ;
12
- import { iou } from './utils' ;
12
+ import iou from './utils' ;
13
13
14
14
const DEFAULTS = {
15
15
filterBoxesThreshold : 0.01 ,
@@ -172,7 +172,7 @@ class YOLO {
172
172
173
173
// Filterboxes by class probability threshold
174
174
const boxScores1 = tf . mul ( boxConfidence1 , tf . max ( boxClassProbs , 3 ) ) ;
175
- const boxClassProbMask = tf . greaterEqual ( boxScores , tf . scalar ( this . classProbThreshold ) ) ;
175
+ const boxClassProbMask = tf . greaterEqual ( boxScores1 , tf . scalar ( this . classProbThreshold ) ) ;
176
176
177
177
// getting classes indices
178
178
const classes1 = tf . argMax ( boxClassProbs , - 1 ) ;
@@ -202,6 +202,7 @@ class YOLO {
202
202
// Img Rescale
203
203
const Height = tf . scalar ( this . imgHeight ) ;
204
204
const Width = tf . scalar ( this . imgWidth ) ;
205
+ // 4
205
206
const ImageDims = tf . stack ( [ Height , Width , Height , Width ] ) . reshape ( [ 1 , 4 ] ) ;
206
207
const filteredBoxes2 = filteredBoxes1 . mul ( ImageDims ) ;
207
208
return [ filteredBoxes2 , filteredScores1 , filteredclasses1 ] ;
@@ -229,8 +230,8 @@ class YOLO {
229
230
let Push = true ;
230
231
for ( let i = 0 ; i < selectedBoxes . length ; i += 1 ) {
231
232
// Compare IoU of zipped[1], since that is the box coordinates arr
232
- const Iou = iou ( box [ 1 ] , selectedBoxes [ i ] ) ;
233
- if ( Iou > this . IOUThreshold ) {
233
+ const IOU = iou ( box [ 1 ] , selectedBoxes [ i ] [ 1 ] ) ;
234
+ if ( IOU > this . IOUThreshold ) {
234
235
Push = false ;
235
236
break ;
236
237
}
@@ -246,7 +247,7 @@ class YOLO {
246
247
const classProbRounded = Math . round ( classProb * 1000 ) / 10 ;
247
248
const className = this . classNames [ selectedBoxes [ id ] [ 2 ] ] ;
248
249
const classIndex = selectedBoxes [ id ] [ 2 ] ;
249
- const [ x1 , y1 , x2 , y2 ] = selectedBoxes [ id ] [ 1 ] ;
250
+ const [ y1 , x1 , y2 , x2 ] = selectedBoxes [ id ] [ 1 ] ;
250
251
// Need to get this out
251
252
// TODO : add a hsla color for later visualization
252
253
const resultObj = {
0 commit comments