Python API for bob.ip.tensorflow_extractor

Classes

bob.ip.tensorflow_extractor.Extractor(…[, …]) Feature extractor using tensorflow
bob.ip.tensorflow_extractor.FaceNet([…]) Wrapper for the free FaceNet variant:

Detailed API

bob.ip.tensorflow_extractor.scratch_network(inputs, end_point='fc1', reuse=False)[source]
bob.ip.tensorflow_extractor.download_file(url, out_file)[source]

Downloads a file from a given url

Parameters:
  • url (str) – The url to download form.
  • out_file (str) – Where to save the file.
bob.ip.tensorflow_extractor.get_config()[source]

Returns a string containing the configuration information.

class bob.ip.tensorflow_extractor.DrGanMSUExtractor(model_path='/local/builds/bob/bob.ip.tensorflow_extractor/miniconda/conda-bld/bob.ip.tensorflow_extractor_1524835265658/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeho/lib/python3.6/site-packages/bob/ip/tensorflow_extractor/data/DR_GAN_model', image_size=[96, 96, 3])

Bases: object

Wrapper for the free DRGan by L.Tran @ MSU:

To use this class as a bob.bio.base extractor:

from bob.bio.base.extractor import Extractor
class DrGanMSUExtractorBioBase(DrGanMSUExtractor, Extractor):
    pass
extractor = DrGanMSUExtractorBioBase()

Parameters:

model_file:
Path to the model
image_size: list
The input image size (WxHxC)
__call__(image) → feature[source]

Extract features

Parameters:

image : 3D numpy.ndarray (floats)
The image to extract the features from.

Returns:

feature : 2D numpy.ndarray (floats)
The extracted features
static download_model()[source]

Download and extract the DrGanMSU files in bob/ip/tensorflow_extractor

static get_modelpath()[source]
static get_rcvariable()[source]
class bob.ip.tensorflow_extractor.Extractor(checkpoint_filename, input_tensor, graph, debug=False)

Bases: object

Feature extractor using tensorflow

__call__(data)[source]

Forward the data with the loaded neural network

Parameters:image (numpy.array) – Input Data
Returns:The features.
Return type:numpy.array
__init__(checkpoint_filename, input_tensor, graph, debug=False)[source]

Loads the tensorflow model

Parameters:
  • checkpoint_filename (str) – Path of your checkpoint. If the .meta file is providede the last checkpoint will be loaded.
  • model – input_tensor: tf.Tensor used as a data entrypoint. It can be a tf.placeholder, the result of tf.train.string_input_producer, etc
  • graph – A tf.Tensor containing the operations to be executed
class bob.ip.tensorflow_extractor.FaceNet(model_path='/local/builds/bob/bob.ip.tensorflow_extractor/miniconda/conda-bld/bob.ip.tensorflow_extractor_1524835265658/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeho/lib/python3.6/site-packages/bob/ip/tensorflow_extractor/data/FaceNet/20170512-110547', image_size=160, **kwargs)

Bases: object

Wrapper for the free FaceNet variant: https://github.com/davidsandberg/facenet

To use this class as a bob.bio.base extractor:

from bob.bio.base.extractor import Extractor
class FaceNetExtractor(FaceNet, Extractor):
    pass
extractor = FaceNetExtractor()

And for a preprocessor you can use:

from bob.bio.face.preprocessor import FaceCrop
# This is the size of the image that this model expects
CROPPED_IMAGE_HEIGHT = 160
CROPPED_IMAGE_WIDTH = 160
# eye positions for frontal images
RIGHT_EYE_POS = (46, 53)
LEFT_EYE_POS = (46, 107)
# Crops the face using eye annotations
preprocessor = FaceCrop(
    cropped_image_size=(CROPPED_IMAGE_HEIGHT, CROPPED_IMAGE_WIDTH),
    cropped_positions={'leye': LEFT_EYE_POS, 'reye': RIGHT_EYE_POS},
    color_channel='rgb'
)
static download_model()[source]

Download and extract the FaceNet files in bob/ip/tensorflow_extractor

static get_modelpath()[source]
static get_rcvariable()[source]
load_model()[source]