Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bob
bob.bio.base
Commits
54b3600e
Commit
54b3600e
authored
Nov 22, 2020
by
Tiago de Freitas Pereira
Browse files
Optimize scoring if allow_scoring_with_all_biometric_references == False
parent
d9c1669b
Pipeline
#45945
failed with stage
in 9 minutes and 36 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
bob/bio/base/pipelines/vanilla_biometrics/abstract_classes.py
View file @
54b3600e
...
...
@@ -31,7 +31,7 @@ class BioAlgorithm(metaclass=ABCMeta):
"""
def
__init__
(
self
,
score_reduction_operation
=
average_scores
,
**
kwargs
):
def
__init__
(
self
,
score_reduction_operation
=
average_scores
,
**
kwargs
):
self
.
stacked_biometric_references
=
None
self
.
score_reduction_operation
=
average_scores
...
...
@@ -163,19 +163,45 @@ class BioAlgorithm(metaclass=ABCMeta):
# There are some protocols where each probe has
# to be scored with a specific list of biometric_references
total_scores
=
[]
if
self
.
stacked_biometric_references
is
None
:
self
.
stacked_biometric_references
=
dict
()
def
cache_references
(
probe_refererences
):
"""
Stack referecences in a dictionary
"""
for
r
in
biometric_references
:
if
(
str
(
r
.
subject
)
in
probe_refererences
and
str
(
r
.
subject
)
not
in
self
.
stacked_biometric_references
):
self
.
stacked_biometric_references
[
str
(
r
.
subject
)]
=
r
.
data
for
probe_sample
in
sampleset
:
scores
=
[]
for
ref
in
[
r
for
r
in
biometric_references
if
str
(
r
.
subject
)
in
sampleset
.
references
]:
scores
.
append
(
self
.
score
(
ref
.
data
,
probe_sample
.
data
))
cache_references
(
sampleset
.
references
)
references
=
[
self
.
stacked_biometric_references
[
str
(
r
.
subject
)]
for
r
in
biometric_references
if
str
(
r
.
subject
)
in
sampleset
.
references
]
scores
=
self
.
score_multiple_biometric_references
(
references
,
probe_sample
.
data
)
total_scores
.
append
(
scores
)
total_scores
=
self
.
score_reduction_operation
(
np
.
array
(
total_scores
))
for
ref
,
score
in
zip
([
r
for
r
in
biometric_references
if
str
(
r
.
subject
)
in
sampleset
.
references
],
total_scores
):
for
ref
,
score
in
zip
(
[
r
for
r
in
biometric_references
if
str
(
r
.
subject
)
in
sampleset
.
references
],
total_scores
,
):
scores_biometric_references
.
append
(
Sample
(
score
,
parent
=
ref
))
...
...
@@ -187,7 +213,6 @@ class BioAlgorithm(metaclass=ABCMeta):
)
return
SampleSet
(
scores_biometric_references
,
parent
=
sampleset
,
**
kwargs
)
@
abstractmethod
def
score
(
self
,
biometric_reference
,
data
):
"""It handles the score computation for one sample
...
...
@@ -226,7 +251,9 @@ class BioAlgorithm(metaclass=ABCMeta):
Data used for the creation of ONE BIOMETRIC REFERENCE
"""
raise
NotImplementedError
(
"Your BioAlgorithm implementation should implement score_multiple_biometric_references."
)
raise
NotImplementedError
(
"Your BioAlgorithm implementation should implement score_multiple_biometric_references."
)
class
Database
(
metaclass
=
ABCMeta
):
...
...
@@ -310,6 +337,7 @@ class ScoreWriter(metaclass=ABCMeta):
import
dask.bag
import
dask
if
isinstance
(
score_paths
,
dask
.
bag
.
Bag
):
all_paths
=
dask
.
delayed
(
list
)(
score_paths
)
return
dask
.
delayed
(
_post_process
)(
all_paths
,
filename
)
...
...
Laurent COLBOIS
@lcolbois
mentioned in issue
#154 (closed)
·
May 18, 2021
mentioned in issue
#154 (closed)
mentioned in issue #154
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment