Commit 48d44c4c authored by Tiago de Freitas Pereira's avatar Tiago de Freitas Pereira
Browse files

Integrated PolaThermal dataset

parent e854e786
Pipeline #49550 failed with stage
in 6 minutes and 14 seconds
from bob.bio.face.database import PolaThermalDatabase
# 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 = "VIS-thermal-overall-split1""
database = PolaThermalDatabase(protocol=protocol)
......@@ -9,12 +9,13 @@ from .gbu import GBUBioDatabase
from .arface import ARFaceBioDatabase
from .lfw import LFWBioDatabase
from .multipie import MultipieDatabase
from .ijbc import IJBCBioDatabase
from .ijbc import IJBCDatabase, IJBCBioDatabase
from .replaymobile import ReplayMobileBioDatabase
from .fargo import FargoBioDatabase
from .meds import MEDSDatabase
from .morph import MorphDatabase
from .casia_africa import CasiaAfricaDatabase
from .pola_thermal import PolaThermalDatabase
# gets sphinx autodoc done right - don't remove it
......@@ -43,11 +44,12 @@ __appropriate__(
ARFaceBioDatabase,
LFWBioDatabase,
MultipieDatabase,
IJBCBioDatabase,
IJBCDatabase,
ReplayMobileBioDatabase,
FargoBioDatabase,
MEDSDatabase,
MorphDatabase,
CasiaAfricaDatabase,
PolaThermalDatabase,
)
__all__ = [_ for _ in dir() if not _.startswith("_")]
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
# Tiago de Freitas Pereira <tiago.pereira@idiap.ch>
"""
PolaThermal 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
class PolaThermalDatabase(CSVDataset):
"""
Collected by USA Army, the Polarimetric Thermal Database contains basically VIS and Thermal face images.
Follow bellow the description of the imager used to capture this device.
The **polarimetric** LWIR imager used to collect this database was developed by Polaris Sensor Technologies.
The imager is based on the division-of-time spinning achromatic retarder (SAR) design that uses a spinning phase-retarder mounted in series with a linear wire-grid polarizer.
This system, also referred to as a polarimeter, has a spectral response range of 7.5-11.1, using a Stirling-cooled mercury telluride focal plane array with pixel array dimensions of 640×480.
A Fourier modulation technique is applied to the pixel readout, followed by a series expansion and inversion to compute the Stokes images.
Data were recorded at 60 frames per second (fps) for this database, using a wide FOV of 10.6°×7.9°. Prior to collecting data for each subject, a two-point non-uniformity correction (NUC) was performed using a Mikron blackbody at 20°C and 40°C, which covers the range of typical facial temperatures (30°C-35°C).
Data was recorded on a laptop using custom vendor software.
An array of four Basler Scout series cameras was used to collect the corresponding **visible spectrum imagery**.
Two of the cameras are monochrome (model # scA640-70gm), with pixel array dimensions of 659×494.
The other two cameras are color (model # scA640-70gc), with pixel array dimensions of 658×494.
The dataset contains 60 subjects in total.
For **VIS** images (considered only the 87 pixels interpupil distance) there are 4 samples per subject with neutral expression (called baseline condition **B**) and 12 samples per subject varying the facial expression (called expression **E**).
Such variability was introduced by asking the subject to count orally.
In total there are 960 images for this modality.
For the **thermal** images there are 4 types of thermal imagery based on the Stokes parameters (:math:`S_0`, :math:`S_1`, :math:`S_2` and :math:`S_3`) commonly used to represent the polarization state.
The thermal imagery is the following:
- :math:`S_0`: The conventional thermal image
- :math:`S_1`
- :math:`S_2`
- DoLP: The degree-of-linear-polarization (DoLP) describes the portion of an electromagnetic wave that is linearly polarized, as defined :math:`\\frac{sqrt(S_{1}^{2} + S_{2}^{2})}{S_0}`.
Since :math:`S_3` is very small and usually taken to be zero, the authors of the database decided not to provide this part of the data.
The same facial expression variability introduced in **VIS** is introduced for **Thermal** images.
The distance between the subject and the camera is the last source of variability introduced in the thermal images.
There are 3 ranges: R1 (2.5m), R2 (5m) and R3 (7.5m).
In total there are 11,520 images for this modality and for each subject they are split as the following:
+----------------+----------+----------+----------+
| Imagery/Range | R1 (B/E) | R2 (B/E) | R3 (B/E) |
+================+==========+==========+==========+
| :math:`S_0` | 16 (8/8) | 16 (8/8) | 16 (8/8) |
+----------------+----------+----------+----------+
| :math:`S_1` | 16 (8/8) | 16 (8/8) | 16 (8/8) |
+----------------+----------+----------+----------+
| :math:`S_2` | 16 (8/8) | 16 (8/8) | 16 (8/8) |
+----------------+----------+----------+----------+
| DoLP | 16 (8/8) | 16 (8/8) | 16 (8/8) |
+----------------+----------+----------+----------+
.. warning::
Use the command below to set the path of the real data::
$ bob config set bob.db.pola-thermal.directory [PATH-TO-MEDS-DATA]
Parameters
----------
protocol: str
One of the database protocols.
"""
def __init__(self, protocol):
# Downloading model if not exists
urls = PolaThermalDatabase.urls()
filename = get_file(
"pola_thermal.tar.gz", urls, file_hash="cfbd7362773c6d49292fe1998e3c3825",
)
self.annotation_type = "eyes-center"
self.fixed_positions = None
directory = (
rc["bob.db.pola-thermal.directory"]
if rc["bob.db.pola-thermal.directory"]
else ""
)
def load(path):
"""
Images in this dataset are stored as 16-bit PNG
"""
return bob.io.base.load(path) / 255
super().__init__(
filename,
protocol,
csv_to_sample_loader=make_pipeline(
CSVToSampleLoaderBiometrics(
data_loader=load,
dataset_original_directory=directory,
extension=".png",
),
EyesAnnotations(),
),
)
@staticmethod
def protocols():
# TODO: Until we have (if we have) a function that dumps the protocols, let's use this one.
return [
"VIS-VIS-split1",
"VIS-VIS-split2",
"VIS-VIS-split3",
"VIS-VIS-split4",
"VIS-VIS-split5",
"VIS-thermal-overall-split1",
"VIS-thermal-overall-split2",
"VIS-thermal-overall-split3",
"VIS-thermal-overall-split4",
"VIS-thermal-overall-split5",
"VIS-polarimetric-overall-split1",
"VIS-polarimetric-overall-split2",
"VIS-polarimetric-overall-split3",
"VIS-polarimetric-overall-split4",
"VIS-polarimetric-overall-split5",
"VIS-thermal-expression-split1",
"VIS-thermal-expression-split2",
"VIS-thermal-expression-split3",
"VIS-thermal-expression-split4",
"VIS-thermal-expression-split5",
"VIS-polarimetric-expression-split1",
"VIS-polarimetric-expression-split2",
"VIS-polarimetric-expression-split3",
"VIS-polarimetric-expression-split4",
"VIS-polarimetric-expression-split5",
"VIS-thermal-R1-split1",
"VIS-thermal-R1-split2",
"VIS-thermal-R1-split3",
"VIS-thermal-R1-split4",
"VIS-thermal-R1-split5",
"VIS-polarimetric-R1-split1",
"VIS-polarimetric-R1-split2",
"VIS-polarimetric-R1-split3",
"VIS-polarimetric-R1-split4",
"VIS-polarimetric-R1-split5",
"VIS-thermal-R2-split1",
"VIS-thermal-R2-split2",
"VIS-thermal-R2-split3",
"VIS-thermal-R2-split4",
"VIS-thermal-R2-split5",
"VIS-polarimetric-R2-split1",
"VIS-polarimetric-R2-split2",
"VIS-polarimetric-R2-split3",
"VIS-polarimetric-R2-split4",
"VIS-polarimetric-R2-split5",
"VIS-thermal-R3-split1",
"VIS-thermal-R3-split2",
"VIS-thermal-R3-split3",
"VIS-thermal-R3-split4",
"VIS-thermal-R3-split5",
"VIS-polarimetric-R3-split1",
"VIS-polarimetric-R3-split2",
"VIS-polarimetric-R3-split3",
"VIS-polarimetric-R3-split4",
"VIS-polarimetric-R3-split5",
]
@staticmethod
def urls():
return [
"https://www.idiap.ch/software/bob/databases/latest/pola_thermal.tar.gz",
"http://www.idiap.ch/software/bob/databases/latest/pola_thermal.tar.gz",
]
......@@ -404,3 +404,12 @@ def test_casia_africa():
assert len(database.references()) == 2455
assert len(database.probes()) == 2426
def test_casia_polathermal():
from bob.bio.face.database import PolaThermalDatabase
database = PolaThermalDatabase("VIS-thermal-overall-split1")
assert len(database.references()) == 35
assert len(database.probes()) == 1680
......@@ -23,6 +23,7 @@ Databases
bob.bio.face.database.FargoBioDatabase
bob.bio.face.database.MEDSDatabase
bob.bio.face.database.MorphDatabase
bob.bio.face.database.PolaThermalDatabase
Face Image Annotators
......
......@@ -113,6 +113,7 @@ setup(
"meds = bob.bio.face.config.database.meds:database",
"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",
],
"bob.bio.annotator": [
"facedetect = bob.bio.face.config.annotator.facedetect:annotator",
......@@ -179,6 +180,7 @@ setup(
"meds = bob.bio.face.config.database.meds",
"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",
"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",
......
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