FaceRecLib Utilities¶
-
facereclib.utils.
load
(file)[source]¶ Loads data from file. The given file might be an HDF5 file open for reading or a string.
-
facereclib.utils.
save
(data, file, compression=0)[source]¶ Saves the data to file using HDF5. The given file might be an HDF5 file open for writing, or a string. If the given data contains a
save
method, this method is called with the given HDF5 file. Otherwise the data is written to the HDF5 file using the given compression.
-
facereclib.utils.
open_compressed
(filename, open_flag='r', compression_type='bz2')[source]¶ Opens a compressed HDF5File with the given opening flags. For the ‘r’ flag, the given compressed file will be extracted to a local space. For ‘w’, an empty HDF5File is created. In any case, the opened HDF5File is returned, which needs to be closed using the close_compressed() function.
-
facereclib.utils.
close_compressed
(filename, hdf5_file, compression_type='bz2', create_link=False)[source]¶ Closes the compressed hdf5_file that was opened with open_compressed. When the file was opened for writing (using the ‘w’ flag in open_compressed), the created HDF5 file is compressed into the given file name. To be able to read the data using the real tools, a link with the correct extension might is created, when create_link is set to True.
-
facereclib.utils.
load_compressed
(filename, compression_type='bz2')[source]¶ Extracts the data to a temporary HDF5 file using HDF5 and reads its contents. Note that, though the file name is .hdf5, it contains compressed data! Accepted compression types are ‘gz’, ‘bz2’, ‘’
-
facereclib.utils.
save_compressed
(data, filename, compression_type='bz2', create_link=False)[source]¶ Saves the data to a temporary file using HDF5. Afterwards, the file is compressed using the given compression method and saved using the given file name. Note that, though the file name will be .hdf5, it will contain compressed data! Accepted compression types are ‘gz’, ‘bz2’, ‘’
-
facereclib.utils.
ensure_dir
(dirname)[source]¶ Creates the directory dirname if it does not already exist, taking into account concurrent ‘creation’ on the grid. An exception is thrown if a file (rather than a directory) already exists.
-
facereclib.utils.
score_fusion_strategy
(strategy_name='avarage')[source]¶ Returns a function to compute a fusion strategy between different scores.
Different strategies are employed:
'average'
: The averaged score is computed using thenumpy.average()
function.'min'
: The minimum score is computed using themin()
function.'max'
: The maximum score is computed using themax()
function.'median'
: The median score is computed using thenumpy.median()
function.None
is also accepted, in which caseNone
is returned.
-
facereclib.utils.
gray_channel
(image, channel='gray')[source]¶ Returns the desired channel of the given image. Currently, gray, red, green and blue channels are supported.
-
facereclib.utils.
quasi_random_indices
(number_of_total_items, number_of_desired_items=None)[source]¶ Returns a quasi-random list of indices that will contain exactly the number of desired indices (or the number of total items in the list, if this is smaller).
-
facereclib.utils.
command_line
(cmdline)[source]¶ Converts the given options to a string that can be executed on command line.
-
class
facereclib.utils.
GridParameters
(grid='sge', number_of_preprocessing_jobs=32, number_of_extraction_jobs=32, number_of_projection_jobs=32, number_of_enrollment_jobs=32, number_of_scoring_jobs=32, training_queue='8G', preprocessing_queue='default', extraction_queue='default', projection_queue='default', enrollment_queue='default', scoring_queue='default', number_of_parallel_processes=1, scheduler_sleep_time=1.0)[source]¶ This class is defining the options that are required to submit parallel jobs to the SGE grid.
-
facereclib.utils.
add_bob_handlers
(logger_name, set_format=True, set_log_level=True)[source]¶ Sets the logging handler of ‘bob’ to the logger with the given name
-
facereclib.utils.
add_logger_command_line_option
(parser)[source]¶ Adds the verbosity command line option to the given parser.