Esempio n. 1
0
    def __init__(self, config):
        super().__init__()
        """
        If only one dataset, then the data set is assumed to be label(there is input_path in CONFIG);
        if there are two datasets, then train is assumed to be net input, label
        :param config:
        :return:
        """
        if config.__contains__("input_path"):
            self.train_np = None
            self.label_np = None
            self.input_path = config["input_path"]
            self.label_path = self.input_path
            self.without_label = True
        else:
            self.train_np = None
            self.label_np = None
            self.train_path = config["train_path"]
            self.label_path = config["label_path"]
            self.without_label = False
        # optional
        self.batch_size = config["batch_size"] if config.__contains__(
            "batch_size") else None
        self.shuffle = config["shuffle"] if config.__contains__(
            "shuffle") else False

        self.processor = DataProcessor()
        self.dataloader = Dataloader()
Esempio n. 2
0
    def __init__(self, config):
        if config.__contains__("input_path"):
            self.test_dnp = None
            self.label_dnp = None
            self.input_path = config["input_path"]
            self.label_path = self.input_path
            self.without_label = True
        else:
            self.test_dnp = None
            self.label_dnp = None
            self.test_path = config["train_path"]
            self.label_path = config["label_path"]
            self.without_label = False

        self.processor = DataProcessor()
        self.dataloader = Dataloader()
Esempio n. 3
0
    def initialization_step(self):
        self.curriter=0
        ## data initialization
        if self.net_input_config == "mr":
            os.chdir(os.path.dirname(__file__))
            mr = sio.loadmat("./mr.mat")["mr"]
            self.net_input,_,_ = DataProcessor().normalization_range(mr.reshape(1,1,self.image_shape[1],self.image_shape[0]).transpose(0,1,3,2))# the shape order has been checked!
        else:
            self.net_input = np.random.randn(1,1,self.image_shape[0],self.image_shape[1])
        os.chdir(os.path.dirname(__file__))
        self.mask = ~sio.loadmat("./u.mat")["u"].reshape(1,1,self.image_shape[1],self.image_shape[0]).transpose(0,1,3,2).astype(np.bool)

        ## net initialization
        self.initial_net(self.model_cofig)
        # x_pre = self.mlem(iters= self.pretrain_iters)
        self.net_train(self.x_0,self.pretrain_epoch)
Esempio n. 4
0
from data.DataProcessor import DataProcessor
from utils.config import config

dp = DataProcessor()

print("Starting augmentation.")

dp.augment_and_save()

print("Finished augmentation. The images were saved to {}".format(
    config.AUGMENTED_TRAIN_WALDO))
Esempio n. 5
0
import numpy as np
from keras.models import load_model

from data.DataProcessor import DataProcessor
from utils.config import config

dp = DataProcessor()

print("Starting precision check.")

# load and preprocess testing data
train_x, train_y, test_x, test_y = dp.load_grayscale()
_, _, test_X, test_Y, _ = dp.preprocess_data(train_x, train_y, test_x, test_y)

model = load_model('version{}_epochs{}_model{}.h5'.format(
    config.VERSION, config.NUM_EPOCHS, config.MODEL_VERSION))

preds_org = model.predict(test_X)
preds = np.round(preds_org - config.THRESHOLD + 0.5)
false_pos = 0
false_neg = 0
total_pos = 0
total_neg = 0
for i in range(0, len(preds)):
    if test_Y[i][1] == 1:
        total_neg += 1
    if test_Y[i][0] == 1:
        total_pos += 1
    if preds[i][0] != test_Y[i][0] or preds[i][1] != test_Y[i][1]:
        if test_Y[i][1] == 1:
            false_pos += 1
Esempio n. 6
0
 def net_train(self,label,end_epoch):
     label,max,min = DataProcessor().normalization_range(label)
     output = self.model.trainer.train_DIP(self.model, label, self.net_input, end_epoch,self.mask)
     return DataProcessor().normalization_range_reverse(output,max,min)