Skip to content
Snippets Groups Projects
Commit 281993c4 authored by Laurent COLBOIS's avatar Laurent COLBOIS
Browse files

[Database][IJBC] Updated Fast IJBC database wrapper

parent 60b60bf6
No related branches found
No related tags found
No related merge requests found
Pipeline #46199 failed
#!/usr/bin/env python #!/usr/bin/env python
from bob.bio.face.database import IJBCBioDatabase
from bob.bio.base.pipelines.vanilla_biometrics import DatabaseConnector
from bob.extension import rc
import pickle import pickle
import os import os
ijbc_directory = rc["bob.db.ijbc.directory"] ijbc_directory = "/idiap/resource/database/IJB-C/IJB/IJB-C/images"
ijbc_pkl_directory = rc["bob.db.ijbc.pkl_directory"] ijbc_pkl_directory = "/idiap/temp/tpereira/ijbc_metadata/"
from bob.pipelines.utils import hash_string
class MetadataLinker:
def __init__(self, name, protocol):
self.name = name
self.protocol = protocol
class FastIJBCDatabase: class FastIJBCDatabase:
def __init__(self, pkl_directory): def __init__(self, pkl_directory):
self.pkl_directory = pkl_directory self.pkl_directory = pkl_directory
self.annotation_type='bounding-box' self.annotation_type = "bounding-box"
self.fixed_positions=None self.fixed_positions = None
self.allow_scoring_with_all_biometric_references = False
self.hash_fn = hash_string
self.memory_demanding = True
def _assert_group(self, group): def _assert_group(self, group):
assert group=="dev", "The IJBC database only has a `dev` group. Received : {}".format(group) assert (
group == "dev"
), "The IJBC database only has a `dev` group. Received : {}".format(group)
def references(self, group="dev"): def references(self, group="dev"):
self._assert_group(group) self._assert_group(group)
return pickle.loads(open(os.path.join(self.pkl_directory, "db_references.pickle"), "rb").read()) return pickle.loads(
open(os.path.join(self.pkl_directory, "db_references.pickle"), "rb").read()
)
def probes(self, group="dev"): def probes(self, group="dev"):
self._assert_group(group) self._assert_group(group)
return pickle.loads(open(os.path.join(self.pkl_directory, "db_probes.pickle"), "rb").read()) return pickle.loads(
open(os.path.join(self.pkl_directory, "db_probes.pickle"), "rb").read()
)
def background_model_samples(self, group="dev"): def background_model_samples(self, group="dev"):
self._assert_group(group) self._assert_group(group)
return pickle.loads(open(os.path.join(self.pkl_directory, "db_background_model_samples.pickle"), "rb").read()) return pickle.loads(
open(
database = FastIJBCDatabase( os.path.join(self.pkl_directory, "db_background_model_samples.pickle"),
pkl_directory=ijbc_pkl_directory "rb",
) ).read()
)
database = FastIJBCDatabase(pkl_directory=ijbc_pkl_directory)
# database = DatabaseConnector( # database = DatabaseConnector(
# IJBCBioDatabase(original_directory=ijbc_directory, protocol="1:1"), # IJBCBioDatabase(original_directory=ijbc_directory, protocol="1:1"),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment