Skip to content

Commit 8547cdb

Browse files
committed
fixed some errors
1 parent 4d83cc9 commit 8547cdb

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/YOLO/index.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Heavily derived from https://github.com/ModelDepot/tfjs-yolo-tiny (ModelDepot: m
99
*/
1010
import * as tf from '@tensorflow/tfjs';
1111
import CLASS_NAMES from './../utils/COCO_CLASSES';
12-
import { iou } from './utils';
12+
import iou from './utils';
1313

1414
const DEFAULTS = {
1515
filterBoxesThreshold: 0.01,
@@ -172,7 +172,7 @@ class YOLO {
172172

173173
// Filterboxes by class probability threshold
174174
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));
176176

177177
// getting classes indices
178178
const classes1 = tf.argMax(boxClassProbs, -1);
@@ -202,6 +202,7 @@ class YOLO {
202202
// Img Rescale
203203
const Height = tf.scalar(this.imgHeight);
204204
const Width = tf.scalar(this.imgWidth);
205+
// 4
205206
const ImageDims = tf.stack([Height, Width, Height, Width]).reshape([1, 4]);
206207
const filteredBoxes2 = filteredBoxes1.mul(ImageDims);
207208
return [filteredBoxes2, filteredScores1, filteredclasses1];
@@ -229,8 +230,8 @@ class YOLO {
229230
let Push = true;
230231
for (let i = 0; i < selectedBoxes.length; i += 1) {
231232
// 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) {
234235
Push = false;
235236
break;
236237
}
@@ -246,7 +247,7 @@ class YOLO {
246247
const classProbRounded = Math.round(classProb * 1000) / 10;
247248
const className = this.classNames[selectedBoxes[id][2]];
248249
const classIndex = selectedBoxes[id][2];
249-
const [x1, y1, x2, y2] = selectedBoxes[id][1];
250+
const [y1, x1, y2, x2] = selectedBoxes[id][1];
250251
// Need to get this out
251252
// TODO : add a hsla color for later visualization
252253
const resultObj = {

src/YOLO/utils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@ const iou = (box1, box2) => {
2727
// compute the IoU
2828
return interarea / unionarea;
2929
};
30+
3031
export default iou;

0 commit comments

Comments
 (0)