Commit c243d2ce authored by Olegs NIKISINS's avatar Olegs NIKISINS
Browse files

Fixed the load method in HLDI of CelebA, added BW face cropper

parent e396992b
Pipeline #20491 passed with stage
in 23 minutes and 26 seconds
......@@ -13,16 +13,16 @@ from bob.pad.face.database.celeb_a import CELEBAPadDatabase
# Directory where the data files are stored.
# This directory is given in the .bob_bio_databases.txt file located in your home directory
original_directory = "[YOUR_CELEB_A_DATABASE_DIRECTORY]"
ORIGINAL_DIRECTORY = "[YOUR_CELEB_A_DATABASE_DIRECTORY]"
"""Value of ``~/.bob_bio_databases.txt`` for this database"""
original_extension = "" # extension of the data files
ORIGINAL_EXTENSION = "" # extension of the data files
database = CELEBAPadDatabase(
protocol='grandtest',
original_directory=original_directory,
original_extension=original_extension,
training_depends_on_protocol=True,
original_directory=ORIGINAL_DIRECTORY,
original_extension=ORIGINAL_EXTENSION,
training_depends_on_protocol=True
)
"""The :py:class:`bob.pad.base.database.PadDatabase` derivative with CELEBA
database settings.
......
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
from ..preprocessor import FaceCropAlign
from bob.pad.face.preprocessor import FaceCropAlign
from bob.bio.video.preprocessor import Wrapper
......@@ -42,3 +42,25 @@ _image_preprocessor = FaceCropAlign(face_size=FACE_SIZE,
rgb_face_detector_mtcnn = Wrapper(preprocessor = _image_preprocessor,
frame_selector = _frame_selector)
# =======================================================================================
FACE_SIZE = 64 # The size of the resulting face
RGB_OUTPUT_FLAG = False # Gray-scale output
USE_FACE_ALIGNMENT = True # detect face landmarks locally and align the face
MAX_IMAGE_SIZE = 1920 # the largest possible dimension of the input image
FACE_DETECTION_METHOD = "mtcnn" # face landmarks detection method
MIN_FACE_SIZE = 50 # skip faces smaller than this value
NORMALIZATION_FUNCTION = None # no normalization
NORMALIZATION_FUNCTION_KWARGS = None
_image_preprocessor = FaceCropAlign(face_size=FACE_SIZE,
rgb_output_flag=RGB_OUTPUT_FLAG,
use_face_alignment=USE_FACE_ALIGNMENT,
max_image_size=MAX_IMAGE_SIZE,
face_detection_method=FACE_DETECTION_METHOD,
min_face_size=MIN_FACE_SIZE,
normalization_function=NORMALIZATION_FUNCTION,
normalization_function_kwargs=NORMALIZATION_FUNCTION_KWARGS)
bw_face_detect_mtcnn = Wrapper(preprocessor=_image_preprocessor,
frame_selector=_frame_selector)
......@@ -24,8 +24,9 @@ class CELEBAPadFile(PadFile):
def __init__(self, client_id, path, attack_type=None, file_id=None):
super(CELEBAPadFile, self).__init__(client_id, path, attack_type, file_id)
#==========================================================================
def load(self, directory=None, extension=None):
# ==========================================================================
def load(self, directory=None, extension=None,
frame_selector=bob.bio.video.FrameSelector(selection_style='all')):
"""
Overridden version of the load method defined in the ``PadFile``.
......@@ -39,6 +40,9 @@ class CELEBAPadFile(PadFile):
Extension of the video files in the CELEBA database.
Default: None
``frame_selector`` : :any:`bob.bio.video.FrameSelector`, optional
Specifying the frames to be selected.
**Returns:**
``video_data`` : FrameContainer
......@@ -47,7 +51,6 @@ class CELEBAPadFile(PadFile):
"""
path = self.make_path(directory=directory, extension=extension) # path to the file
frame_selector = bob.bio.video.FrameSelector(selection_style = 'all') # this frame_selector will select all frames from the video file
data = bob.io.base.load(path)
data = np.expand_dims(data, axis=0) # upgrade to 4D (video)
......
......@@ -109,6 +109,7 @@ setup(
'empty-preprocessor = bob.pad.face.config.preprocessor.filename:empty_preprocessor', # no preprocessing
'rgb-face-detect-dlib = bob.pad.face.config.preprocessor.video_face_crop:rgb_face_detector_dlib', # detect faces locally replacing database annotations
'rgb-face-detect-mtcnn = bob.pad.face.config.preprocessor.video_face_crop:rgb_face_detector_mtcnn', # detect faces locally replacing database annotations
'bw-face-detect-mtcnn = bob.pad.face.config.preprocessor.video_face_crop:bw_face_detect_mtcnn', # detect faces locally, return BW image
],
# registered extractors:
......
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