Commit f44427da authored by Tiago de Freitas Pereira's avatar Tiago de Freitas Pereira Committed by Amir MOHAMMADI

[nose] Fixed imports to no import tensorflow all the time

parent 839f96ca
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
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,
......
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
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
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
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
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("_")]
......@@ -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):
"""
......@@ -100,7 +103,7 @@ 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",
"http://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(
......@@ -133,7 +136,7 @@ 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",
"http://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(
......@@ -166,7 +169,7 @@ 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",
"http://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(
......@@ -200,7 +203,7 @@ 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",
"http://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(
......
......@@ -8,7 +8,9 @@ from bob.bio.base.test.utils import is_library_available
@is_library_available("tensorflow")
def test_idiap_inceptionv2_msceleb():
from bob.bio.face.embeddings import InceptionResnetv2_MsCeleb_CenterLoss_2018
from bob.bio.face.embeddings.tf2_inception_resnet import (
InceptionResnetv2_MsCeleb_CenterLoss_2018,
)
reference = bob.io.base.load(
pkg_resources.resource_filename(
......@@ -50,7 +52,9 @@ def test_idiap_inceptionv2_casia():
@is_library_available("tensorflow")
def test_idiap_inceptionv1_msceleb():
from bob.bio.face.embeddings import InceptionResnetv1_MsCeleb_CenterLoss_2018
from bob.bio.face.embeddings.tf2_inception_resnet import (
InceptionResnetv1_MsCeleb_CenterLoss_2018,
)
np.random.seed(10)
transformer = InceptionResnetv1_MsCeleb_CenterLoss_2018()
......@@ -68,7 +72,9 @@ def test_idiap_inceptionv1_msceleb():
@is_library_available("tensorflow")
def test_idiap_inceptionv1_casia():
from bob.bio.face.embeddings import InceptionResnetv1_Casia_CenterLoss_2018
from bob.bio.face.embeddings.tf2_inception_resnet import (
InceptionResnetv1_Casia_CenterLoss_2018,
)
np.random.seed(10)
transformer = InceptionResnetv1_Casia_CenterLoss_2018()
......@@ -86,7 +92,9 @@ def test_idiap_inceptionv1_casia():
@is_library_available("tensorflow")
def test_facenet_sanderberg():
from bob.bio.face.embeddings import FaceNetSanderberg_20170512_110547
from bob.bio.face.embeddings.tf2_inception_resnet import (
FaceNetSanderberg_20170512_110547,
)
np.random.seed(10)
transformer = FaceNetSanderberg_20170512_110547()
......@@ -103,7 +111,7 @@ def test_facenet_sanderberg():
@is_library_available("mxnet")
def test_arcface_insight_face():
from bob.bio.face.embeddings import ArcFaceInsightFace
from bob.bio.face.embeddings.mxnet_models import ArcFaceInsightFace
transformer = ArcFaceInsightFace()
data = np.random.rand(3, 112, 112) * 255
......
import bob.bio.base.test.utils
import bob.bio.face
# TODO: Disabling this test until we have bob.bio.base#146
"""
def test_display_annotations():
from bob.bio.face.script.display_face_annotations import main
......@@ -8,3 +10,4 @@ def test_display_annotations():
with bob.bio.base.test.utils.Quiet():
parameters = ['-d', 'dummy', '-a', '/very/unlikely/directory', '--self-test']
main(parameters)
"""
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