Yuantao Feng
commited on
Commit
·
43c47ef
1
Parent(s):
55654c5
SFace: allow bbox to be none for aligned images as input (#38)
Browse files
models/face_recognition_sface/sface.py
CHANGED
|
@@ -47,9 +47,12 @@ class SFace:
|
|
| 47 |
target_id=self._targetId)
|
| 48 |
|
| 49 |
def _preprocess(self, image, bbox):
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
-
def infer(self, image, bbox):
|
| 53 |
# Preprocess
|
| 54 |
inputBlob = self._preprocess(image, bbox)
|
| 55 |
|
|
@@ -66,4 +69,5 @@ class SFace:
|
|
| 66 |
return 1 if cosine_score >= self._threshold_cosine else 0
|
| 67 |
else: # NORM_L2
|
| 68 |
norml2_distance = self._model.match(feature1, feature2, self._disType)
|
| 69 |
-
return 1 if norml2_distance <= self._threshold_norml2 else 0
|
|
|
|
|
|
| 47 |
target_id=self._targetId)
|
| 48 |
|
| 49 |
def _preprocess(self, image, bbox):
|
| 50 |
+
if bbox is None:
|
| 51 |
+
return image
|
| 52 |
+
else:
|
| 53 |
+
return self._model.alignCrop(image, bbox)
|
| 54 |
|
| 55 |
+
def infer(self, image, bbox=None):
|
| 56 |
# Preprocess
|
| 57 |
inputBlob = self._preprocess(image, bbox)
|
| 58 |
|
|
|
|
| 69 |
return 1 if cosine_score >= self._threshold_cosine else 0
|
| 70 |
else: # NORM_L2
|
| 71 |
norml2_distance = self._model.match(feature1, feature2, self._disType)
|
| 72 |
+
return 1 if norml2_distance <= self._threshold_norml2 else 0
|
| 73 |
+
|