Skip to content
Snippets Groups Projects
Commit a8cd5c4c authored by Hatef OTROSHI's avatar Hatef OTROSHI
Browse files

+ notebook: Extract_ArcFace_from_MOBIO

parent 7e057fa5
No related branches found
No related tags found
1 merge request!120Adding a tutorial notebook (Extract ArcFace from MOBIO)
Pipeline #50829 passed
%% Cell type:markdown id:54da1cf9 tags:
# Extracting embedding features from face data
In 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:
%% Cell type:code id:3e7ff891 tags:
``` python
##### CHANGE YOUR DATABASE HERE
from bob.bio.face.config.database.mobio_male import database
annotation_type = database.annotation_type
fixed_positions = database.fixed_positions
```
%% Cell type:code id:a5fba83d tags:
``` python
from bob.bio.face.config.baseline.arcface_insightface import load
pipeline = load(annotation_type, fixed_positions) #pre-process and feature extraction pipeline
transformer = pipeline.transformer
```
%% Cell type:code id:4d610eb0 tags:
``` python
import bob.pipelines
features_dir = "features" #Path to store extracted features
transformer = bob.pipelines.CheckpointWrapper(transformer, features_dir=features_dir)
# Printing the setup of the transformer
print(transformer)
```
%% Output
CheckpointWrapper(estimator=Pipeline(steps=[('samplewrapper-1',
SampleWrapper(estimator=FaceCrop(cropped_image_size=(112,
112),
cropped_positions={'leye': (55,
81),
'reye': (55,
42)}),
fit_extra_arguments=(),
transform_extra_arguments=(('annotations',
'annotations'),))),
('samplewrapper-2',
SampleWrapper(estimator=ArcFaceInsightFace(),
fit_extra_arguments=(),
transform_extra_arguments=()))]),
features_dir='features',
load_func=<function load at 0x7f5c5424d4c0>,
save_func=<function save at 0x7f5c5424d670>)
%% Cell type:markdown id:7ea60d56 tags:
As an example, we consider 10 samples from this database and extract features for these samples:
%% Cell type:code id:bb65175a tags:
``` python
# get 10 samples from database
samples = database.all_samples()[:10]
```
%% Cell type:code id:aee7754f tags:
``` python
features = transformer.transform(samples)
```
%% Cell type:markdown id:bb27ce2a tags:
In the following cells, we convert the extracted features to `numpy.array` and check the size of features.
%% Cell type:code id:a0a9efe1 tags:
``` python
import numpy as np
from bob.pipelines import SampleBatch
np_features = np.array(SampleBatch(features))
```
%% Cell type:code id:92971828 tags:
``` python
np_features.shape
```
%% Output
(10, 512)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment