Commit 46540688 authored by Tiago de Freitas Pereira's avatar Tiago de Freitas Pereira

Merge branch 'p1' into 'master'

[facenet] Allow for layer name to be provided as well

See merge request !10
parents 1e9584f3 a351280b
Pipeline #22868 passed with stages
in 12 minutes and 51 seconds
......@@ -73,15 +73,18 @@ class FaceNet(object):
"""
def __init__(self,
def __init__(
self,
model_path=rc["bob.ip.tensorflow_extractor.facenet_modelpath"],
image_size=160,
layer_name='embeddings:0',
**kwargs):
super(FaceNet, self).__init__()
self.model_path = model_path
self.image_size = image_size
self.session = None
self.embeddings = None
self.layer_name = layer_name
def _check_feature(self, img):
img = numpy.ascontiguousarray(img)
......@@ -131,7 +134,7 @@ class FaceNet(object):
os.path.join(model_exp, ckpt_file))
# Get input and output tensors
self.images_placeholder = self.graph.get_tensor_by_name("input:0")
self.embeddings = self.graph.get_tensor_by_name("embeddings:0")
self.embeddings = self.graph.get_tensor_by_name(self.layer_name)
self.phase_train_placeholder = self.graph.get_tensor_by_name(
"phase_train:0")
logger.info("Successfully loaded the model.")
......@@ -156,7 +159,7 @@ class FaceNet(object):
def get_rcvariable():
"""
Variable name used in the Bob Global Configuration System
https://www.idiap.ch/software/bob/docs/bob/bob.extension/stable/rc.html#global-configuration-system
https://www.idiap.ch/software/bob/docs/bob/bob.extension/stable/rc.html
"""
return "bob.ip.tensorflow_extractor.facenet_modelpath"
......@@ -166,7 +169,8 @@ class FaceNet(object):
Get default model path.
First we try the to search this path via Global Configuration System.
If we can not find it, we set the path in the directory `<project>/data`
If we can not find it, we set the path in the directory
`<project>/data`
"""
# Priority to the RC path
......@@ -174,8 +178,7 @@ class FaceNet(object):
if model_path is None:
import pkg_resources
model_path = pkg_resources.resource_filename(__name__,
'data/FaceNet/20170512-110547')
model_path = pkg_resources.resource_filename(
__name__, 'data/FaceNet/20170512-110547')
return model_path
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment