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
4df4e7e5
Commit
4df4e7e5
authored
5 years ago
by
Tiago de Freitas Pereira
Committed by
Amir MOHAMMADI
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Metadate attempt
parent
144e75a4
Branches
Branches containing commit
Tags
Tags containing commit
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/legacy.py
+39
-19
39 additions, 19 deletions
bob/bio/base/pipelines/vanilla_biometrics/legacy.py
with
39 additions
and
19 deletions
bob/bio/base/pipelines/vanilla_biometrics/legacy.py
+
39
−
19
View file @
4df4e7e5
...
@@ -46,6 +46,7 @@ class DatabaseConnector:
...
@@ -46,6 +46,7 @@ class DatabaseConnector:
self
.
directory
=
database
.
original_directory
self
.
directory
=
database
.
original_directory
self
.
extension
=
database
.
original_extension
self
.
extension
=
database
.
original_extension
def
background_model_samples
(
self
):
def
background_model_samples
(
self
):
"""
Returns :py:class:`Sample`
'
s to train a background model (group
"""
Returns :py:class:`Sample`
'
s to train a background model (group
``world``).
``world``).
...
@@ -105,8 +106,7 @@ class DatabaseConnector:
...
@@ -105,8 +106,7 @@ class DatabaseConnector:
"""
"""
retval
=
[]
retval
=
[]
for
m
in
self
.
database
.
model_ids_with_protocol
(
protocol
=
self
.
protocol
,
groups
=
group
):
for
m
in
self
.
database
.
model_ids
(
protocol
=
self
.
protocol
,
groups
=
group
):
objects
=
self
.
database
.
objects
(
objects
=
self
.
database
.
objects
(
protocol
=
self
.
protocol
,
groups
=
group
,
model_ids
=
(
m
,),
purposes
=
"
enroll
"
protocol
=
self
.
protocol
,
groups
=
group
,
model_ids
=
(
m
,),
purposes
=
"
enroll
"
...
@@ -157,7 +157,7 @@ class DatabaseConnector:
...
@@ -157,7 +157,7 @@ class DatabaseConnector:
probes
=
dict
()
probes
=
dict
()
for
m
in
self
.
database
.
model_ids
(
protocol
=
self
.
protocol
,
groups
=
group
):
for
m
in
self
.
database
.
model_ids
_with_protocol
(
protocol
=
self
.
protocol
,
groups
=
group
):
# Getting all the probe objects from a particular biometric
# Getting all the probe objects from a particular biometric
# reference
# reference
...
@@ -191,6 +191,30 @@ class DatabaseConnector:
...
@@ -191,6 +191,30 @@ class DatabaseConnector:
return
list
(
probes
.
values
())
return
list
(
probes
.
values
())
def
_load_data_and_annotations
(
bio_file
,
annotations
,
original_directory
,
original_extension
):
"""
Return a tuple (data, annotations) given a :py:class:`bob.bio.base.database.BioFile` as input
Parameters
----------
bio_file: :py:class:`bob.bio.base.database.BioFile`
Input bio file
Returns
-------
(data, annotations): A dictionary containing the raw data + annotations
"""
data
=
bio_file
.
load
(
original_directory
,
original_extension
)
# I know it sounds stupid to return the the annotations here without any transformation
# but I can't do `database.annotations(bio_file)`, SQLAlcheamy session is not picklable
return
{
"
data
"
:
data
,
"
annotations
"
:
annotations
}
class
DatabaseConnectorAnnotated
(
DatabaseConnector
):
class
DatabaseConnectorAnnotated
(
DatabaseConnector
):
"""
Wraps a bob.bio.base database and generates conforming samples for datasets
"""
Wraps a bob.bio.base database and generates conforming samples for datasets
that has annotations
that has annotations
...
@@ -215,6 +239,7 @@ class DatabaseConnectorAnnotated(DatabaseConnector):
...
@@ -215,6 +239,7 @@ class DatabaseConnectorAnnotated(DatabaseConnector):
def
__init__
(
self
,
database
,
protocol
):
def
__init__
(
self
,
database
,
protocol
):
super
(
DatabaseConnectorAnnotated
,
self
).
__init__
(
database
,
protocol
)
super
(
DatabaseConnectorAnnotated
,
self
).
__init__
(
database
,
protocol
)
def
background_model_samples
(
self
):
def
background_model_samples
(
self
):
"""
Returns :py:class:`Sample`
'
s to train a background model (group
"""
Returns :py:class:`Sample`
'
s to train a background model (group
``world``).
``world``).
...
@@ -233,21 +258,19 @@ class DatabaseConnectorAnnotated(DatabaseConnector):
...
@@ -233,21 +258,19 @@ class DatabaseConnectorAnnotated(DatabaseConnector):
retval
=
[]
retval
=
[]
objects
=
self
.
database
.
objects
(
protocol
=
self
.
protocol
,
groups
=
"
world
"
)
objects
=
self
.
database
.
objects
(
protocol
=
self
.
protocol
,
groups
=
"
world
"
)
return
[
return
[
SampleSet
(
SampleSet
(
[
[
DelayedSample
(
DelayedSample
(
load
=
functools
.
partial
(
load
=
functools
.
partial
(
k
.
load
,
_load_data_and_annotations
,
self
.
database
.
annotations
(
k
),
self
.
database
.
original_directory
,
self
.
database
.
original_extension
self
.
database
.
original_directory
,
self
.
database
.
original_extension
,
),
),
id
=
k
.
id
,
key
=
str
(
k
.
id
)
,
path
=
k
.
path
,
path
=
k
.
path
,
annotations
=
self
.
database
.
annotations
(
k
),
annotations
=
self
.
database
.
annotations
(
k
),
)
)
]
],
key
=
str
(
k
.
client_id
),
)
)
for
k
in
objects
for
k
in
objects
]
]
...
@@ -288,17 +311,16 @@ class DatabaseConnectorAnnotated(DatabaseConnector):
...
@@ -288,17 +311,16 @@ class DatabaseConnectorAnnotated(DatabaseConnector):
[
[
DelayedSample
(
DelayedSample
(
load
=
functools
.
partial
(
load
=
functools
.
partial
(
k
.
load
,
_load_data_and_annotations
,
self
.
database
.
annotations
(
k
),
self
.
database
.
original_directory
,
self
.
database
.
original_extension
self
.
database
.
original_directory
,
self
.
database
.
original_extension
,
),
),
id
=
k
.
id
,
key
=
k
.
id
,
path
=
k
.
path
,
path
=
k
.
path
,
subject
=
str
(
objects
[
0
].
client_id
),
annotations
=
self
.
database
.
annotations
(
k
),
annotations
=
self
.
database
.
annotations
(
k
),
)
)
for
k
in
objects
for
k
in
objects
],
],
id
=
m
,
key
=
str
(
m
)
,
path
=
str
(
m
),
path
=
str
(
m
),
subject
=
objects
[
0
].
client_id
,
subject
=
objects
[
0
].
client_id
,
)
)
...
@@ -346,16 +368,14 @@ class DatabaseConnectorAnnotated(DatabaseConnector):
...
@@ -346,16 +368,14 @@ class DatabaseConnectorAnnotated(DatabaseConnector):
[
[
DelayedSample
(
DelayedSample
(
load
=
functools
.
partial
(
load
=
functools
.
partial
(
o
.
load
,
_load_data_and_annotations
,
self
.
database
.
annotations
(
o
),
self
.
database
.
original_directory
,
self
.
database
.
original_extension
self
.
database
.
original_directory
,
self
.
database
.
original_extension
,
),
),
id
=
o
.
id
,
key
=
o
.
id
,
path
=
o
.
path
,
path
=
o
.
path
,
annotations
=
self
.
database
.
annotations
(
o
),
annotations
=
self
.
database
.
annotations
(
o
),
)
)
],
],
id
=
o
.
id
,
key
=
o
.
id
,
path
=
o
.
path
,
path
=
o
.
path
,
subject
=
o
.
client_id
,
subject
=
o
.
client_id
,
references
=
[
m
],
references
=
[
m
],
...
...
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