Commit c566524f authored by Tiago de Freitas Pereira's avatar Tiago de Freitas Pereira

Merge branch 'test-facenet' into 'master'

Test Facenet

See merge request !84
parents b385d51c 6cca593f
Pipeline #46327 passed with stages
in 8 minutes and 49 seconds
...@@ -14,7 +14,7 @@ def test_idiap_inceptionv2_msceleb(): ...@@ -14,7 +14,7 @@ def test_idiap_inceptionv2_msceleb():
reference = bob.io.base.load( reference = bob.io.base.load(
pkg_resources.resource_filename( pkg_resources.resource_filename(
"bob.bio.face.test", "data/inception_resnet_v2_rgb.hdf5" "bob.bio.face.test", "data/inception_resnet_v2_msceleb_rgb.hdf5"
) )
) )
np.random.seed(10) np.random.seed(10)
...@@ -61,11 +61,18 @@ def test_idiap_inceptionv2_msceleb_memory_demanding(): ...@@ -61,11 +61,18 @@ def test_idiap_inceptionv2_msceleb_memory_demanding():
@is_library_available("tensorflow") @is_library_available("tensorflow")
def test_idiap_inceptionv2_casia(): def test_idiap_inceptionv2_casia():
from bob.bio.face.embeddings import InceptionResnetv2_Casia_CenterLoss_2018 from bob.bio.face.embeddings.tf2_inception_resnet import (
InceptionResnetv2_Casia_CenterLoss_2018,
)
reference = bob.io.base.load(
pkg_resources.resource_filename(
"bob.bio.face.test", "data/inception_resnet_v2_casia_rgb.hdf5"
)
)
np.random.seed(10) np.random.seed(10)
transformer = InceptionResnetv2_Casia_CenterLoss_2018() transformer = InceptionResnetv2_Casia_CenterLoss_2018()
data = np.random.rand(3, 160, 160).astype("uint8") data = (np.random.rand(3, 160, 160) * 255).astype("uint8")
output = transformer.transform([data])[0] output = transformer.transform([data])[0]
assert output.size == 128, output.shape assert output.size == 128, output.shape
...@@ -74,6 +81,7 @@ def test_idiap_inceptionv2_casia(): ...@@ -74,6 +81,7 @@ def test_idiap_inceptionv2_casia():
transformer_sample = wrap(["sample"], transformer) transformer_sample = wrap(["sample"], transformer)
output = [s.data for s in transformer_sample.transform([sample])][0] output = [s.data for s in transformer_sample.transform([sample])][0]
np.testing.assert_allclose(output, reference.flatten(), rtol=1e-5, atol=1e-4)
assert output.size == 128, output.shape assert output.size == 128, output.shape
...@@ -83,9 +91,14 @@ def test_idiap_inceptionv1_msceleb(): ...@@ -83,9 +91,14 @@ def test_idiap_inceptionv1_msceleb():
InceptionResnetv1_MsCeleb_CenterLoss_2018, InceptionResnetv1_MsCeleb_CenterLoss_2018,
) )
reference = bob.io.base.load(
pkg_resources.resource_filename(
"bob.bio.face.test", "data/inception_resnet_v1_msceleb_rgb.hdf5"
)
)
np.random.seed(10) np.random.seed(10)
transformer = InceptionResnetv1_MsCeleb_CenterLoss_2018() transformer = InceptionResnetv1_MsCeleb_CenterLoss_2018()
data = np.random.rand(3, 160, 160).astype("uint8") data = (np.random.rand(3, 160, 160) * 255).astype("uint8")
output = transformer.transform([data])[0] output = transformer.transform([data])[0]
assert output.size == 128, output.shape assert output.size == 128, output.shape
...@@ -94,6 +107,7 @@ def test_idiap_inceptionv1_msceleb(): ...@@ -94,6 +107,7 @@ def test_idiap_inceptionv1_msceleb():
transformer_sample = wrap(["sample"], transformer) transformer_sample = wrap(["sample"], transformer)
output = [s.data for s in transformer_sample.transform([sample])][0] output = [s.data for s in transformer_sample.transform([sample])][0]
np.testing.assert_allclose(output, reference.flatten(), rtol=1e-5, atol=1e-4)
assert output.size == 128, output.shape assert output.size == 128, output.shape
...@@ -103,9 +117,14 @@ def test_idiap_inceptionv1_casia(): ...@@ -103,9 +117,14 @@ def test_idiap_inceptionv1_casia():
InceptionResnetv1_Casia_CenterLoss_2018, InceptionResnetv1_Casia_CenterLoss_2018,
) )
reference = bob.io.base.load(
pkg_resources.resource_filename(
"bob.bio.face.test", "data/inception_resnet_v1_casia_rgb.hdf5"
)
)
np.random.seed(10) np.random.seed(10)
transformer = InceptionResnetv1_Casia_CenterLoss_2018() transformer = InceptionResnetv1_Casia_CenterLoss_2018()
data = np.random.rand(3, 160, 160).astype("uint8") data = (np.random.rand(3, 160, 160) * 255).astype("uint8")
output = transformer.transform([data])[0] output = transformer.transform([data])[0]
assert output.size == 128, output.shape assert output.size == 128, output.shape
...@@ -114,6 +133,7 @@ def test_idiap_inceptionv1_casia(): ...@@ -114,6 +133,7 @@ def test_idiap_inceptionv1_casia():
transformer_sample = wrap(["sample"], transformer) transformer_sample = wrap(["sample"], transformer)
output = [s.data for s in transformer_sample.transform([sample])][0] output = [s.data for s in transformer_sample.transform([sample])][0]
np.testing.assert_allclose(output, reference.flatten(), rtol=1e-5, atol=1e-4)
assert output.size == 128, output.shape assert output.size == 128, output.shape
...@@ -123,9 +143,14 @@ def test_facenet_sanderberg(): ...@@ -123,9 +143,14 @@ def test_facenet_sanderberg():
FaceNetSanderberg_20170512_110547, FaceNetSanderberg_20170512_110547,
) )
reference = bob.io.base.load(
pkg_resources.resource_filename(
"bob.bio.face.test", "data/facenet_sandberg_20170512-110547.hdf5"
)
)
np.random.seed(10) np.random.seed(10)
transformer = FaceNetSanderberg_20170512_110547() transformer = FaceNetSanderberg_20170512_110547()
data = np.random.rand(3, 160, 160).astype("uint8") data = (np.random.rand(3, 160, 160) * 255).astype("uint8")
output = transformer.transform([data])[0] output = transformer.transform([data])[0]
assert output.size == 128, output.shape assert output.size == 128, output.shape
...@@ -133,6 +158,8 @@ def test_facenet_sanderberg(): ...@@ -133,6 +158,8 @@ def test_facenet_sanderberg():
sample = Sample(data) sample = Sample(data)
transformer_sample = wrap(["sample"], transformer) transformer_sample = wrap(["sample"], transformer)
output = [s.data for s in transformer_sample.transform([sample])][0] output = [s.data for s in transformer_sample.transform([sample])][0]
np.testing.assert_allclose(output, reference.flatten(), rtol=1e-5, atol=1e-4)
assert output.size == 128, output.shape assert output.size == 128, output.shape
......
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