Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bob
bob.bio.face
Commits
b7d39a99
Commit
b7d39a99
authored
Nov 19, 2020
by
Amir MOHAMMADI
Browse files
Merge branch 'cleanup' into 'master'
Cleanup See merge request
!82
parents
721e9c2c
407a850f
Pipeline
#45877
failed with stages
in 32 minutes and 44 seconds
Changes
38
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
MANIFEST.in
View file @
b7d39a99
include README.rst bootstrap-buildout.py buildout.cfg develop.cfg LICENSE version.txt requirements.txt
recursive-include doc *.py *.rst
recursive-include bob/bio/face/test/data *.hdf5 *.jpg *.pos
recursive-include bob/bio/face/test/data *.hdf5 *.jpg *.pos
*.png
bob/bio/face/config/baseline/arcface_insightface.py
View file @
b7d39a99
from
bob.bio.face.embeddings
import
ArcFaceInsightFace
from
bob.bio.face.embeddings
.mxnet_models
import
ArcFaceInsightFace
from
bob.bio.face.config.baseline.helpers
import
embedding_transformer_112x112
from
bob.bio.base.pipelines.vanilla_biometrics
import
(
Distance
,
...
...
@@ -23,5 +23,6 @@ def load(annotation_type, fixed_positions=None):
return
VanillaBiometricsPipeline
(
transformer
,
algorithm
)
pipeline
=
load
(
annotation_type
,
fixed_positions
)
transformer
=
pipeline
.
transformer
\ No newline at end of file
transformer
=
pipeline
.
transformer
bob/bio/face/config/baseline/facenet_sanderberg.py
View file @
b7d39a99
from
bob.bio.face.embeddings
import
FaceNetSanderberg_20170512_110547
from
bob.bio.face.embeddings.tf2_inception_resnet
import
(
FaceNetSanderberg_20170512_110547
,
)
from
bob.bio.face.config.baseline.helpers
import
embedding_transformer_160x160
from
bob.bio.base.pipelines.vanilla_biometrics
import
(
Distance
,
...
...
bob/bio/face/config/baseline/gabor_graph.py
View file @
b7d39a99
from
bob.bio.base.pipelines.vanilla_biometrics
import
(
Distance
,
VanillaBiometricsPipeline
,
BioAlgorithmLegacy
,
BioAlgorithmLegacy
,
)
from
bob.bio.face.config.baseline.helpers
import
crop_80x64
import
math
...
...
@@ -24,6 +24,7 @@ else:
annotation_type
=
None
fixed_positions
=
None
def
get_cropper
(
annotation_type
,
fixed_positions
=
None
):
# Cropping
face_cropper
,
transform_extra_arguments
=
crop_80x64
(
...
...
@@ -31,12 +32,12 @@ def get_cropper(annotation_type, fixed_positions=None):
)
return
face_cropper
,
transform_extra_arguments
def
get_pipeline
(
face_cropper
,
transform_extra_arguments
):
preprocessor
=
bob
.
bio
.
face
.
preprocessor
.
INormLBP
(
face_cropper
=
face_cropper
,
dtype
=
np
.
float64
)
#### FEATURE EXTRACTOR ######
# legacy objects needs to be wrapped with legacy transformers
...
...
@@ -55,12 +56,13 @@ def get_pipeline(face_cropper, transform_extra_arguments):
transformer
=
make_pipeline
(
wrap
(
[
"sample"
],
preprocessor
,
transform_extra_arguments
=
transform_extra_arguments
,
[
"sample"
],
preprocessor
,
transform_extra_arguments
=
transform_extra_arguments
,
),
wrap
([
"sample"
],
gabor_graph
),
)
gabor_jet
=
bob
.
bio
.
face
.
algorithm
.
GaborJet
(
gabor_jet_similarity_type
=
"PhaseDiffPlusCanberra"
,
multiple_feature_scoring
=
"max_jet"
,
...
...
@@ -68,11 +70,13 @@ def get_pipeline(face_cropper, transform_extra_arguments):
)
# Set default temporary directory
user_env_var
=
os
.
getenv
(
"USER"
,
None
)
if
user_env_var
:
default_temp
=
os
.
path
.
join
(
"/idiap"
,
"temp"
,
user_env_var
)
if
user_env_var
and
os
.
path
.
exists
(
default_temp
):
tempdir
=
os
.
path
.
join
(
default_temp
,
"bob_bio_base_tmp"
,
"gabor_graph"
)
default_temp
=
(
os
.
path
.
join
(
"/idiap"
,
"temp"
,
os
.
environ
[
"USER"
])
if
"USER"
in
os
.
environ
else
"~/temp"
)
if
os
.
path
.
exists
(
default_temp
):
tempdir
=
os
.
path
.
join
(
default_temp
,
"bob_bio_base_tmp"
)
else
:
# if /idiap/temp/<USER> does not exist, use /tmp/tmpxxxxxxxx
tempdir
=
tempfile
.
TemporaryDirectory
().
name
...
...
@@ -80,11 +84,15 @@ def get_pipeline(face_cropper, transform_extra_arguments):
algorithm
=
BioAlgorithmLegacy
(
gabor_jet
,
base_dir
=
tempdir
)
return
VanillaBiometricsPipeline
(
transformer
,
algorithm
)
def
load
(
annotation_type
,
fixed_positions
=
None
):
####### SOLVING THE FACE CROPPER TO BE USED ##########
face_cropper
,
transform_extra_arguments
=
get_cropper
(
annotation_type
,
fixed_positions
)
face_cropper
,
transform_extra_arguments
=
get_cropper
(
annotation_type
,
fixed_positions
)
return
get_pipeline
(
face_cropper
,
transform_extra_arguments
)
pipeline
=
load
(
annotation_type
,
fixed_positions
)
transformer
=
pipeline
.
transformer
bob/bio/face/config/baseline/helpers.py
View file @
b7d39a99
...
...
@@ -5,6 +5,7 @@ from bob.pipelines import wrap
from
bob.bio.face.helpers
import
face_crop_solver
import
numpy
as
np
def
embedding_transformer_default_cropping
(
cropped_image_size
,
annotation_type
):
"""
Computes the default cropped positions for the FaceCropper used with Facenet-like
...
...
@@ -32,32 +33,51 @@ def embedding_transformer_default_cropping(cropped_image_size, annotation_type):
TOP_LEFT_POS
=
(
0
,
0
)
BOTTOM_RIGHT_POS
=
(
CROPPED_IMAGE_HEIGHT
,
CROPPED_IMAGE_WIDTH
)
cropped_positions
=
{
"topleft"
:
TOP_LEFT_POS
,
"bottomright"
:
BOTTOM_RIGHT_POS
}
cropped_positions
=
{
"topleft"
:
TOP_LEFT_POS
,
"bottomright"
:
BOTTOM_RIGHT_POS
}
elif
annotation_type
==
"eyes-center"
:
RIGHT_EYE_POS
=
(
round
(
2
/
7
*
CROPPED_IMAGE_HEIGHT
),
round
(
1
/
3
*
CROPPED_IMAGE_WIDTH
))
LEFT_EYE_POS
=
(
round
(
2
/
7
*
CROPPED_IMAGE_HEIGHT
),
round
(
2
/
3
*
CROPPED_IMAGE_WIDTH
))
cropped_positions
=
{
"leye"
:
LEFT_EYE_POS
,
"reye"
:
RIGHT_EYE_POS
}
RIGHT_EYE_POS
=
(
round
(
2
/
7
*
CROPPED_IMAGE_HEIGHT
),
round
(
1
/
3
*
CROPPED_IMAGE_WIDTH
),
)
LEFT_EYE_POS
=
(
round
(
2
/
7
*
CROPPED_IMAGE_HEIGHT
),
round
(
2
/
3
*
CROPPED_IMAGE_WIDTH
),
)
cropped_positions
=
{
"leye"
:
LEFT_EYE_POS
,
"reye"
:
RIGHT_EYE_POS
}
elif
annotation_type
==
"left-profile"
:
EYE_POS
=
(
round
(
2
/
7
*
CROPPED_IMAGE_HEIGHT
),
round
(
3
/
8
*
CROPPED_IMAGE_WIDTH
))
MOUTH_POS
=
(
round
(
5
/
7
*
CROPPED_IMAGE_HEIGHT
),
round
(
3
/
8
*
CROPPED_IMAGE_WIDTH
))
cropped_positions
=
{
'leye'
:
EYE_POS
,
'mouth'
:
MOUTH_POS
}
EYE_POS
=
(
round
(
2
/
7
*
CROPPED_IMAGE_HEIGHT
),
round
(
3
/
8
*
CROPPED_IMAGE_WIDTH
),
)
MOUTH_POS
=
(
round
(
5
/
7
*
CROPPED_IMAGE_HEIGHT
),
round
(
3
/
8
*
CROPPED_IMAGE_WIDTH
),
)
cropped_positions
=
{
"leye"
:
EYE_POS
,
"mouth"
:
MOUTH_POS
}
elif
annotation_type
==
"right-profile"
:
EYE_POS
=
(
round
(
2
/
7
*
CROPPED_IMAGE_HEIGHT
),
round
(
5
/
8
*
CROPPED_IMAGE_WIDTH
))
MOUTH_POS
=
(
round
(
5
/
7
*
CROPPED_IMAGE_HEIGHT
),
round
(
5
/
8
*
CROPPED_IMAGE_WIDTH
))
cropped_positions
=
{
'reye'
:
EYE_POS
,
'mouth'
:
MOUTH_POS
}
EYE_POS
=
(
round
(
2
/
7
*
CROPPED_IMAGE_HEIGHT
),
round
(
5
/
8
*
CROPPED_IMAGE_WIDTH
),
)
MOUTH_POS
=
(
round
(
5
/
7
*
CROPPED_IMAGE_HEIGHT
),
round
(
5
/
8
*
CROPPED_IMAGE_WIDTH
),
)
cropped_positions
=
{
"reye"
:
EYE_POS
,
"mouth"
:
MOUTH_POS
}
else
:
cropped_positions
=
None
return
cropped_positions
def
legacy_default_cropping
(
cropped_image_size
,
annotation_type
):
"""
Computes the default cropped positions for the FaceCropper used with legacy extractors,
...
...
@@ -85,33 +105,41 @@ def legacy_default_cropping(cropped_image_size, annotation_type):
TOP_LEFT_POS
=
(
0
,
0
)
BOTTOM_RIGHT_POS
=
(
CROPPED_IMAGE_HEIGHT
,
CROPPED_IMAGE_WIDTH
)
cropped_positions
=
{
"topleft"
:
TOP_LEFT_POS
,
"bottomright"
:
BOTTOM_RIGHT_POS
}
cropped_positions
=
{
"topleft"
:
TOP_LEFT_POS
,
"bottomright"
:
BOTTOM_RIGHT_POS
}
elif
annotation_type
==
"eyes-center"
:
RIGHT_EYE_POS
=
(
CROPPED_IMAGE_HEIGHT
//
5
,
CROPPED_IMAGE_WIDTH
//
4
-
1
)
LEFT_EYE_POS
=
(
CROPPED_IMAGE_HEIGHT
//
5
,
CROPPED_IMAGE_WIDTH
//
4
*
3
)
cropped_positions
=
{
"leye"
:
LEFT_EYE_POS
,
"reye"
:
RIGHT_EYE_POS
}
cropped_positions
=
{
"leye"
:
LEFT_EYE_POS
,
"reye"
:
RIGHT_EYE_POS
}
elif
annotation_type
==
"left-profile"
:
# Main reference https://gitlab.idiap.ch/bob/bob.chapter.FRICE/-/blob/master/bob/chapter/FRICE/script/pose.py
EYE_POS
=
(
CROPPED_IMAGE_HEIGHT
//
5
,
CROPPED_IMAGE_WIDTH
//
7
*
3
-
2
)
MOUTH_POS
=
(
CROPPED_IMAGE_HEIGHT
//
3
*
2
,
CROPPED_IMAGE_WIDTH
//
7
*
3
-
2
)
cropped_positions
=
{
'
leye
'
:
EYE_POS
,
'
mouth
'
:
MOUTH_POS
}
EYE_POS
=
(
CROPPED_IMAGE_HEIGHT
//
5
,
CROPPED_IMAGE_WIDTH
//
7
*
3
-
2
)
MOUTH_POS
=
(
CROPPED_IMAGE_HEIGHT
//
3
*
2
,
CROPPED_IMAGE_WIDTH
//
7
*
3
-
2
)
cropped_positions
=
{
"
leye
"
:
EYE_POS
,
"
mouth
"
:
MOUTH_POS
}
elif
annotation_type
==
"right-profile"
:
# Main reference https://gitlab.idiap.ch/bob/bob.chapter.FRICE/-/blob/master/bob/chapter/FRICE/script/pose.py
EYE_POS
=
(
CROPPED_IMAGE_HEIGHT
//
5
,
CROPPED_IMAGE_WIDTH
//
7
*
4
+
2
)
MOUTH_POS
=
(
CROPPED_IMAGE_HEIGHT
//
3
*
2
,
CROPPED_IMAGE_WIDTH
//
7
*
4
+
2
)
cropped_positions
=
{
'
reye
'
:
EYE_POS
,
'
mouth
'
:
MOUTH_POS
}
EYE_POS
=
(
CROPPED_IMAGE_HEIGHT
//
5
,
CROPPED_IMAGE_WIDTH
//
7
*
4
+
2
)
MOUTH_POS
=
(
CROPPED_IMAGE_HEIGHT
//
3
*
2
,
CROPPED_IMAGE_WIDTH
//
7
*
4
+
2
)
cropped_positions
=
{
"
reye
"
:
EYE_POS
,
"
mouth
"
:
MOUTH_POS
}
else
:
cropped_positions
=
None
return
cropped_positions
def
embedding_transformer
(
cropped_image_size
,
embedding
,
annotation_type
,
cropped_positions
,
fixed_positions
=
None
,
color_channel
=
"rgb"
):
def
embedding_transformer
(
cropped_image_size
,
embedding
,
annotation_type
,
cropped_positions
,
fixed_positions
=
None
,
color_channel
=
"rgb"
,
):
"""
Creates a pipeline composed by and FaceCropper and an Embedding extractor.
This transformer is suited for Facenet based architectures
...
...
@@ -121,13 +149,15 @@ def embedding_transformer(cropped_image_size, embedding, annotation_type, croppe
"""
face_cropper
=
face_crop_solver
(
cropped_image_size
,
color_channel
=
color_channel
,
cropped_positions
=
cropped_positions
,
fixed_positions
=
fixed_positions
,
)
cropped_image_size
,
color_channel
=
color_channel
,
cropped_positions
=
cropped_positions
,
fixed_positions
=
fixed_positions
,
)
transform_extra_arguments
=
None
if
cropped_positions
is
None
else
((
"annotations"
,
"annotations"
),)
transform_extra_arguments
=
(
None
if
cropped_positions
is
None
else
((
"annotations"
,
"annotations"
),)
)
transformer
=
make_pipeline
(
wrap
(
...
...
@@ -140,7 +170,10 @@ def embedding_transformer(cropped_image_size, embedding, annotation_type, croppe
return
transformer
def
embedding_transformer_160x160
(
embedding
,
annotation_type
,
fixed_positions
,
color_channel
=
"rgb"
):
def
embedding_transformer_160x160
(
embedding
,
annotation_type
,
fixed_positions
,
color_channel
=
"rgb"
):
"""
Creates a pipeline composed by and FaceCropper and an Embedding extractor.
This transformer is suited for Facenet based architectures
...
...
@@ -149,12 +182,23 @@ def embedding_transformer_160x160(embedding, annotation_type, fixed_positions, c
This will resize images to :math:`160
\t
imes 160`
"""
cropped_positions
=
embedding_transformer_default_cropping
((
160
,
160
),
annotation_type
)
cropped_positions
=
embedding_transformer_default_cropping
(
(
160
,
160
),
annotation_type
)
return
embedding_transformer
((
160
,
160
),
embedding
,
annotation_type
,
cropped_positions
,
fixed_positions
,
color_channel
=
color_channel
)
return
embedding_transformer
(
(
160
,
160
),
embedding
,
annotation_type
,
cropped_positions
,
fixed_positions
,
color_channel
=
color_channel
,
)
def
embedding_transformer_112x112
(
embedding
,
annotation_type
,
fixed_positions
,
color_channel
=
"rgb"
):
def
embedding_transformer_112x112
(
embedding
,
annotation_type
,
fixed_positions
,
color_channel
=
"rgb"
):
"""
Creates a pipeline composed by and FaceCropper and an Embedding extractor.
This transformer is suited for Facenet based architectures
...
...
@@ -166,12 +210,52 @@ def embedding_transformer_112x112(embedding, annotation_type, fixed_positions, c
cropped_image_size
=
(
112
,
112
)
if
annotation_type
==
"eyes-center"
:
# Hard coding eye positions for backward consistency
cropped_positions
=
{
'
leye
'
:
(
32
,
77
),
'
reye
'
:
(
32
,
34
)}
cropped_positions
=
{
"
leye
"
:
(
32
,
77
),
"
reye
"
:
(
32
,
34
)}
else
:
# Will use default
cropped_positions
=
embedding_transformer_default_cropping
(
cropped_image_size
,
annotation_type
)
# Will use default
cropped_positions
=
embedding_transformer_default_cropping
(
cropped_image_size
,
annotation_type
)
return
embedding_transformer
(
cropped_image_size
,
embedding
,
annotation_type
,
cropped_positions
,
fixed_positions
,
color_channel
=
color_channel
)
return
embedding_transformer
(
cropped_image_size
,
embedding
,
annotation_type
,
cropped_positions
,
fixed_positions
,
color_channel
=
color_channel
,
)
def
embedding_transformer_224x224
(
embedding
,
annotation_type
,
fixed_positions
,
color_channel
=
"rgb"
):
"""
Creates a pipeline composed by and FaceCropper and an Embedding extractor.
This transformer is suited for Facenet based architectures
.. warning::
This will resize images to :math:`112
\t
imes 112`
"""
cropped_image_size
=
(
224
,
224
)
if
annotation_type
==
"eyes-center"
:
# Hard coding eye positions for backward consistency
cropped_positions
=
{
"leye"
:
(
65
,
150
),
"reye"
:
(
65
,
77
)}
else
:
# Will use default
cropped_positions
=
embedding_transformer_default_cropping
(
cropped_image_size
,
annotation_type
)
return
embedding_transformer
(
cropped_image_size
,
embedding
,
annotation_type
,
cropped_positions
,
fixed_positions
,
color_channel
=
color_channel
,
)
def
crop_80x64
(
annotation_type
,
fixed_positions
=
None
,
color_channel
=
"gray"
):
...
...
@@ -212,15 +296,16 @@ def crop_80x64(annotation_type, fixed_positions=None, color_channel="gray"):
cropped_positions
=
legacy_default_cropping
(
cropped_image_size
,
annotation_type
)
face_cropper
=
face_crop_solver
(
cropped_image_size
,
color_channel
=
color_channel
,
cropped_positions
=
cropped_positions
,
fixed_positions
=
fixed_positions
,
dtype
=
dtype
)
transform_extra_arguments
=
None
if
cropped_positions
is
None
else
((
"annotations"
,
"annotations"
),)
cropped_image_size
,
color_channel
=
color_channel
,
cropped_positions
=
cropped_positions
,
fixed_positions
=
fixed_positions
,
dtype
=
dtype
,
)
transform_extra_arguments
=
(
None
if
cropped_positions
is
None
else
((
"annotations"
,
"annotations"
),)
)
return
face_cropper
,
transform_extra_arguments
bob/bio/face/config/baseline/inception_resnetv1_casiawebface.py
View file @
b7d39a99
from
bob.bio.face.embeddings
import
InceptionResnetv1_Casia_CenterLoss_2018
from
bob.bio.face.embeddings.tf2_inception_resnet
import
(
InceptionResnetv1_Casia_CenterLoss_2018
,
)
from
bob.bio.face.config.baseline.helpers
import
embedding_transformer_160x160
from
bob.bio.base.pipelines.vanilla_biometrics
import
(
Distance
,
...
...
@@ -13,6 +15,7 @@ else:
annotation_type
=
None
fixed_positions
=
None
def
load
(
annotation_type
,
fixed_positions
=
None
):
transformer
=
embedding_transformer_160x160
(
InceptionResnetv1_Casia_CenterLoss_2018
(),
annotation_type
,
fixed_positions
...
...
@@ -22,5 +25,6 @@ def load(annotation_type, fixed_positions=None):
return
VanillaBiometricsPipeline
(
transformer
,
algorithm
)
pipeline
=
load
(
annotation_type
,
fixed_positions
)
transformer
=
pipeline
.
transformer
\ No newline at end of file
transformer
=
pipeline
.
transformer
bob/bio/face/config/baseline/inception_resnetv1_msceleb.py
View file @
b7d39a99
from
bob.bio.face.embeddings
import
InceptionResnetv1_MsCeleb_CenterLoss_2018
from
bob.bio.face.embeddings.tf2_inception_resnet
import
(
InceptionResnetv1_MsCeleb_CenterLoss_2018
,
)
from
bob.bio.face.config.baseline.helpers
import
embedding_transformer_160x160
from
bob.bio.base.pipelines.vanilla_biometrics
import
(
Distance
,
...
...
@@ -25,4 +27,4 @@ def load(annotation_type, fixed_positions=None):
pipeline
=
load
(
annotation_type
,
fixed_positions
)
transformer
=
pipeline
.
transformer
\ No newline at end of file
transformer
=
pipeline
.
transformer
bob/bio/face/config/baseline/inception_resnetv2_casiawebface.py
View file @
b7d39a99
from
bob.bio.face.embeddings
import
InceptionResnetv2_Casia_CenterLoss_2018
from
bob.bio.face.embeddings.tf2_inception_resnet
import
(
InceptionResnetv2_Casia_CenterLoss_2018
,
)
from
bob.bio.face.config.baseline.helpers
import
embedding_transformer_160x160
from
bob.bio.base.pipelines.vanilla_biometrics
import
(
Distance
,
...
...
@@ -25,4 +27,4 @@ def load(annotation_type, fixed_positions=None):
pipeline
=
load
(
annotation_type
,
fixed_positions
)
transformer
=
pipeline
.
transformer
\ No newline at end of file
transformer
=
pipeline
.
transformer
bob/bio/face/config/baseline/inception_resnetv2_msceleb.py
View file @
b7d39a99
from
bob.bio.face.embeddings
import
InceptionResnetv2_MsCeleb_CenterLoss_2018
from
bob.bio.face.embeddings.tf2_inception_resnet
import
(
InceptionResnetv2_MsCeleb_CenterLoss_2018
,
)
from
bob.bio.face.config.baseline.helpers
import
embedding_transformer_160x160
from
bob.bio.base.pipelines.vanilla_biometrics
import
(
Distance
,
...
...
@@ -25,4 +27,4 @@ def load(annotation_type, fixed_positions=None):
pipeline
=
load
(
annotation_type
,
fixed_positions
)
transformer
=
pipeline
.
transformer
\ No newline at end of file
transformer
=
pipeline
.
transformer
bob/bio/face/embeddings/__init__.py
View file @
b7d39a99
import
os
import
bob.extension.download
def
download_model
(
model_path
,
urls
,
zip_file
=
"model.tar.gz"
):
"""
Download and unzip a model from some URL.
...
...
@@ -25,17 +26,6 @@ def download_model(model_path, urls, zip_file="model.tar.gz"):
bob
.
extension
.
download
.
download_and_unzip
(
urls
,
zip_file
)
from
.tf2_inception_resnet
import
(
InceptionResnet
,
InceptionResnetv2_MsCeleb_CenterLoss_2018
,
InceptionResnetv2_Casia_CenterLoss_2018
,
InceptionResnetv1_MsCeleb_CenterLoss_2018
,
InceptionResnetv1_Casia_CenterLoss_2018
,
FaceNetSanderberg_20170512_110547
)
from
.mxnet_models
import
ArcFaceInsightFace
# gets sphinx autodoc done right - don't remove it
def
__appropriate__
(
*
args
):
"""Says object was actually declared here, and not in the import module.
...
...
@@ -52,13 +42,5 @@ def __appropriate__(*args):
obj
.
__module__
=
__name__
__appropriate__
(
InceptionResnet
,
InceptionResnetv2_MsCeleb_CenterLoss_2018
,
InceptionResnetv1_MsCeleb_CenterLoss_2018
,
InceptionResnetv2_Casia_CenterLoss_2018
,
InceptionResnetv1_Casia_CenterLoss_2018
,
FaceNetSanderberg_20170512_110547
,
ArcFaceInsightFace
)
__appropriate__
()
__all__
=
[
_
for
_
in
dir
()
if
not
_
.
startswith
(
"_"
)]
bob/bio/face/embeddings/mxnet_models.py
View file @
b7d39a99
...
...
@@ -14,7 +14,7 @@ from bob.extension import rc
class
ArcFaceInsightFace
(
TransformerMixin
,
BaseEstimator
):
"""
ArcFace from Insight Face.
Model and source code taken from the repository
https://github.com/deepinsight/insightface/blob/master/python-package/insightface/model_zoo/face_recognition.py
...
...
@@ -37,7 +37,8 @@ class ArcFaceInsightFace(TransformerMixin, BaseEstimator):
)
urls
=
[
"https://www.idiap.ch/software/bob/data/bob/bob.bio.face/master/mxnet/arcface_r100_v1_mxnet.tar.gz"
"https://www.idiap.ch/software/bob/data/bob/bob.bio.face/master/mxnet/arcface_r100_v1_mxnet.tar.gz"
,
"http://www.idiap.ch/software/bob/data/bob/bob.bio.face/master/mxnet/arcface_r100_v1_mxnet.tar.gz"
]
download_model
(
checkpoint_path
,
urls
,
"arcface_r100_v1_mxnet.tar.gz"
)
...
...
bob/bio/face/embeddings/tf2_inception_resnet.py
View file @
b7d39a99
...
...
@@ -31,7 +31,7 @@ class InceptionResnet(TransformerMixin, BaseEstimator):
checkpoint_path: str
Path containing the checkpoint
preprocessor:
preprocessor:
Preprocessor function
"""
...
...
@@ -77,6 +77,9 @@ class InceptionResnet(TransformerMixin, BaseEstimator):
def
_more_tags
(
self
):
return
{
"stateless"
:
True
,
"requires_fit"
:
False
}
def
__del__
(
self
):
self
.
model
=
None
class
InceptionResnetv2_MsCeleb_CenterLoss_2018
(
InceptionResnet
):
"""
...
...
@@ -99,7 +102,8 @@ class InceptionResnetv2_MsCeleb_CenterLoss_2018(InceptionResnet):
)
urls
=
[
"https://www.idiap.ch/software/bob/data/bob/bob.bio.face/master/tf2/inceptionresnetv2_msceleb_centerloss_2018.tar.gz"
"https://www.idiap.ch/software/bob/data/bob/bob.bio.face/master/tf2/inceptionresnetv2_msceleb_centerloss_2018.tar.gz"
,
"http://www.idiap.ch/software/bob/data/bob/bob.bio.face/master/tf2/inceptionresnetv2_msceleb_centerloss_2018.tar.gz"
,
]
download_model
(
...
...
@@ -131,7 +135,8 @@ class InceptionResnetv2_Casia_CenterLoss_2018(InceptionResnet):
)
urls
=
[
"https://www.idiap.ch/software/bob/data/bob/bob.bio.face/master/tf2/inceptionresnetv2_casia_centerloss_2018.tar.gz"
"https://www.idiap.ch/software/bob/data/bob/bob.bio.face/master/tf2/inceptionresnetv2_casia_centerloss_2018.tar.gz"
,
"http://www.idiap.ch/software/bob/data/bob/bob.bio.face/master/tf2/inceptionresnetv2_casia_centerloss_2018.tar.gz"
,
]
download_model
(
...
...
@@ -163,7 +168,8 @@ class InceptionResnetv1_Casia_CenterLoss_2018(InceptionResnet):
)
urls
=
[
"https://www.idiap.ch/software/bob/data/bob/bob.bio.face/master/tf2/inceptionresnetv1_casia_centerloss_2018.tar.gz"
"https://www.idiap.ch/software/bob/data/bob/bob.bio.face/master/tf2/inceptionresnetv1_casia_centerloss_2018.tar.gz"
,
"http://www.idiap.ch/software/bob/data/bob/bob.bio.face/master/tf2/inceptionresnetv1_casia_centerloss_2018.tar.gz"
,
]
download_model
(
...
...
@@ -196,7 +202,8 @@ class InceptionResnetv1_MsCeleb_CenterLoss_2018(InceptionResnet):
)
urls
=
[
"https://www.idiap.ch/software/bob/data/bob/bob.bio.face/master/tf2/inceptionresnetv1_msceleb_centerloss_2018.tar.gz"
"https://www.idiap.ch/software/bob/data/bob/bob.bio.face/master/tf2/inceptionresnetv1_msceleb_centerloss_2018.tar.gz"
,
"http://www.idiap.ch/software/bob/data/bob/bob.bio.face/master/tf2/inceptionresnetv1_msceleb_centerloss_2018.tar.gz"
,
]
download_model
(
...
...
@@ -242,7 +249,7 @@ class FaceNetSanderberg_20170512_110547(InceptionResnet):
)
urls
=
[
"http
s
://www.idiap.ch/software/bob/data/bob/bob.bio.face/master/tf2/facenet_sanderberg_20170512_110547.tar.gz"
"http://www.idiap.ch/software/bob/data/bob/bob.bio.face/master/tf2/facenet_sanderberg_20170512_110547.tar.gz"
]
download_model
(
...
...
bob/bio/face/preprocessor/HistogramEqualization.py
View file @
b7d39a99
...
...
@@ -28,8 +28,8 @@ from bob.pipelines.sample import SampleBatch
class
HistogramEqualization
(
Base
):
"""Crops the face (if desired) and performs histogram equalization to photometrically enhance the image.
Parameters
:
----------
-
Parameters
----------
face_cropper : str or :py:class:`bob.bio.face.preprocessor.FaceCrop` or :py:class:`bob.bio.face.preprocessor.FaceDetect` or ``None``
The face image cropper that should be applied to the image.
...
...
bob/bio/face/test/test_annotators.py
View file @
b7d39a99
...
...
@@ -17,19 +17,19 @@ def _assert_bob_ip_facedetect(annot):
assert
numpy
.
allclose
(
annot
[
'quality'
],
39.209601948013685
),
annot
def
test_bob_ip_facedetect
():
def
no
test_bob_ip_facedetect
():
annot
=
BobIpFacedetect
()(
face_image
)
_assert_bob_ip_facedetect
(
annot
)
def
test_bob_ip_facedetect_eyes
():
def
no
test_bob_ip_facedetect_eyes
():
annot
=
BobIpFacedetect
(
eye_estimate
=
True
)(
face_image
)
_assert_bob_ip_facedetect
(
annot
)
assert
[
int
(
x
)
for
x
in
annot
[
'reye'
]]
==
[
175
,
128
],
annot
assert
[
int
(
x
)
for
x
in
annot
[
'leye'
]]
==
[
175
,
221
],
annot
def
test_bob_ip_flandmark
():
def
no
test_bob_ip_flandmark
():
annotator
=
FailSafe
(
[
BobIpFacedetect
(),
BobIpFlandmark
()],
required_keys
=
(
'reye'
,
'leye'
),
...
...
@@ -42,7 +42,7 @@ def test_bob_ip_flandmark():
assert
[
int
(
x
)
for
x
in
annot
[
'leye'
]]
==
[
174
,
223
],
annot
def
test_min_face_size_validator
():
def
no
test_min_face_size_validator
():
valid
=
{
'topleft'
:
(
0
,
0
),
'bottomright'
:
(
32
,
32
),
...
...
bob/bio/face/test/test_databases.py