aboutsummaryrefslogtreecommitdiffstats
path: root/anime-face-detector/nms_wrapper.py
diff options
context:
space:
mode:
authorcarp <25677564+carp@users.noreply.github.com>2020-07-13 13:27:55 -0400
committercarp <25677564+carp@users.noreply.github.com>2020-07-13 13:27:55 -0400
commitcb961ed0d6896309336159bda34ed2f75fb60a84 (patch)
tree6d75fcd9bd32b2e884e299ea97e361513036b3a2 /anime-face-detector/nms_wrapper.py
parente78f351e06e432a607ebadc8de3ea6d27315c088 (diff)
downloadyaoi-communism-cb961ed0d6896309336159bda34ed2f75fb60a84.tar.gz
yaoi-communism-cb961ed0d6896309336159bda34ed2f75fb60a84.zip
add face detection
Diffstat (limited to 'anime-face-detector/nms_wrapper.py')
-rw-r--r--anime-face-detector/nms_wrapper.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/anime-face-detector/nms_wrapper.py b/anime-face-detector/nms_wrapper.py
new file mode 100644
index 0000000..ca900e8
--- /dev/null
+++ b/anime-face-detector/nms_wrapper.py
@@ -0,0 +1,29 @@
+from enum import Enum
+
+
+class NMSType(Enum):
+ PY_NMS = 1
+ CPU_NMS = 2
+ GPU_NMS = 3
+
+
+default_nms_type = NMSType.PY_NMS
+
+
+class NMSWrapper:
+ def __init__(self, nms_type=default_nms_type):
+ assert type(nms_type) == NMSType
+ if nms_type == NMSType.PY_NMS:
+ from nms.py_cpu_nms import py_cpu_nms
+ self._nms = py_cpu_nms
+ elif nms_type == NMSType.CPU_NMS:
+ from nms.cpu_nms import cpu_nms
+ self._nms = cpu_nms
+ elif nms_type == NMSType.GPU_NMS:
+ from nms.gpu_nms import gpu_nms
+ self._nms = gpu_nms
+ else:
+ raise ValueError('current nms type is not implemented yet')
+
+ def __call__(self, *args, **kwargs):
+ return self._nms(*args, **kwargs)