Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bob
bob.bio.face
Commits
bef0c3e1
Commit
bef0c3e1
authored
Mar 09, 2018
by
Amir MOHAMMADI
Browse files
Handle cases when annotations is None in FaceCrop
Fixes
#28
parent
3fac20b4
Pipeline
#17497
passed with stage
in 23 minutes and 52 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
bob/bio/face/preprocessor/FaceCrop.py
View file @
bef0c3e1
...
...
@@ -19,10 +19,14 @@
import
bob.ip.base
import
numpy
import
logging
from
.Base
import
Base
from
bob.bio.base.preprocessor
import
Preprocessor
logger
=
logging
.
getLogger
(
__name__
)
class
FaceCrop
(
Base
):
"""Crops the face according to the given annotations.
...
...
@@ -144,8 +148,6 @@ class FaceCrop (Base):
face : 2D :py:class:`numpy.ndarray` (float)
The cropped face.
"""
if
self
.
fixed_positions
is
not
None
:
annotations
=
self
.
fixed_positions
if
annotations
is
None
:
raise
ValueError
(
"Cannot perform image cropping since annotations are not given, and no fixed annotations are specified."
)
...
...
@@ -202,6 +204,12 @@ class FaceCrop (Base):
face : 2D :py:class:`numpy.ndarray`
The cropped face.
"""
if
self
.
fixed_positions
is
not
None
:
annotations
=
self
.
fixed_positions
if
not
annotations
:
logger
.
warn
(
"Cannot crop face without annotations. Returning None."
)
return
None
# convert to the desired color channel
image
=
self
.
color_channel
(
image
)
# crop face
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment