Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.pad.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.pad.face
Commits
d718f12f
Commit
d718f12f
authored
7 years ago
by
Olegs NIKISINS
Browse files
Options
Downloads
Patches
Plain Diff
Added temp annotations save option to Batl HLDI
parent
a282657d
No related branches found
No related tags found
1 merge request
!59
Added HLDI for the BATL database, added optional data normalization in FaceCropAlign
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/pad/face/database/batl.py
+28
-18
28 additions, 18 deletions
bob/pad/face/database/batl.py
with
28 additions
and
18 deletions
bob/pad/face/database/batl.py
+
28
−
18
View file @
d718f12f
...
@@ -12,6 +12,8 @@ from batl.utils.data import load_data_config
...
@@ -12,6 +12,8 @@ from batl.utils.data import load_data_config
from
bob.pad.face.preprocessor.FaceCropAlign
import
detect_face_landmarks_in_image
from
bob.pad.face.preprocessor.FaceCropAlign
import
detect_face_landmarks_in_image
import
json
class
BatlPadFile
(
PadFile
):
class
BatlPadFile
(
PadFile
):
"""
"""
A high level implementation of the File class for the BATL
A high level implementation of the File class for the BATL
...
@@ -86,7 +88,7 @@ class BatlPadDatabase(PadDatabase):
...
@@ -86,7 +88,7 @@ class BatlPadDatabase(PadDatabase):
protocol
=
'
grandtest
'
,
protocol
=
'
grandtest
'
,
original_directory
=
rc
[
'
bob.db.batl.directory
'
],
original_directory
=
rc
[
'
bob.db.batl.directory
'
],
original_extension
=
'
.h5
'
,
original_extension
=
'
.h5
'
,
annotations_temp_dir
=
None
,
annotations_temp_dir
=
""
,
landmark_detect_method
=
"
mtcnn
"
,
landmark_detect_method
=
"
mtcnn
"
,
**
kwargs
):
**
kwargs
):
"""
"""
...
@@ -231,36 +233,44 @@ class BatlPadDatabase(PadDatabase):
...
@@ -231,36 +233,44 @@ class BatlPadDatabase(PadDatabase):
return
files
return
files
def
annotations
(
self
,
f
):
def
annotations
(
self
,
f
):
pass
#
if annotations_temp_dir is None:
file_path
=
os
.
path
.
join
(
self
.
annotations_temp_dir
,
f
.
f
.
path
+
"
.json
"
)
video
=
f
.
load
(
self
,
directory
=
self
.
original_directory
,
if
not
os
.
path
.
isfile
(
file_path
):
# no file with annotations
extension
=
self
.
original_extension
,
stream_type
=
"
color
"
,
# TODO: this parameter is currently missing in bob.db.batl, add it there
reference_stream_type
=
"
color
"
,
data_format_config
=
load_data_config
(
pkg_resources
.
resource_filename
(
'
batl.utils
'
,
'
config/idiap_hdf5_data_config.json
'
)),
warp_to_reference
=
False
,
convert_to_rgb
=
False
,
crop
=
None
,
max_frames
=
None
)
annotations
=
{}
video
=
f
.
load
(
self
,
directory
=
self
.
original_directory
,
extension
=
self
.
original_extension
,
stream_type
=
"
color
"
,
# TODO: this parameter is currently missing in bob.db.batl, add it there
reference_stream_type
=
"
color
"
,
data_format_config
=
load_data_config
(
pkg_resources
.
resource_filename
(
'
batl.utils
'
,
'
config/idiap_hdf5_data_config.json
'
)),
warp_to_reference
=
False
,
convert_to_rgb
=
False
,
crop
=
None
,
max_frames
=
None
)
for
idx
,
image
in
enumerate
(
video
):
annotations
=
{}
f
rame_annotations
=
detect_face_landmarks_in_image
(
image
,
method
=
self
.
landmark_detect_method
)
f
or
idx
,
image
in
enumerate
(
video
):
if
frame_annotations
:
frame_annotations
=
detect_face_landmarks_in_image
(
image
,
method
=
self
.
landmark_detect_method
)
annotations
[
str
(
idx
)]
=
frame_annotations
if
frame_annotations
:
return
annotations
annotations
[
str
(
idx
)]
=
frame_annotations
if
self
.
annotations_temp_dir
:
# if directory is not an empty string
with
open
(
file_path
,
'
w
'
)
as
json_file
:
json_file
.
write
(
json
.
dumps
(
annotations
))
else
:
# if file with annotations exists load them from file
with
open
(
file_path
,
'
r
'
)
as
json_file
:
annotations
=
json
.
load
(
json_file
)
return
annotations
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