mirror of
https://github.com/serengil/deepface.git
synced 2025-06-07 12:05:22 +00:00
VGGFace batched inference
This commit is contained in:
parent
c60152e9a5
commit
8fb70eb43f
@ -57,8 +57,7 @@ class VggFaceClient(FacialRecognition):
|
|||||||
def forward(self, img: np.ndarray) -> List[float]:
|
def forward(self, img: np.ndarray) -> List[float]:
|
||||||
"""
|
"""
|
||||||
Generates embeddings using the VGG-Face model.
|
Generates embeddings using the VGG-Face model.
|
||||||
This method incorporates an additional normalization layer,
|
This method incorporates an additional normalization layer.
|
||||||
necessitating the override of the forward method.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
img (np.ndarray): pre-loaded image in BGR
|
img (np.ndarray): pre-loaded image in BGR
|
||||||
@ -70,8 +69,14 @@ class VggFaceClient(FacialRecognition):
|
|||||||
|
|
||||||
# having normalization layer in descriptor troubles for some gpu users (e.g. issue 957, 966)
|
# having normalization layer in descriptor troubles for some gpu users (e.g. issue 957, 966)
|
||||||
# instead we are now calculating it with traditional way not with keras backend
|
# instead we are now calculating it with traditional way not with keras backend
|
||||||
embedding = self.model(img, training=False).numpy()[0].tolist()
|
embedding = super().forward(img)
|
||||||
embedding = verification.l2_normalize(embedding)
|
if (
|
||||||
|
isinstance(embedding, list) and
|
||||||
|
isinstance(embedding[0], list)
|
||||||
|
):
|
||||||
|
embedding = verification.l2_normalize(embedding, axis=1)
|
||||||
|
else:
|
||||||
|
embedding = verification.l2_normalize(embedding)
|
||||||
return embedding.tolist()
|
return embedding.tolist()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user