Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.pad.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.pad.base
Commits
769aeb47
There was a problem fetching the pipeline summary.
Commit
769aeb47
authored
7 years ago
by
Amir Mohammadi
Committed by
Pavel KORSHUNOV
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add support for annotations
parent
9025548f
No related branches found
No related tags found
1 merge request
!8
Adds annotations for PAD (similar to bob.bio.base)
Pipeline
#
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
bob/pad/base/database/database.py
+14
-2
14 additions, 2 deletions
bob/pad/base/database/database.py
bob/pad/base/tools/FileSelector.py
+7
-0
7 additions, 0 deletions
bob/pad/base/tools/FileSelector.py
bob/pad/base/tools/preprocessor.py
+8
-1
8 additions, 1 deletion
bob/pad/base/tools/preprocessor.py
with
29 additions
and
3 deletions
bob/pad/base/database/database.py
+
14
−
2
View file @
769aeb47
...
...
@@ -85,12 +85,24 @@ class PadDatabase(BioDatabase):
"""
return
[]
@abc.abstractmethod
def
annotations
(
self
,
file
):
"""
Annotations are not supported by PAD interface
Returns the annotations for the given File object, if available.
You need to override this method in your high-level implementation.
If your database does not have annotations, it should return ``None``.
**Parameters:**
file : :py:class:`bob.pad.base.database.PadFile`
The file for which annotations should be returned.
**Returns:**
annots : dict or None
The annotations for the file, if available.
"""
r
eturn
None
r
aise
NotImplementedError
(
"
This function must be implemented in your derived class.
"
)
@abc.abstractmethod
def
objects
(
self
,
groups
=
None
,
protocol
=
None
,
purposes
=
None
,
model_ids
=
None
,
**
kwargs
):
...
...
This diff is collapsed.
Click to expand it.
bob/pad/base/tools/FileSelector.py
+
7
−
0
View file @
769aeb47
...
...
@@ -147,3 +147,10 @@ class FileSelector(object):
no_norm_dir
=
self
.
score_directories
[
0
]
return
os
.
path
.
join
(
no_norm_dir
,
"
scores-
"
+
group
+
"
-
"
+
obj_type
)
+
self
.
compressed_extension
def
annotation_list
(
self
,
groups
=
None
):
"""
Returns the list of annotations objects.
"""
return
self
.
database
.
all_files
(
groups
=
groups
)
def
get_annotations
(
self
,
annotation_file
):
"""
Returns the annotations of the given file.
"""
return
self
.
database
.
annotations
(
annotation_file
)
This diff is collapsed.
Click to expand it.
bob/pad/base/tools/preprocessor.py
+
8
−
1
View file @
769aeb47
...
...
@@ -46,6 +46,9 @@ def preprocess(preprocessor, groups=None, indices=None, allow_missing_files=Fals
data_files
,
original_directory
,
original_extension
=
fs
.
original_data_list_files
(
groups
=
groups
)
preprocessed_data_files
=
fs
.
preprocessed_data_list
(
groups
=
groups
)
# read annotation files
annotation_list
=
fs
.
annotation_list
(
groups
=
groups
)
# select a subset of keys to iterate
if
indices
is
not
None
:
index_range
=
range
(
indices
[
0
],
indices
[
1
])
...
...
@@ -56,6 +59,7 @@ def preprocess(preprocessor, groups=None, indices=None, allow_missing_files=Fals
logger
.
info
(
"
- Preprocessing: processing %d data files from directory
'
%s
'
to directory
'
%s
'"
,
len
(
index_range
),
fs
.
directories
[
'
original
'
],
fs
.
directories
[
'
preprocessed
'
])
# iterate over the selected files
for
i
in
index_range
:
preprocessed_data_file
=
str
(
preprocessed_data_files
[
i
])
...
...
@@ -69,8 +73,11 @@ def preprocess(preprocessor, groups=None, indices=None, allow_missing_files=Fals
# create output directory before reading the data file (is sometimes required, when relative directories are specified, especially, including a .. somewhere)
bob
.
io
.
base
.
create_directories_safe
(
os
.
path
.
dirname
(
preprocessed_data_file
))
# get the annotations; might be None
annotations
=
fs
.
get_annotations
(
annotation_list
[
i
])
# call the preprocessor
preprocessed_data
=
preprocessor
(
data
,
N
on
e
)
preprocessed_data
=
preprocessor
(
data
,
annotati
on
s
)
if
preprocessed_data
is
None
:
logger
.
error
(
"
Preprocessing of file
'
%s
'
was not successful
"
,
file_name
)
continue
...
...
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