preprocessor.py 644 Bytes
Newer Older
1
from bob.bio.base.preprocessor import Preprocessor
2
3
import numpy
numpy.random.seed(10)
4

5

6
class DummyPreprocessor (Preprocessor):
7
  def __init__(self, return_none=False, probability_of_none=1,  **kwargs):
8
    Preprocessor.__init__(self)
9
    self.return_none = return_none
10
    self.probability_of_none = probability_of_none
11
12
13

  def __call__(self, data, annotation):
    """Does nothing, simply converts the data type of the data, ignoring any annotation."""
14
    if self.return_none:
15
16
      return numpy.random.choice([None, data], p=[self.probability_of_none, 1-self.probability_of_none])
      
17
18
    return data

19

20
preprocessor = DummyPreprocessor()