Skip to content
Snippets Groups Projects
Commit 68cf5d5b authored by Tiago de Freitas Pereira's avatar Tiago de Freitas Pereira
Browse files

Integrated CBSR_NIR_VIS_2 database

parent 48d44c4c
No related branches found
No related tags found
1 merge request!111Integrating HTFace databases
Pipeline #49551 failed
from bob.bio.face.database import CBSRNirVis2Database
# In case protocol is comming from chain loading
# https://www.idiap.ch/software/bob/docs/bob/bob.extension/stable/py_api.html#bob.extension.config.load
if "protocol" not in locals():
protocol = "view2_1"
database = CBSRNirVis2Database(protocol=protocol)
......@@ -16,6 +16,7 @@ from .meds import MEDSDatabase
from .morph import MorphDatabase
from .casia_africa import CasiaAfricaDatabase
from .pola_thermal import PolaThermalDatabase
from .cbsr_nir_vis_2 import CBSRNirVis2Database
# gets sphinx autodoc done right - don't remove it
......@@ -51,5 +52,6 @@ __appropriate__(
MorphDatabase,
CasiaAfricaDatabase,
PolaThermalDatabase,
CBSRNirVis2Database,
)
__all__ = [_ for _ in dir() if not _.startswith("_")]
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
# Tiago de Freitas Pereira <tiago.pereira@idiap.ch>
"""
CBSRNirVis2Database database: database implementation
"""
from bob.bio.base.database import CSVDataset
from bob.bio.base.database import CSVToSampleLoaderBiometrics
from bob.bio.face.database.sample_loaders import EyesAnnotations
from bob.extension import rc
from bob.extension.download import get_file
import bob.io.base
from sklearn.pipeline import make_pipeline
import os
class CBSRNirVis2Database(CSVDataset):
"""
This package contains the access API and descriptions for the `CASIA NIR-VIS 2.0 Database <http://www.cbsr.ia.ac.cn/english/NIR-VIS-2.0-Database.html>`.
The actual raw data for the database should be downloaded from the original URL.
This package only contains the Bob accessor methods to use the DB directly from python, with the original protocol of the database.
CASIA NIR-VIS 2.0 database offers pairs of mugshot images and their correspondent NIR photos.
The images of this database were collected in four recording sessions: 2007 spring, 2009 summer, 2009 fall and 2010 summer,
in which the first session is identical to the CASIA HFB database. It consists of 725 subjects in total.
There are [1-22] VIS and [5-50] NIR face images per subject. The eyes positions are also distributed with the images.
.. code-block:: latex
@inproceedings{li2013casia,
title={The casia nir-vis 2.0 face database},
author={Li, Stan Z and Yi, Dong and Lei, Zhen and Liao, Shengcai},
booktitle={Computer Vision and Pattern Recognition Workshops (CVPRW), 2013 IEEE Conference on},
pages={348--353},
year={2013},
organization={IEEE}
}
.. warning::
Use the command below to set the path of the real data::
$ bob config set bob.db.cbsr-nir-vis-2.directory [PATH-TO-CBSR-DATA]
Parameters
----------
protocol: str
One of the database protocols.
"""
def __init__(self, protocol):
# Downloading model if not exists
urls = CBSRNirVis2Database.urls()
filename = get_file(
"cbsr_nir_vis_2.tar.gz", urls, file_hash="1fc247626f88d6f36a2675516eb745a5",
)
self.annotation_type = "eyes-center"
self.fixed_positions = None
directory = (
rc["bob.db.cbsr-nir-vis-2.directory"]
if rc["bob.db.cbsr-nir-vis-2.directory"]
else ""
)
def load(filename):
extensions = [".jpg", ".bmp"]
for e in extensions:
f = os.path.splitext(filename)[0]
new_filename = f + e
if os.path.exists(new_filename):
return bob.io.base.load(new_filename)
else:
raise ValueError("File `{0}` not found".format(str(new_filename)))
super().__init__(
filename,
protocol,
csv_to_sample_loader=make_pipeline(
CSVToSampleLoaderBiometrics(
data_loader=load,
dataset_original_directory=directory,
extension=".jpg",
),
EyesAnnotations(),
),
)
@staticmethod
def protocols():
# TODO: Until we have (if we have) a function that dumps the protocols, let's use this one.
return [
"view2_1",
"view2_2",
"view2_3",
"view2_4",
"view2_5",
"view2_6",
"view2_7",
"view2_8",
"view2_9",
"view2_10",
]
@staticmethod
def urls():
return [
"https://www.idiap.ch/software/bob/databases/latest/cbsr_nir_vis_2.tar.gz",
"http://www.idiap.ch/software/bob/databases/latest/cbsr_nir_vis_2.tar.gz",
]
......@@ -406,10 +406,20 @@ def test_casia_africa():
assert len(database.probes()) == 2426
def test_casia_polathermal():
def test_polathermal():
from bob.bio.face.database import PolaThermalDatabase
database = PolaThermalDatabase("VIS-thermal-overall-split1")
assert len(database.references()) == 35
assert len(database.probes()) == 1680
def test_cbsr_nir_vis_2():
from bob.bio.face.database import CBSRNirVis2Database
database = CBSRNirVis2Database("view2_1")
assert len(database.references()) == 358
assert len(database.probes()) == 6123
......@@ -24,6 +24,7 @@ Databases
bob.bio.face.database.MEDSDatabase
bob.bio.face.database.MorphDatabase
bob.bio.face.database.PolaThermalDatabase
bob.bio.face.database.CBSRNirVis2Database
Face Image Annotators
......
......@@ -114,6 +114,7 @@ setup(
"morph = bob.bio.face.config.database.morph:database",
"casia-africa = bob.bio.face.config.database.casia_africa:database",
"pola-thermal = bob.bio.face.config.database.pola_thermal:database",
"cbsr-nir-vis-2 = bob.bio.face.config.database.cbsr_nir_vis_2:database",
],
"bob.bio.annotator": [
"facedetect = bob.bio.face.config.annotator.facedetect:annotator",
......@@ -181,6 +182,7 @@ setup(
"morph = bob.bio.face.config.database.morph",
"casia-africa = bob.bio.face.config.database.casia_africa",
"pola-thermal = bob.bio.face.config.database.pola_thermal",
"cbsr-nir-vis-2 = bob.bio.face.config.database.cbsr_nir_vis_2",
"resnet50-msceleb-arcface-2021 = bob.bio.face.config.baseline.resnet50_msceleb_arcface_2021",
"resnet50-vgg2-arcface-2021 = bob.bio.face.config.baseline.resnet50_vgg2_arcface_2021",
"mobilenetv2-msceleb-arcface-2021 = bob.bio.face.config.baseline.mobilenetv2_msceleb_arcface_2021",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment