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
c0ee7474
Commit
c0ee7474
authored
4 years ago
by
Tiago de Freitas Pereira
Browse files
Options
Downloads
Patches
Plain Diff
Fixed tinyface annotator
parent
3e174653
No related branches found
No related tags found
1 merge request
!112
Feature extractors
Pipeline
#51390
failed
4 years ago
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bob/bio/face/annotator/bobiptinyface.py
+4
-1
4 additions, 1 deletion
bob/bio/face/annotator/bobiptinyface.py
bob/bio/face/test/test_annotators.py
+57
-28
57 additions, 28 deletions
bob/bio/face/test/test_annotators.py
with
61 additions
and
29 deletions
bob/bio/face/annotator/bobiptinyface.py
+
4
−
1
View file @
c0ee7474
...
...
@@ -7,7 +7,7 @@ class BobIpTinyface(Base):
def
__init__
(
self
,
**
kwargs
):
super
(
BobIpTinyface
,
self
).
__init__
(
**
kwargs
)
self
.
tinyface
=
bob
.
ip
.
facedetect
.
tinyface
.
TinyFacesDetector
(
prob_thresh
=
0.5
)
self
.
detector
=
bob
.
ip
.
facedetect
.
tinyface
.
TinyFacesDetector
(
prob_thresh
=
0.5
)
def
annotate
(
self
,
image
,
**
kwargs
):
"""
Annotates an image using tinyface
...
...
@@ -25,6 +25,9 @@ class BobIpTinyface(Base):
Annotations with (topleft, bottomright) keys (or None).
"""
# return the annotations for the first/largest face
annotations
=
self
.
detector
.
detect
(
image
)
if
annotations
is
not
None
:
return
annotations
[
0
]
else
:
...
...
This diff is collapsed.
Click to expand it.
bob/bio/face/test/test_annotators.py
+
57
−
28
View file @
c0ee7474
...
...
@@ -4,34 +4,49 @@ import bob.io.image
from
bob.bio.face.annotator
import
(
BobIpFacedetect
,
BobIpFlandmark
,
min_face_size_validator
)
min_face_size_validator
,
)
from
bob.bio.base.annotator
import
FailSafe
from
bob.bio.face.annotator
import
BobIpMTCNN
from
bob.bio.face.annotator
import
BobIpTinyface
import
numpy
from
bob.bio.base.test.utils
import
is_library_available
face_image
=
bob
.
io
.
base
.
load
(
bob
.
io
.
base
.
test_utils
.
datafile
(
'
testimage.jpg
'
,
'
bob.ip.facedetect
'
)
bob
.
io
.
base
.
test_utils
.
datafile
(
"
testimage.jpg
"
,
"
bob.ip.facedetect
"
)
)
def
_assert_mtcnn
(
annot
):
"""
Verifies that the MTCNN annotations are correct for ``faceimage.jpg``
"""
assert
type
(
annot
)
is
dict
,
annot
assert
[
int
(
x
)
for
x
in
annot
[
'
topleft
'
]]
==
[
68
,
76
],
annot
assert
[
int
(
x
)
for
x
in
annot
[
'
bottomright
'
]]
==
[
344
,
274
],
annot
assert
[
int
(
x
)
for
x
in
annot
[
'
reye
'
]]
==
[
180
,
129
],
annot
assert
[
int
(
x
)
for
x
in
annot
[
'
leye
'
]]
==
[
175
,
220
],
annot
assert
numpy
.
allclose
(
annot
[
'
quality
'
],
0.9998975
),
annot
assert
[
int
(
x
)
for
x
in
annot
[
"
topleft
"
]]
==
[
68
,
76
],
annot
assert
[
int
(
x
)
for
x
in
annot
[
"
bottomright
"
]]
==
[
344
,
274
],
annot
assert
[
int
(
x
)
for
x
in
annot
[
"
reye
"
]]
==
[
180
,
129
],
annot
assert
[
int
(
x
)
for
x
in
annot
[
"
leye
"
]]
==
[
175
,
220
],
annot
assert
numpy
.
allclose
(
annot
[
"
quality
"
],
0.9998975
),
annot
def
_assert_tinyface
(
annot
):
"""
Verifies that the Tinyface annotations are correct for ``faceimage.jpg``
"""
assert
type
(
annot
)
is
dict
,
annot
assert
[
int
(
x
)
for
x
in
annot
[
"
topleft
"
]]
==
[
59
,
57
],
annot
assert
[
int
(
x
)
for
x
in
annot
[
"
bottomright
"
]]
==
[
338
,
284
],
annot
assert
[
int
(
x
)
for
x
in
annot
[
"
reye
"
]]
==
[
162
,
125
],
annot
assert
[
int
(
x
)
for
x
in
annot
[
"
leye
"
]]
==
[
162
,
216
],
annot
def
_assert_bob_ip_facedetect
(
annot
):
assert
annot
[
'
topleft
'
]
==
(
110
,
82
),
annot
assert
annot
[
'
bottomright
'
]
==
(
334
,
268
),
annot
assert
numpy
.
allclose
(
annot
[
'
quality
'
],
39.209601948013685
),
annot
assert
annot
[
"
topleft
"
]
==
(
110
,
82
),
annot
assert
annot
[
"
bottomright
"
]
==
(
334
,
268
),
annot
assert
numpy
.
allclose
(
annot
[
"
quality
"
],
39.209601948013685
),
annot
@is_library_available
(
"
tensorflow
"
)
def
test_mtcnn_annotator
():
...
...
@@ -43,57 +58,71 @@ def test_mtcnn_annotator():
annot_batch
=
mtcnn_annotator
(
batch
)
_assert_mtcnn
(
annot_batch
[
0
])
@is_library_available
(
"
mxnet
"
)
def
test_tinyface_annotator
():
"""
The Tiny face annotator should return the correct annotations.
"""
tinyface_annotator
=
BobIpTinyface
()
batch
=
[
face_image
]
annot_batch
=
tinyface_annotator
(
batch
)
_assert_tinyface
(
annot_batch
[
0
])
def
test_bob_ip_facedetect
():
batch
=
[
face_image
]
annot
=
BobIpFacedetect
()(
batch
)
_assert_bob_ip_facedetect
(
annot
[
0
])
def
test_bob_ip_facedetect_eyes
():
batch
=
[
face_image
]
annot
=
BobIpFacedetect
(
eye_estimate
=
True
)(
batch
)
_assert_bob_ip_facedetect
(
annot
[
0
])
assert
[
int
(
x
)
for
x
in
annot
[
0
][
'
reye
'
]]
==
[
175
,
128
],
annot
assert
[
int
(
x
)
for
x
in
annot
[
0
][
'
leye
'
]]
==
[
175
,
221
],
annot
assert
[
int
(
x
)
for
x
in
annot
[
0
][
"
reye
"
]]
==
[
175
,
128
],
annot
assert
[
int
(
x
)
for
x
in
annot
[
0
][
"
leye
"
]]
==
[
175
,
221
],
annot
def
test_fail_safe
():
annotator
=
FailSafe
(
[
BobIpFacedetect
(
eye_estimate
=
True
)],
required_keys
=
(
'
reye
'
,
'
leye
'
),
[
BobIpFacedetect
(
eye_estimate
=
True
)],
required_keys
=
(
"
reye
"
,
"
leye
"
),
)
batch
=
[
face_image
]
annot
=
annotator
(
batch
)
_assert_bob_ip_facedetect
(
annot
[
0
])
assert
[
int
(
x
)
for
x
in
annot
[
0
][
'
reye
'
]]
==
[
175
,
128
],
annot
assert
[
int
(
x
)
for
x
in
annot
[
0
][
'
leye
'
]]
==
[
175
,
221
],
annot
assert
[
int
(
x
)
for
x
in
annot
[
0
][
"
reye
"
]]
==
[
175
,
128
],
annot
assert
[
int
(
x
)
for
x
in
annot
[
0
][
"
leye
"
]]
==
[
175
,
221
],
annot
def
test_bob_ip_flandmark
():
annotator
=
FailSafe
(
[
BobIpFacedetect
(),
BobIpFlandmark
()],
required_keys
=
(
'
reye
'
,
'
leye
'
),
[
BobIpFacedetect
(),
BobIpFlandmark
()],
required_keys
=
(
"
reye
"
,
"
leye
"
),
)
batch
=
[
face_image
]
annot
=
annotator
(
batch
)
print
(
annot
)
_assert_bob_ip_facedetect
(
annot
[
0
])
assert
[
int
(
x
)
for
x
in
annot
[
0
][
'
reye
'
]]
==
[
183
,
127
],
annot
assert
[
int
(
x
)
for
x
in
annot
[
0
][
'
leye
'
]]
==
[
174
,
223
],
annot
assert
[
int
(
x
)
for
x
in
annot
[
0
][
"
reye
"
]]
==
[
183
,
127
],
annot
assert
[
int
(
x
)
for
x
in
annot
[
0
][
"
leye
"
]]
==
[
174
,
223
],
annot
def
test_min_face_size_validator
():
valid
=
{
'
topleft
'
:
(
0
,
0
),
'
bottomright
'
:
(
32
,
32
),
"
topleft
"
:
(
0
,
0
),
"
bottomright
"
:
(
32
,
32
),
}
assert
min_face_size_validator
(
valid
)
not_valid
=
{
'
topleft
'
:
(
0
,
0
),
'
bottomright
'
:
(
28
,
33
),
"
topleft
"
:
(
0
,
0
),
"
bottomright
"
:
(
28
,
33
),
}
assert
not
min_face_size_validator
(
not_valid
)
not_valid
=
{
'
topleft
'
:
(
0
,
0
),
'
bottomright
'
:
(
33
,
28
),
"
topleft
"
:
(
0
,
0
),
"
bottomright
"
:
(
33
,
28
),
}
assert
not
min_face_size_validator
(
not_valid
)
...
...
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