Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
bob.bio.face
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bob
bob.bio.face
Commits
5f423214
Commit
5f423214
authored
Dec 13, 2020
by
Tiago de Freitas Pereira
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'sample_loader_as_transformer' into 'master'
SampleLoader as transformer See merge request
!88
parents
50af61d4
6b6c80e4
Pipeline
#46569
passed with stages
in 43 minutes and 49 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
29 deletions
+62
-29
bob/bio/face/config/database/meds.py
bob/bio/face/config/database/meds.py
+9
-0
bob/bio/face/database/meds.py
bob/bio/face/database/meds.py
+14
-9
bob/bio/face/database/sample_loaders.py
bob/bio/face/database/sample_loaders.py
+37
-20
setup.py
setup.py
+2
-0
No files found.
bob/bio/face/config/database/meds.py
0 → 100644
View file @
5f423214
from
bob.bio.face.database
import
MEDSDatabase
# In case protocol is comming from chain loading
# https://www.idiap.ch/software/bob/docs/bob/bob.extension/stable/py_api.html#bob.extension.config.load
if
"protocol"
not
in
locals
():
protocol
=
"verification_fold1"
database
=
MEDSDatabase
(
protocol
=
protocol
)
bob/bio/face/database/meds.py
View file @
5f423214
...
...
@@ -9,12 +9,15 @@
from
bob.bio.base.database
import
(
CSVDataset
,
CSVDatasetZTNorm
,
CSVToSampleLoader
,
)
from
bob.pipelines.datasets
import
CSVToSampleLoader
from
bob.bio.face.database.sample_loaders
import
EyesAnnotations
from
bob.extension
import
rc
from
bob.extension.download
import
get_file
import
bob.io.base
from
bob.bio.face.database.sample_loaders
import
eyes_annotations_loader
from
sklearn.pipeline
import
make_pipeline
# from bob.bio.face.database.sample_loaders import eyes_annotations_loader
import
os
...
...
@@ -57,13 +60,15 @@ class MEDSDatabase(CSVDatasetZTNorm):
database
=
CSVDataset
(
dataset_protocol_path
,
protocol
,
csv_to_sample_loader
=
CSVToSampleLoader
(
data_loader
=
bob
.
io
.
base
.
load
,
metadata_loader
=
eyes_annotations_loader
,
dataset_original_directory
=
rc
[
"bob.db.meds.directory"
]
if
rc
[
"bob.db.meds.directory"
]
else
""
,
extension
=
".jpg"
,
csv_to_sample_loader
=
make_pipeline
(
CSVToSampleLoader
(
data_loader
=
bob
.
io
.
base
.
load
,
dataset_original_directory
=
rc
[
"bob.db.meds.directory"
]
if
rc
[
"bob.db.meds.directory"
]
else
""
,
extension
=
".jpg"
,
),
EyesAnnotations
(),
),
)
...
...
bob/bio/face/database/sample_loaders.py
View file @
5f423214
...
...
@@ -4,23 +4,40 @@
""" Sample and Metatada loaders"""
def
eyes_annotations_loader
(
row
,
header
=
None
):
"""
Convert leye_x, leye_y, reye_x, reye_y attributes to `annotations = (leye, reye)`
"""
def
find_attribute
(
attribute
):
for
i
,
a
in
enumerate
(
header
):
if
a
==
attribute
:
return
i
else
:
ValueError
(
f"Attribute not found in the dataset:
{
a
}
"
)
eyes
=
{
"leye"
:
(
row
[
find_attribute
(
"leye_x"
)],
row
[
find_attribute
(
"leye_y"
)]),
"reye"
:
(
row
[
find_attribute
(
"reye_x"
)],
row
[
find_attribute
(
"reye_y"
)]),
}
annotation
=
{
"annotations"
:
eyes
}
return
annotation
from
bob.pipelines
import
DelayedSample
,
Sample
,
SampleSet
from
sklearn.base
import
TransformerMixin
,
BaseEstimator
class
EyesAnnotations
(
TransformerMixin
,
BaseEstimator
):
def
fit
(
self
,
X
,
y
=
None
):
return
self
def
_more_tags
(
self
):
return
{
"stateless"
:
True
,
"requires_fit"
:
False
,
}
def
transform
(
self
,
X
):
"""
Convert leye_x, leye_y, reye_x, reye_y attributes to `annotations = (leye, reye)`
"""
def
find_attribute
(
x
,
attribute
):
if
hasattr
(
x
,
attribute
):
return
getattr
(
x
,
attribute
)
else
:
ValueError
(
f"Attribute not found in the dataset:
{
attribute
}
"
)
annotated_samples
=
[]
for
x
in
X
:
eyes
=
{
"leye"
:
(
find_attribute
,
(
x
,
"leye_x"
),
find_attribute
(
x
,
"leye_y"
)),
"reye"
:
(
find_attribute
(
x
,
"reye_x"
),
find_attribute
(
x
,
"reye_y"
)),
}
sample
=
DelayedSample
(
x
.
_load
,
parent
=
x
,
annotations
=
eyes
)
[
delattr
(
sample
,
a
)
for
a
in
[
"leye_x"
,
"leye_y"
,
"reye_x"
,
"reye_y"
]]
annotated_samples
.
append
(
sample
)
return
annotated_samples
setup.py
View file @
5f423214
...
...
@@ -110,6 +110,7 @@ setup(
"replaymobile-img-licit = bob.bio.face.config.database.replaymobile:replaymobile_licit"
,
"replaymobile-img-spoof = bob.bio.face.config.database.replaymobile:replaymobile_spoof"
,
"fargo = bob.bio.face.config.database.fargo:database"
,
"meds = bob.bio.face.config.database.meds:database"
,
],
"bob.bio.annotator"
:
[
"facedetect = bob.bio.face.config.annotator.facedetect:annotator"
,
...
...
@@ -170,6 +171,7 @@ setup(
"replaymobile-img-licit = bob.bio.face.config.database.replaymobile_licit"
,
"replaymobile-img-spoof = bob.bio.face.config.database.replaymobile_spoof"
,
"fargo = bob.bio.face.config.database.fargo"
,
"meds = bob.bio.face.config.database.meds"
,
],
"bob.bio.cli"
:
[
"display-face-annotations = bob.bio.face.script.display_face_annotations:display_face_annotations"
,
...
...
Write
Preview
Markdown
is supported
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