Example #1
0
 def _flow_on_training(self):
     # get minibatch indices
     with self.lock:
         index_array, current_index, current_batch_size = next(
             self.index_generator)
     image_batch = np.array(self.x[index_array])
     image_batch = normalize(image_batch, self.normalize_mode)
     # label_batch = np.array(self.y[index_array])
     return image_batch
def preprocessing(x, target_size=None):
    image = x.convert('L')

    if target_size is not None and target_size != image.size:
        image = image.resize(target_size, Image.BILINEAR)

    image_array = np.asarray(image)
    image_array = normalize(image_array)

    return image_array
def load_image(path, channel=None):
    """
    :param paths: (channel, ) string list
    :param target_size:
    :return:
    """

    image_array = np.asarray(Image.open(path))
    image_array = normalize(image_array)
    split_array = np.array(np.split(image_array, channel, axis=1))
    image_array = split_array.transpose((1, 2, 0))
    return image_array
Example #4
0
    def _flow_on_test(self):
        # create indices
        indexes = np.arange(self.n)

        # calculate steps per a test
        steps = self.n // self.batch_size
        if self.n % self.batch_size != 0:
            steps += 1

        # yield loop
        for i in range(steps):
            index_array = indexes[i * self.batch_size:(i + 1) *
                                  self.batch_size]
            image_batch = self.x[index_array]
            image_batch = normalize(image_batch, self.normalize_mode)
            # label_batch = self.y[index_array]
            yield image_batch