Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.pad.face
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bob
bob.pad.face
Commits
bb36b1e1
There was a problem fetching the pipeline summary.
Commit
bb36b1e1
authored
7 years ago
by
Olegs NIKISINS
Browse files
Options
Downloads
Patches
Plain Diff
Added video and frame subsampling options to VideoLRPadAlgorithm
parent
9f5e7433
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!12
Added anomaly detection algos and unseen attack protocols for aggregated database
Pipeline
#
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/pad/face/algorithm/VideoLRPadAlgorithm.py
+82
-4
82 additions, 4 deletions
bob/pad/face/algorithm/VideoLRPadAlgorithm.py
with
82 additions
and
4 deletions
bob/pad/face/algorithm/VideoLRPadAlgorithm.py
+
82
−
4
View file @
bb36b1e1
...
...
@@ -45,17 +45,39 @@ class VideoLRPadAlgorithm(Algorithm):
``frame_level_scores_flag`` : :py:class:`bool`
Return scores for each frame individually if True. Otherwise, return a
single score per video. Default: False.
single score per video. Default: ``False``.
``subsample_train_data_flag`` : :py:class:`bool`
Uniformly subsample the training data if ``True``. Default: ``False``.
``subsampling_step`` : :py:class:`int`
Training data subsampling step, only valid is
``subsample_train_data_flag = True``. Default: 10 .
``subsample_videos_flag`` : :py:class:`bool`
Uniformly subsample the training videos if ``True``. Default: ``False``.
``video_subsampling_step`` : :py:class:`int`
Training videos subsampling step, only valid is
``subsample_videos_flag = True``. Default: 3 .
"""
def
__init__
(
self
,
C
=
1
,
frame_level_scores_flag
=
False
):
frame_level_scores_flag
=
False
,
subsample_train_data_flag
=
False
,
subsampling_step
=
10
,
subsample_videos_flag
=
False
,
video_subsampling_step
=
3
):
Algorithm
.
__init__
(
self
,
C
=
C
,
frame_level_scores_flag
=
frame_level_scores_flag
,
subsample_train_data_flag
=
subsample_train_data_flag
,
subsampling_step
=
subsampling_step
,
subsample_videos_flag
=
subsample_videos_flag
,
video_subsampling_step
=
video_subsampling_step
,
performs_projection
=
True
,
requires_projector_training
=
True
)
...
...
@@ -63,6 +85,14 @@ class VideoLRPadAlgorithm(Algorithm):
self
.
frame_level_scores_flag
=
frame_level_scores_flag
self
.
subsample_train_data_flag
=
subsample_train_data_flag
self
.
subsampling_step
=
subsampling_step
self
.
subsample_videos_flag
=
subsample_videos_flag
self
.
video_subsampling_step
=
video_subsampling_step
self
.
lr_machine
=
None
# this argument will be updated with pretrained LR machine
self
.
features_mean
=
None
# this argument will be updated with features mean
...
...
@@ -316,6 +346,32 @@ class VideoLRPadAlgorithm(Algorithm):
del
f
#==========================================================================
def
subsample_train_videos
(
self
,
training_features
,
step
):
"""
Uniformly select subset of frmae containes from the input list
**Parameters:**
``training_features`` : [FrameContainer]
A list of FrameContainers
``step`` : :py:class:`int`
Data selection step.
**Returns:**
``training_features_subset`` : [FrameContainer]
A list with selected FrameContainers
"""
indexes
=
range
(
0
,
len
(
training_features
),
step
)
training_features_subset
=
[
training_features
[
x
]
for
x
in
indexes
]
return
training_features_subset
#==========================================================================
def
train_projector
(
self
,
training_features
,
projector_file
):
"""
...
...
@@ -336,10 +392,32 @@ class VideoLRPadAlgorithm(Algorithm):
"""
# training_features[0] - training features for the REAL class.
real
=
self
.
convert_list_of_frame_cont_to_array
(
training_features
[
0
])
# output is array
# training_features[1] - training features for the ATTACK class.
if
self
.
subsample_videos_flag
:
# subsample videos of the real class
real
=
self
.
convert_list_of_frame_cont_to_array
(
self
.
subsample_train_videos
(
training_features
[
0
],
self
.
video_subsampling_step
)
)
# output is array
else
:
real
=
self
.
convert_list_of_frame_cont_to_array
(
training_features
[
0
])
# output is array
if
self
.
subsample_train_data_flag
:
real
=
real
[
range
(
0
,
len
(
real
),
self
.
subsampling_step
),
:]
if
self
.
subsample_videos_flag
:
# subsample videos of the real class
attack
=
self
.
convert_list_of_frame_cont_to_array
(
self
.
subsample_train_videos
(
training_features
[
1
],
self
.
video_subsampling_step
)
)
# output is array
else
:
attack
=
self
.
convert_list_of_frame_cont_to_array
(
training_features
[
1
])
# output is array
if
self
.
subsample_train_data_flag
:
attack
=
attack
[
range
(
0
,
len
(
attack
),
self
.
subsampling_step
),
:]
# Train the LR machine and get normalizers:
machine
,
features_mean
,
features_std
=
self
.
train_lr
(
real
=
real
,
attack
=
attack
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment