Commit 350cd6cf authored by Olegs NIKISINS's avatar Olegs NIKISINS
Browse files

Merge branch 'minor-fixes' into 'master'

Minor fixes

See merge request !32
parents 8354dc0c 825e4156
Pipeline #17253 passed with stages
in 19 minutes and 20 seconds
...@@ -121,7 +121,6 @@ class SVM(Algorithm): ...@@ -121,7 +121,6 @@ class SVM(Algorithm):
self.n_train_samples = n_train_samples self.n_train_samples = n_train_samples
self.machine = None self.machine = None
# ========================================================================== # ==========================================================================
def comp_prediction_precision(self, machine, real, attack): def comp_prediction_precision(self, machine, real, attack):
""" """
...@@ -468,7 +467,6 @@ class SVM(Algorithm): ...@@ -468,7 +467,6 @@ class SVM(Algorithm):
Must be writable with the ``write_feature`` function and Must be writable with the ``write_feature`` function and
readable with the ``read_feature`` function. readable with the ``read_feature`` function.
""" """
if isinstance( if isinstance(
feature, feature,
FrameContainer): # if FrameContainer convert to 2D numpy array FrameContainer): # if FrameContainer convert to 2D numpy array
...@@ -517,6 +515,9 @@ class SVM(Algorithm): ...@@ -517,6 +515,9 @@ class SVM(Algorithm):
Score is a probability of a sample being a real class. Score is a probability of a sample being a real class.
""" """
if toscore.ndim == 1:
return [toscore[0]]
if self.frame_level_scores_flag: if self.frame_level_scores_flag:
score = toscore[:, score = toscore[:,
......
...@@ -143,3 +143,16 @@ def test_video_gmm_pad_algorithm(): ...@@ -143,3 +143,16 @@ def test_video_gmm_pad_algorithm():
assert (np.max(scores_real) + 1.8380480068281055) < 0.000001 assert (np.max(scores_real) + 1.8380480068281055) < 0.000001
assert (np.min(scores_attack) + 38.831260843070098) < 0.000001 assert (np.min(scores_attack) + 38.831260843070098) < 0.000001
assert (np.max(scores_attack) + 5.3633030621521272) < 0.000001 assert (np.max(scores_attack) + 5.3633030621521272) < 0.000001
def test_convert_list_of_frame_cont_to_array():
N = 1000
mu = 1
sigma = 1
real_array = np.transpose(np.vstack([[random.gauss(mu, sigma) for _ in range(N)], [random.gauss(mu, sigma) for _ in range(N)]]))
features_array = convert_list_of_frame_cont_to_array(real_array)
assert isinstance(features_array[0], np.ndarray)
features_fm = convert_array_to_list_of_frame_cont(real_array)
assert isinstance(features_fm[0], bob.bio.video.FrameContainer)
...@@ -87,13 +87,16 @@ def convert_list_of_frame_cont_to_array(frame_containers): ...@@ -87,13 +87,16 @@ def convert_list_of_frame_cont_to_array(frame_containers):
An array containing features for all frames of all individuals. An array containing features for all frames of all individuals.
""" """
feature_vectors = []
for frame_container in frame_containers: if isinstance( frame_containers[0], bob.bio.video.FrameContainer):
video_features_array = convert_frame_cont_to_array(
frame_container)
feature_vectors.append(video_features_array) feature_vectors = []
for frame_container in frame_containers:
video_features_array = convert_frame_cont_to_array(
frame_container)
feature_vectors.append(video_features_array)
else:
feature_vectors = frame_containers
features_array = np.vstack(feature_vectors) features_array = np.vstack(feature_vectors)
...@@ -478,4 +481,4 @@ def prepare_data_for_hyper_param_grid_search(training_features, n_samples): ...@@ -478,4 +481,4 @@ def prepare_data_for_hyper_param_grid_search(training_features, n_samples):
real_train, real_cv = split_data_to_train_cv(real_subset) real_train, real_cv = split_data_to_train_cv(real_subset)
attack_train, attack_cv = split_data_to_train_cv(attack_subset) attack_train, attack_cv = split_data_to_train_cv(attack_subset)
return real_train, real_cv, attack_train, attack_cv return real_train, real_cv, attack_train, attack_cv
\ No newline at end of file
...@@ -35,8 +35,8 @@ provided in ``bob.pad``. Hence for speech PAD, you can take ...@@ -35,8 +35,8 @@ provided in ``bob.pad``. Hence for speech PAD, you can take
the :py:class:`bob.bio.spear.preprocessor.Energy_2Gauss` and the the :py:class:`bob.bio.spear.preprocessor.Energy_2Gauss` and the
:py:class:`bob.bio.spear.extractor.Cepstral` feature extractor defined in :py:class:`bob.bio.spear.extractor.Cepstral` feature extractor defined in
:ref:`bob.bio.spear <bob.bio.spear>`, and the :ref:`bob.bio.spear <bob.bio.spear>`, and the
:py:class:`bob.pad.voice.algorithm.GmmAlgorithm` algorithm defined in :py:class:`bob.pad.base.algorithm.OneClassGMM` algorithm defined in
:ref:`bob.pad.voice <bob.pad.voice>`, using voicePA database (contains speech presentation attacks) :ref:`bob.pad.base <bob.pad.base>`, using voicePA database (contains speech presentation attacks)
interface defined in :ref:`bob.db.voicepa <bob.db.voicepa>`. Running the interface defined in :ref:`bob.db.voicepa <bob.db.voicepa>`. Running the
command line below will install all the required packages: command line below will install all the required packages:
......
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