Пример #1
0
    def _predict_patches(self, dataset, batch_size):
        '''
        Using the params.pkl or instantiated model to create patch predictions.
        '''
        dim = self.dataset_config.output_dim
        compute_output = util.create_predictor(dataset, self.model_config, self.params, batch_size)
        result_output, result_label = util.batch_predict(compute_output, dataset, dim, batch_size)

        return result_output, result_label
Пример #2
0
    def _predict_patches(self, dataset, batch_size):
        '''
        Using the params.pkl or instantiated model to create patch predictions.
        '''
        dim = self.dataset_config.output_dim
        compute_output = util.create_predictor(dataset, self.model_config,
                                               self.params, batch_size)
        result_output, result_label = util.batch_predict(
            compute_output, dataset, dim, batch_size)

        return result_output, result_label
Пример #3
0
    def visualize(self, image_path, batch_size, best_trade_off=0.1):
        dataset, dim = self.create_data_from_image(image_path)

        compute_output = util.create_predictor(dataset, self.model_config, self.model_params, batch_size)
        predictions, labels = util.batch_predict(compute_output, dataset, self.dim_label, batch_size)
        image = self.combine_to_image(predictions, dim)

        #Need to have Mass_road structure TODO: argument
        dir = os.path.abspath(image_path + "../../../")
        #TODO: not the same extension for labels and data. In the case of MASS.
        file_ext = os.path.basename(image_path).split('.')[-1]
        label_ext = os.listdir(dir + "/labels/")[0].split('.')[-1]
        label_path = dir + "/labels/" + os.path.basename(image_path).split('.')[-2] + "." + label_ext
        label_image = Image.open(label_path, 'r')
        raw_image =  Image.open(image_path, 'r')
        hit_image = self._create_hit_image(image, raw_image, label_image , best_trade_off)
        return image, hit_image, raw_image, label_image