<jupyter_start><jupyter_text>Extracting embedding features from face dataIn this notebook, we aim to extract embedding features from images using face recogntion extractors.As an example, we use MOBIO dataset, and extract Arcface features from the face images:<jupyter_code>##### CHANGE YOUR DATABASE HERE
from bob.bio.face.config.database.mobio_male import database
annotation_type = database.annotation_type
fixed_positions = database.fixed_positions
memory_demanding = True
dask_client = None
from bob.bio.face.embeddings.mxnet import arcface_insightFace_lresnet100
pipeline = arcface_insightFace_lresnet100(annotation_type=annotation_type,
                                          fixed_positions=fixed_positions,
                                          memory_demanding=memory_demanding)
transformer = pipeline.transformer
from bob.pipelines import wrap


features_dir = "features" #Path to store extracted features
# Wrapping with CHECKPOINT and DASK
transformer = wrap(["checkpoint","dask"],
                   transformer,
                   features_dir=features_dir)

# Printing the setup of the transformer
print(transformer)<jupyter_output>Pipeline(steps=[('ToDaskBag', ToDaskBag()),
                ('samplewrapper-1',
                 DaskWrapper(estimator=CheckpointWrapper(estimator=SampleWrapper(estimator=FaceCrop(annotator=BobIpMTCNN(),
                                                                                                    cropped_image_size=(112,
                                                                                                                        112),
                                                                                                    cropped_positions={'leye': (55,
                                                                                                                                81),
                                                                                                                       'reye': (55,
                                                                                                                                42)}),
             [...]<jupyter_text>As an example, we consider 10 samples from this database and extract features for these samples:<jupyter_code># get 10 samples from database
samples = database.all_samples()[:10]
# Setting the DASK client
# HERE MAKE ABSOLUTELLY SURE THAT YOU DO `SETSHELL grid` 
# BEFORE STARTING THE NOTEBOOK

from dask.distributed import Client
from bob.pipelines.distributed.sge import SGEMultipleQueuesCluster

cluster = SGEMultipleQueuesCluster(min_jobs=1)
dask_client = Client(cluster)

features = transformer.transform(samples)
if dask_client is not None:
    features = features.compute(scheduler=dask_client)<jupyter_output><empty_output><jupyter_text>In the following cells, we convert the extracted features to `numpy.array` and check the size of features.<jupyter_code>import numpy as np
from bob.pipelines import SampleBatch

np_features = np.array(SampleBatch(features))
np_features
# KILL THE SGE WORKERS
dask_client.shutdown()<jupyter_output>tornado.application - ERROR - Exception in callback functools.partial(<function TCPServer._handle_connection.<locals>.<lambda> at 0x7f3470e7c8c0>, <Task finished coro=<BaseTCPListener._handle_stream() done, defined at /idiap/user/tpereira/conda/envs/bob.nightlies/lib/python3.7/site-packages/distributed/comm/tcp.py:445> exception=ValueError('invalid operation on non-started TCPListener')>)
Traceback (most recent call last):
  File "/idiap/user/tpereira/conda/envs/bob.nightlies/lib/python3.7/site-packages/tornado/ioloop.py", line 743, in _run_callback
    ret = callback()
  File "/idiap/user/tpereira/conda/envs/bob.nightlies/lib/python3.7/site-packages/tornado/tcpserver.py", line 327, in <lambda>
    gen.convert_yielded(future), lambda f: f.result()
  File "/idiap/user/tpereira/conda/envs/bob.nightlies/lib/python3.7/site-packages/distributed/comm/tcp.py", line 451, in _handle_stream
    logger.debug("Incoming connection from %r to %r", address, self.contact_address)
  File "/idiap/user/t[...]