def _load_iam_paragraphs():
    print('Loading IAM paragraph crops and ground truth from image files...')
    images = []
    gt_images = []
    ids = []
    for filename in CROPS_DIRNAME.glob('*.jpg'):
        id_ = filename.stem
        image = util.read_image(filename, grayscale=True)
        image = 1. - image / 255

        gt_filename = GT_DIRNAME / f'{id_}.png'
        gt_image = util.read_image(gt_filename, grayscale=True)

        images.append(image)
        gt_images.append(gt_image)
        ids.append(id_)
    images = np.array(images).astype(np.float32)
    gt_images = util.to_categorical(np.array(gt_images), 3).astype(np.uint8)
    return images, gt_images, np.array(ids)
Beispiel #2
0
 def y_test(self):
     return to_categorical(self.y_test_int, self.num_classes)
Beispiel #3
0
 def y_train(self):
     return to_categorical(self.y_train_int, self.num_classes)
Beispiel #4
0
def convert_strings_to_categorical_labels(labels, mapping):
    return np.array([
        to_categorical([mapping[c] for c in label], num_classes=len(mapping))
        for label in labels
    ])
 def y_test(self):
     """Return y_test"""
     return util.to_categorical(self.y_test_int, self.num_classes)
 def y_train(self):
     """Return y_train"""
     return util.to_categorical(self.y_train_int, self.num_classes)