def train(self, train_generator): x, y = [], [] for i, (image, mask) in enumerate(train_generator): point_generator = PointGeneratorBalanced(mask, self.__patch_count, balance=self.__training_balance) feature_extractor = FeatureExtractor(image, self.__patch_size, point_generator) pixel_extractor = PixelExtractor(mask, point_generator) x.extend(feature_extractor.extract()) y.extend(pixel_extractor.extract()) stdout.write("\rTraining features: %.1f%%" % (100.0 * (i + 1) / train_generator.size)) stdout.flush() stdout.write("\nTrain...") stdout.flush() self.__model.fit(x, y) stdout.write("\rTraining done\n")
def _inner_classify(self, input_image): point_generator = PointGeneratorAll(input_image.shape) feature_extractor = FeatureExtractor(input_image, self.__patch_size, point_generator) return self.__model.predict([*feature_extractor.extract()]).reshape(input_image.shape)