exp_name = args.exp

#get parameters
params = getParams(exp_name)

#set common variables
epochs = params['epochs']
batch_size = params['batch_size']
verbose = params['verbose']
val_to_monitor = params['val_to_monitor']

resetSeed()

#Get data and generators
dh = DataHandler()
tr_images, tr_masks, te_images, te_masks = dh.getData()

train_generator = getGenerator(tr_images, tr_masks,
        augmentation = False, batch_size=batch_size)

val_generator = getGenerator(te_images, te_masks,
        augmentation = False, batch_size=batch_size)

#Get model and add weights
model = getUnet()

#load weights from other problem transfer learning
#model.load_weights('./weights/unet_transfer.h5')

# print(model.summary())
Exemple #2
0
from models.unet import *
from datahandler import DataHandler

import os
import skimage.io as io
from tqdm import tqdm
from math import ceil
# TODO remove this
import warnings
warnings.filterwarnings("ignore")

model = getUnet()
model.load_weights('logs/unet/unet_dice_nobells/unet_dice_nobells_weights.h5')

dh = DataHandler()
images, masks = dh.getData(only_test=True)

# save_path = './data/test_results/'
# for i, img in enumerate(tqdm(images, desc='Saving Imgs')):
#     io.imsave(os.path.join(save_path,"%d_img.png"%i), np.squeeze(img))
#     io.imsave(os.path.join(save_path,"%d_mask.png"%i), np.squeeze(masks[i]))


def resetSeed():
    np.random.seed(1)


def getGenerator(images):
    resetSeed()

    image_datagen = ImageDataGenerator(rescale=1. / 255)