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
9a08b32a
Commit
9a08b32a
authored
3 years ago
by
Yannick DAYER
Browse files
Options
Downloads
Patches
Plain Diff
One frame is one sample
parent
f1d3573d
No related branches found
No related tags found
1 merge request
!106
Vulnerability framework - CSV datasets
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/bio/face/database/replaymobile.py
+9
-11
9 additions, 11 deletions
bob/bio/face/database/replaymobile.py
with
9 additions
and
11 deletions
bob/bio/face/database/replaymobile.py
+
9
−
11
View file @
9a08b32a
...
@@ -8,14 +8,14 @@ from bob.db.base.annotations import read_annotation_file
...
@@ -8,14 +8,14 @@ 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
from
sklearn.pipeline
import
make_pipeline
from
sklearn.pipeline
import
make_pipeline
import
functools
import
functools
import
os.path
import
os.path
import
logging
import
numpy
import
numpy
logger
=
bob
.
core
.
log
.
setup
(
"
bob.bio.face
"
)
logger
=
logging
.
getLogger
(
__name__
)
def
load_frame_from_file_replaymobile
(
file_name
,
frame
,
should_flip
):
def
load_frame_from_file_replaymobile
(
file_name
,
frame
,
should_flip
):
"""
Loads a single frame from a video file for replay-mobile.
"""
Loads a single frame from a video file for replay-mobile.
...
@@ -42,7 +42,7 @@ def load_frame_from_file_replaymobile(file_name, frame, should_flip):
...
@@ -42,7 +42,7 @@ def load_frame_from_file_replaymobile(file_name, frame, should_flip):
images: 3D numpy array
images: 3D numpy array
The frame of the video in bob format (channel, height, width)
The frame of the video in bob format (channel, height, width)
"""
"""
logger
.
debug
(
f
"
Extract
ing frame
{
frame
}
from
'
{
file_name
}
'"
)
logger
.
debug
(
f
"
Read
ing frame
{
frame
}
from
'
{
file_name
}
'"
)
video_reader
=
reader
(
file_name
)
video_reader
=
reader
(
file_name
)
image
=
video_reader
[
frame
]
image
=
video_reader
[
frame
]
# Image captured by the 'mobile' device are flipped vertically.
# Image captured by the 'mobile' device are flipped vertically.
...
@@ -58,7 +58,7 @@ class ReplayMobileCSVFrameSampleLoader(CSVToSampleLoaderBiometrics):
...
@@ -58,7 +58,7 @@ 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.
This is specifically tailored for replay-mobile. It uses a specific loader
This is specifically tailored for replay-mobile. It uses a specific loader
that
takes the capturing device as input
.
that
processes the `should_flip` metadata to correctly orient the frames
.
"""
"""
def
__init__
(
def
__init__
(
self
,
self
,
...
@@ -75,7 +75,7 @@ class ReplayMobileCSVFrameSampleLoader(CSVToSampleLoaderBiometrics):
...
@@ -75,7 +75,7 @@ class ReplayMobileCSVFrameSampleLoader(CSVToSampleLoaderBiometrics):
self
.
references_list
=
[]
self
.
references_list
=
[]
def
convert_row_to_sample
(
self
,
row
,
header
):
def
convert_row_to_sample
(
self
,
row
,
header
):
"""
Creates a
set of
sample
s
given a row of the CSV protocol definition.
"""
Creates a sample given a row of the CSV protocol definition.
"""
"""
fields
=
dict
([[
str
(
h
).
lower
(),
r
]
for
h
,
r
in
zip
(
header
,
row
)])
fields
=
dict
([[
str
(
h
).
lower
(),
r
]
for
h
,
r
in
zip
(
header
,
row
)])
...
@@ -102,18 +102,16 @@ class ReplayMobileCSVFrameSampleLoader(CSVToSampleLoaderBiometrics):
...
@@ -102,18 +102,16 @@ class ReplayMobileCSVFrameSampleLoader(CSVToSampleLoaderBiometrics):
else
:
else
:
kwargs
[
"
references
"
]
=
self
.
references_list
kwargs
[
"
references
"
]
=
self
.
references_list
# One row leads to multiple samples (different frames)
# One row leads to multiple samples (different frames)
all_samples
=
[
DelayedSample
(
return
DelayedSample
(
functools
.
partial
(
functools
.
partial
(
load_frame_from_file_replaymobile
,
load_frame_from_file_replaymobile
,
file_name
=
os
.
path
.
join
(
self
.
dataset_original_directory
,
fields
[
"
path
"
]
+
self
.
extension
),
file_name
=
os
.
path
.
join
(
self
.
dataset_original_directory
,
fields
[
"
path
"
]
+
self
.
extension
),
frame
=
frame
,
frame
=
int
(
fields
[
"
frame
"
])
,
should_flip
=
fields
[
"
should_flip
"
]
==
"
TRUE
"
,
should_flip
=
fields
[
"
should_flip
"
]
==
"
TRUE
"
,
),
),
key
=
f
"
{
fields
[
'
id
'
]
}
_
{
frame
}
"
,
key
=
fields
[
'
id
'
],
frame
=
frame
,
**
kwargs
,
**
kwargs
,
)
for
frame
in
range
(
12
,
251
,
24
)]
)
return
all_samples
def
read_frame_annotation_file_replaymobile
(
file_name
,
frame
,
annotations_type
=
"
json
"
):
def
read_frame_annotation_file_replaymobile
(
file_name
,
frame
,
annotations_type
=
"
json
"
):
...
...
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