Exemplo n.º 1
0
    def load_custom_dataset(self, train_path, val_path):
        """
        Loads the custom dataset from train_path and val_path.
        """
        # Loads training dataset from train_path
        with open(train_path, 'rb') as f:
            load_dict = pickle.load(f)
        self.y = load_dict['y']
        self.x_true = load_dict['x_true']
        self.fbp = load_dict['tv']
        for idx in range(self.fbp.shape[0]):
            self.fbp[idx, :, :, 0] = ut.scale_to_unit_intervall(self.fbp[idx, :, :, 0])
        print("STARTING FROM TV")
        print(f"self.fbp.max(): {self.fbp.max()}")
        print(f"self.fbp.min(): {self.fbp.min()}")

        self.batch_indices = np.arange(start=0, stop=self.x_true.shape[0], dtype=np.int)
        np.random.shuffle(self.batch_indices)

        # Loads validation dataset from validation path
        with open(val_path, 'rb') as f:
            val_load_dict = pickle.load(f)
        self.val_y = val_load_dict['y']
        self.val_x_true = val_load_dict['x_true']
        self.val_fbp = val_load_dict['tv']
        for idx in range(self.val_fbp.shape[0]):
            self.val_fbp[idx, :, :, 0] = ut.scale_to_unit_intervall(self.val_fbp[idx, :, :, 0])
        print("STARTING FROM TV")
        print(f"self.val_fbp.max(): {self.val_fbp.max()}")
        print(f"self.val_fbp.min(): {self.val_fbp.min()}")
        self.val_size = self.val_y.shape[0]
 def load_data(self, training_data= True):
     output = np.zeros((128, 128, 1))
     if training_data:
         pic = self.random_phantom(spc= self.space)
         output[..., 0] = ut.scale_to_unit_intervall(pic)
     else:
         pic = odl.phantom.shepp_logan(self.space, True)
         output[..., 0] = ut.scale_to_unit_intervall(pic)
     return output
 def load_data(self, training_data=True):
     pic = self.random_phantom(spc=self.space)
     output = np.zeros((128, 128, 1))
     output[..., 0] = ut.scale_to_unit_intervall(pic)
     return output
 def reshape_pic(self, pic):
     pic = ut.normalize_image(pic)
     pic = imresize(pic, [128, 128])
     pic = ut.scale_to_unit_intervall(pic)
     return pic
 def reshape_pic(self, pic):
     pic = ut.normalize_image(pic)
     # pic = imresize(pic, [128, 128])
     pic = np.array(Image.fromarray(pic).resize(size=(128, 128)))
     pic = ut.scale_to_unit_intervall(pic)
     return pic