Commit 6405fa0f authored by Tiago de Freitas Pereira's avatar Tiago de Freitas Pereira
Browse files

Updated FaceCrop and FaceDetect

parent 6b891267
Pipeline #40528 failed with stage
in 4 minutes and 9 seconds
#!/usr/bin/env python
from bob.bio.face.database import MobioBioDatabase
from bob.bio.base.pipelines.vanilla_biometrics import DatabaseConnector
from bob.extension import rc
database = DatabaseConnector(
MobioBioDatabase(
original_directory=rc["bob.db.mobio.directory"],
annotation_directory=rc["bob.db.mobio.annotation_directory"],
original_extension=".png",
protocol="mobile0-male",
)
)
......@@ -11,7 +11,7 @@ from .Base import Base
logger = logging.getLogger("bob.bio.face")
from sklearn.utils import check_array
from bob.pipelines.sample import SampleBatch
class FaceCrop(Base):
"""Crops the face according to the given annotations.
......@@ -335,16 +335,17 @@ class FaceCrop(Base):
# crop face
return self.data_type(self.crop_face(image, annot))
X = check_array(X, allow_nd=True)
if isinstance(X, SampleBatch):
if annotations is None:
return [_crop(data) for data in X]
else:
return [_crop(data, annot) for data, annot in zip(X, annotations)]
if isinstance(annotations, list):
cropped_images = []
for image, annot in zip(X, annotations):
cropped_images.append(_crop(image, annot))
return cropped_images
else:
return _crop(X, annotations)
def __getstate__(self):
d = dict(self.__dict__)
d.pop("mask_rng")
......
......@@ -10,7 +10,7 @@ import numpy
from .Base import Base
from .utils import load_cropper_only
from sklearn.utils import check_array
from bob.pipelines.sample import SampleBatch
import logging
logger = logging.getLogger("bob.bio.face")
......@@ -225,14 +225,13 @@ class FaceDetect(Base):
return self.data_type(image)
X = check_array(X, allow_nd=True)
cropped_images = []
if isinstance(X, SampleBatch):
if annotations is None:
return [_crop(data) for data in X]
else:
return [_crop(data, annot) for data, annot in zip(X, annotations)]
if isinstance(annotations, list):
cropped_images = []
for image, annot in zip(X, annotations):
cropped_images.append(_crop(image, annot))
return cropped_images
else:
return _crop(X, annotations)
......
......@@ -62,7 +62,7 @@ def run_baseline(baseline, samples_for_training=[]):
probes = get_fake_sample_set(purpose="probe")
# Regular pipeline
pipeline = load_resource(baseline, "baseline")
pipeline = load_resource(baseline, "pipeline")
scores = pipeline(samples_for_training, biometric_references, probes)
assert len(scores) == 1
assert len(scores[0]) == 1
......
......@@ -115,9 +115,7 @@ setup(
'lfw-restricted = bob.bio.face.config.database.lfw_restricted:database',
'lfw-unrestricted = bob.bio.face.config.database.lfw_unrestricted:database',
'mobio-image = bob.bio.face.config.database.mobio:mobio_image',
'mobio-male = bob.bio.face.config.database.mobio:mobio_male', # MOBIO gender-dependent training
'mobio-female = bob.bio.face.config.database.mobio:mobio_female', # MOBIO gender-dependent training
'mobio-male = bob.bio.face.config.database.mobio_male:database',
'msu-mfsd-mod-licit = bob.bio.face.config.database.msu_mfsd_mod:msu_mfsd_mod_licit',
'msu-mfsd-mod-spoof = bob.bio.face.config.database.msu_mfsd_mod:msu_mfsd_mod_spoof',
'multipie = bob.bio.face.config.database.multipie:database',
......@@ -149,7 +147,7 @@ setup(
],
#baselines
'bob.bio.baseline':[
'bob.bio.pipeline':[
'facenet_sanderberg = bob.bio.face.config.baseline.facenet_sanderberg:pipeline',
'inception_resnetv1_casiawebface = bob.bio.face.config.baseline.inception_resnetv1_casiawebface:pipeline',
'inception_resnetv2_casiawebface = bob.bio.face.config.baseline.inception_resnetv2_casiawebface:pipeline',
......
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