Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.bio.face
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.face
Commits
a9653ef6
Commit
a9653ef6
authored
4 years ago
by
Yannick DAYER
Browse files
Options
Downloads
Patches
Plain Diff
Use read_annotation_file from bob.db
parent
6cad6f98
No related branches found
No related tags found
1 merge request
!106
Vulnerability framework - CSV datasets
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bob/bio/face/config/database/replaymobile.py
+2
-2
2 additions, 2 deletions
bob/bio/face/config/database/replaymobile.py
bob/bio/face/database/replaymobile.py
+18
-36
18 additions, 36 deletions
bob/bio/face/database/replaymobile.py
with
20 additions
and
38 deletions
bob/bio/face/config/database/replaymobile.py
+
2
−
2
View file @
a9653ef6
...
@@ -44,8 +44,8 @@ logger.info(f"Annotations files will be fetched from '{annotations_path}'")
...
@@ -44,8 +44,8 @@ logger.info(f"Annotations files will be fetched from '{annotations_path}'")
logger
.
debug
(
f
"
Instantiation of ReplayMobile bio database with protocol
'
{
protocol
}
'"
)
logger
.
debug
(
f
"
Instantiation of ReplayMobile bio database with protocol
'
{
protocol
}
'"
)
database
=
ReplayMobileBioDatabase
(
database
=
ReplayMobileBioDatabase
(
dataset_protocols
_path
=
dataset_protocol_path
,
protocol_definition
_path
=
dataset_protocol_path
,
protocol
=
protocol
,
protocol
_name
=
protocol
,
data_path
=
data_path
,
data_path
=
data_path
,
data_extension
=
data_extension
,
data_extension
=
data_extension
,
annotations_path
=
annotations_path
,
annotations_path
=
annotations_path
,
...
...
This diff is collapsed.
Click to expand it.
bob/bio/face/database/replaymobile.py
+
18
−
36
View file @
a9653ef6
...
@@ -2,14 +2,14 @@
...
@@ -2,14 +2,14 @@
# Yannick Dayer <yannick.dayer@idiap.ch>
# Yannick Dayer <yannick.dayer@idiap.ch>
from
bob.bio.base.database
import
CSVDataset
,
CSVToSampleLoaderBiometrics
from
bob.bio.base.database
import
CSVDataset
,
CSVToSampleLoaderBiometrics
from
bob.pipelines.
datasets.
sample_loaders
import
AnnotationsLoader
from
bob.pipelines.sample_loaders
import
AnnotationsLoader
from
bob.pipelines.sample
import
DelayedSample
from
bob.pipelines.sample
import
DelayedSample
from
bob.db.base.annotations
import
read_annotation_file
from
bob.extension.download
import
get_file
from
bob.extension.download
import
get_file
from
bob.io.video
import
reader
from
bob.io.video
import
reader
from
bob.extension
import
rc
from
bob.extension
import
rc
import
bob.core
import
bob.core
from
sklearn.base
import
TransformerMixin
,
BaseEstimator
from
sklearn.pipeline
import
make_pipeline
from
sklearn.pipeline
import
make_pipeline
import
functools
import
functools
import
os.path
import
os.path
...
@@ -54,7 +54,7 @@ def load_frame_from_file_replaymobile(file_name, frame, should_flip):
...
@@ -54,7 +54,7 @@ def load_frame_from_file_replaymobile(file_name, frame, should_flip):
image
=
numpy
.
transpose
(
image
,
(
0
,
2
,
1
))
image
=
numpy
.
transpose
(
image
,
(
0
,
2
,
1
))
return
image
return
image
def
read_frame_annotation_file_replaymobile
(
file_name
,
frame
):
def
read_frame_annotation_file_replaymobile
(
file_name
,
frame
,
annotations_type
=
"
json
"
):
"""
Returns the bounding-box for one frame of a video file of replay-mobile.
"""
Returns the bounding-box for one frame of a video file of replay-mobile.
Given an annnotation file location and a frame number, returns the bounding
Given an annnotation file location and a frame number, returns the bounding
...
@@ -72,36 +72,16 @@ def read_frame_annotation_file_replaymobile(file_name, frame):
...
@@ -72,36 +72,16 @@ def read_frame_annotation_file_replaymobile(file_name, frame):
----------
----------
file_name: str
file_name: str
The
complete
annotation file
path and name (with extension
).
The annotation file
name (relative to annotations_path
).
frame: int
frame: int
The video frame index.
The video frame index.
"""
"""
logger
.
debug
(
f
"
Reading annotation file
'
{
file_name
}
'
, frame
{
frame
}
.
"
)
logger
.
debug
(
f
"
Reading annotation file
'
{
file_name
}
'
, frame
{
frame
}
.
"
)
if
not
file_name
:
return
None
if
not
os
.
path
.
exists
(
file_name
):
video_annotations
=
read_annotation_file
(
file_name
,
annotation_type
=
annotations_type
)
raise
IOError
(
f
"
The annotation file
'
{
file_name
}
'
was not found
"
)
# read_annotation_file returns an ordered dict with string keys
return
video_annotations
[
f
"
{
frame
}
"
]
with
open
(
file_name
,
'
r
'
)
as
f
:
# One line is one frame, each line contains a bounding box coordinates
line
=
f
.
readlines
()[
frame
]
positions
=
line
.
split
(
'
'
)
if
len
(
positions
)
!=
4
:
raise
ValueError
(
f
"
The content of
'
{
file_name
}
'
was not correct for frame
{
frame
}
(
{
positions
}
)
"
)
annotations
=
{
'
topleft
'
:
(
float
(
positions
[
1
]),
float
(
positions
[
0
])),
'
bottomright
'
:(
float
(
positions
[
1
])
+
float
(
positions
[
3
]),
float
(
positions
[
0
])
+
float
(
positions
[
2
])
)
}
return
annotations
class
ReplayMobileCSVFrameSampleLoader
(
CSVToSampleLoaderBiometrics
):
class
ReplayMobileCSVFrameSampleLoader
(
CSVToSampleLoaderBiometrics
):
"""
A loader transformer returning a specific frame of a video file.
"""
A loader transformer returning a specific frame of a video file.
...
@@ -194,7 +174,7 @@ class FrameBoundingBoxAnnotationLoader(AnnotationsLoader):
...
@@ -194,7 +174,7 @@ class FrameBoundingBoxAnnotationLoader(AnnotationsLoader):
delayed_attributes
=
dict
(
delayed_attributes
=
dict
(
annotations
=
functools
.
partial
(
annotations
=
functools
.
partial
(
read_frame_annotation_file_replaymobile
,
read_frame_annotation_file_replaymobile
,
file_name
=
annotation_
file
,
file_name
=
f
"
{
self
.
annotation_
directory
}
:
{
x
.
path
}{
self
.
annotation_extension
}
"
,
frame
=
int
(
x
.
frame
),
frame
=
int
(
x
.
frame
),
)
)
),
),
...
@@ -235,10 +215,12 @@ class ReplayMobileBioDatabase(CSVDataset):
...
@@ -235,10 +215,12 @@ class ReplayMobileBioDatabase(CSVDataset):
"""
"""
def
__init__
(
def
__init__
(
self
,
self
,
protocol_name
=
"
bio-
grandtest
"
,
protocol_name
=
"
grandtest
"
,
protocol_definition_path
=
None
,
protocol_definition_path
=
None
,
data_path
=
None
,
data_path
=
None
,
annotation_path
=
None
,
data_extension
=
"
.mov
"
,
annotations_path
=
None
,
annotations_extension
=
"
.json
"
,
**
kwargs
**
kwargs
):
):
if
protocol_definition_path
is
None
:
if
protocol_definition_path
is
None
:
...
@@ -253,27 +235,27 @@ class ReplayMobileBioDatabase(CSVDataset):
...
@@ -253,27 +235,27 @@ class ReplayMobileBioDatabase(CSVDataset):
# Defaults to cwd if config not defined
# Defaults to cwd if config not defined
data_path
=
rc
.
get
(
"
bob.db.replaymobile.directory
"
,
""
)
data_path
=
rc
.
get
(
"
bob.db.replaymobile.directory
"
,
""
)
if
annotation_path
is
None
:
if
annotation
s
_path
is
None
:
# Defaults to {data_path}/faceloc/rect if config not defined
# Defaults to {data_path}/faceloc/rect if config not defined
annotation_path
=
rc
.
get
(
annotation
s
_path
=
rc
.
get
(
"
bob.db.replaymobile.annotation_directory
"
,
"
bob.db.replaymobile.annotation_directory
"
,
os
.
path
.
join
(
data_path
,
"
faceloc/rect/
"
)
os
.
path
.
join
(
data_path
,
"
faceloc/rect/
"
)
)
)
logger
.
info
(
f
"
Database: Loading database definition from
'
{
protocol_definition_path
}
'
.
"
)
logger
.
info
(
f
"
Database: Loading database definition from
'
{
protocol_definition_path
}
'
.
"
)
logger
.
info
(
f
"
Database: Defining data files path as
'
{
data_path
}
'
.
"
)
logger
.
info
(
f
"
Database: Defining data files path as
'
{
data_path
}
'
.
"
)
logger
.
info
(
f
"
Database: Defining annotation files path as
'
{
annotation_path
}
'
.
"
)
logger
.
info
(
f
"
Database: Defining annotation files path as
'
{
annotation
s
_path
}
'
.
"
)
super
().
__init__
(
super
().
__init__
(
protocol_definition_path
,
protocol_definition_path
,
protocol_name
,
protocol_name
,
csv_to_sample_loader
=
make_pipeline
(
csv_to_sample_loader
=
make_pipeline
(
ReplayMobileCSVFrameSampleLoader
(
ReplayMobileCSVFrameSampleLoader
(
dataset_original_directory
=
data_path
,
dataset_original_directory
=
data_path
,
extension
=
"
.mov
"
,
extension
=
data_extension
,
),
),
FrameBoundingBoxAnnotationLoader
(
FrameBoundingBoxAnnotationLoader
(
annotation_directory
=
annotation_path
,
annotation_directory
=
annotation
s
_path
,
annotation_extension
=
"
.face
"
,
annotation_extension
=
annotations_extension
,
),
),
),
),
**
kwargs
**
kwargs
...
...
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