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

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):
self.n_train_samples = n_train_samples
self.machine = None
# ==========================================================================
def comp_prediction_precision(self, machine, real, attack):
"""
......@@ -468,7 +467,6 @@ class SVM(Algorithm):
Must be writable with the ``write_feature`` function and
readable with the ``read_feature`` function.
"""
if isinstance(
feature,
FrameContainer): # if FrameContainer convert to 2D numpy array
......@@ -517,6 +515,9 @@ class SVM(Algorithm):
Score is a probability of a sample being a real class.
"""
if toscore.ndim == 1:
return [toscore[0]]
if self.frame_level_scores_flag:
score = toscore[:,
......
......@@ -143,3 +143,16 @@ def test_video_gmm_pad_algorithm():
assert (np.max(scores_real) + 1.8380480068281055) < 0.000001
assert (np.min(scores_attack) + 38.831260843070098) < 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):
An array containing features for all frames of all individuals.
"""
feature_vectors = []
if isinstance( frame_containers[0], bob.bio.video.FrameContainer):
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)
......
......@@ -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
:py:class:`bob.bio.spear.extractor.Cepstral` feature extractor defined in
:ref:`bob.bio.spear <bob.bio.spear>`, and the
:py:class:`bob.pad.voice.algorithm.GmmAlgorithm` algorithm defined in
:ref:`bob.pad.voice <bob.pad.voice>`, using voicePA database (contains speech presentation attacks)
:py:class:`bob.pad.base.algorithm.OneClassGMM` algorithm defined in
: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
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