Commit bef0c3e1 authored by Amir MOHAMMADI's avatar 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
......@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment