Skip to content

Commit 28a7745

Browse files
fixed nms issue
1 parent 84e287c commit 28a7745

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/tinyYolov2/TinyYolov2.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { FaceDetection } from '../FaceDetection';
88
import { NetInput } from '../NetInput';
99
import { toNetInput } from '../toNetInput';
1010
import { TNetInput } from '../types';
11-
import { BOX_ANCHORS, INPUT_SIZES, NUM_BOXES, NUM_CELLS } from './config';
11+
import { BOX_ANCHORS, INPUT_SIZES, IOU_THRESHOLD, NUM_BOXES, NUM_CELLS } from './config';
1212
import { convWithBatchNorm } from './convWithBatchNorm';
1313
import { extractParams } from './extractParams';
1414
import { getDefaultParams } from './getDefaultParams';
@@ -111,7 +111,17 @@ export class TinyYolov2 extends NeuralNetwork<NetParams> {
111111
boxesTensor.dispose()
112112
scoresTensor.dispose()
113113

114-
const indices = nonMaxSuppression(boxes, scores, 0.4, true)
114+
const indices = nonMaxSuppression(
115+
boxes.map(box => new BoundingBox(
116+
box.left * inputSize,
117+
box.top * inputSize,
118+
box.right * inputSize,
119+
box.bottom * inputSize
120+
)),
121+
scores,
122+
IOU_THRESHOLD,
123+
true
124+
)
115125

116126
const detections = indices.map(idx =>
117127
new FaceDetection(

src/tinyYolov2/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Point } from '../Point';
33
export const INPUT_SIZES = { xs: 224, sm: 320, md: 416, lg: 608 }
44
export const NUM_CELLS = { xs: 7, sm: 10, md: 13, lg: 19 }
55
export const NUM_BOXES = 5
6+
export const IOU_THRESHOLD = 0.4
67

78
export const BOX_ANCHORS = [
89
new Point(0.738768, 0.874946),

0 commit comments

Comments
 (0)