forked from liuwei16/CSP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnms_wrapper.py
28 lines (23 loc) · 897 Bytes
/
nms_wrapper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# --------------------------------------------------------
# Fast R-CNN
# Copyright (c) 2015 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Ross Girshick
# --------------------------------------------------------
from nms.gpu_nms import gpu_nms
from nms.cpu_nms import cpu_nms
import numpy as np
def soft_nms(dets, sigma=0.5, Nt=0.3, threshold=0.001, method=1):
keep = cpu_soft_nms(np.ascontiguousarray(dets, dtype=np.float32),
np.float32(sigma), np.float32(Nt),
np.float32(threshold),
np.uint8(method))
return keep
def nms(dets, thresh, usegpu,gpu_id):
"""Dispatch to either CPU or GPU NMS implementations."""
if dets.shape[0] == 0:
return []
if usegpu:
return gpu_nms(dets, thresh, device_id=gpu_id)
else:
return cpu_nms(dets, thresh)