Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.bio.base
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bob
bob.bio.base
Commits
6ae969d4
Commit
6ae969d4
authored
5 years ago
by
Tiago de Freitas Pereira
Browse files
Options
Downloads
Patches
Plain Diff
Check if there are samples available for the function train_background_model
parent
076f80c2
No related branches found
No related tags found
1 merge request
!180
[dask] Preparing bob.bio.base for dask pipelines
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/bio/base/pipelines/vanilla_biometrics/pipeline.py
+26
-3
26 additions, 3 deletions
bob/bio/base/pipelines/vanilla_biometrics/pipeline.py
with
26 additions
and
3 deletions
bob/bio/base/pipelines/vanilla_biometrics/pipeline.py
+
26
−
3
View file @
6ae969d4
...
@@ -9,6 +9,7 @@ for bob.bio experiments
...
@@ -9,6 +9,7 @@ for bob.bio experiments
"""
"""
import
logging
import
logging
import
numpy
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
...
@@ -19,6 +20,7 @@ def biometric_pipeline(
...
@@ -19,6 +20,7 @@ def biometric_pipeline(
probe_samples
,
probe_samples
,
transformer
,
transformer
,
biometric_algorithm
,
biometric_algorithm
,
allow_scoring_with_all_biometric_references
=
False
,
):
):
logger
.
info
(
logger
.
info
(
f
"
>> Vanilla Biometrics: Training background model with pipeline
{
transformer
}
"
f
"
>> Vanilla Biometrics: Training background model with pipeline
{
transformer
}
"
...
@@ -43,12 +45,25 @@ def biometric_pipeline(
...
@@ -43,12 +45,25 @@ def biometric_pipeline(
# Scores all probes
# Scores all probes
return
compute_scores
(
return
compute_scores
(
probe_samples
,
biometric_references
,
transformer
,
biometric_algorithm
probe_samples
,
biometric_references
,
transformer
,
biometric_algorithm
,
allow_scoring_with_all_biometric_references
,
)
)
def
train_background_model
(
background_model_samples
,
transformer
):
def
train_background_model
(
background_model_samples
,
transformer
):
# background_model_samples is a list of Samples
# background_model_samples is a list of Samples
# We might have algorithms that has no data for training
if
len
(
background_model_samples
)
<=
0
:
logger
.
warning
(
"
There
'
s no data to train background model.
"
"
For the rest of the execution it will be assumed that the pipeline is stateless.
"
)
return
transformer
transformer
=
transformer
.
fit
(
background_model_samples
)
transformer
=
transformer
.
fit
(
background_model_samples
)
return
transformer
return
transformer
...
@@ -67,13 +82,21 @@ def create_biometric_reference(
...
@@ -67,13 +82,21 @@ def create_biometric_reference(
def
compute_scores
(
def
compute_scores
(
probe_samples
,
biometric_references
,
transformer
,
biometric_algorithm
probe_samples
,
biometric_references
,
transformer
,
biometric_algorithm
,
allow_scoring_with_all_biometric_references
=
False
,
):
):
# probes is a list of SampleSets
# probes is a list of SampleSets
probe_features
=
transformer
.
transform
(
probe_samples
)
probe_features
=
transformer
.
transform
(
probe_samples
)
scores
=
biometric_algorithm
.
score_samples
(
probe_features
,
biometric_references
)
scores
=
biometric_algorithm
.
score_samples
(
probe_features
,
biometric_references
,
allow_scoring_with_all_biometric_references
=
allow_scoring_with_all_biometric_references
,
)
# scores is a list of Samples
# scores is a list of Samples
return
scores
return
scores
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