Esempio n. 1
0
os.environ["CUDA_VISIBLE_DEVICES"] = "0"
save_image = True
visible_image = False
start, number = 0, 68
# set path
# data_path = '..\\dataset\\CBSD68' # Windows
data_path = '../dataset/CBSD68'  # Linux
model_name = "DHDN"
load_model_path = '../experiment/model/DHDN_015-0.02.hdf5'
result_path = '../experiment/result/'

# The data, shuffled and split between train and test sets:
x_train, y_train = get_data(data_path, 0.02)
x_train, y_train = x_train / 255, y_train / 255

model = model_getter(model_name, load_model_path)

Path(result_path).mkdir(exist_ok=True, parents=True)
setup_logger('base',
             result_path,
             'test',
             level=logging.INFO,
             screen=True,
             tofile=True)
logger = logging.getLogger('base')
logger.info(f'Test {start} to {start+ number} Model : {load_model_path}')
noise_psnr, denoise_psnr, noise_ssim, denoise_ssim = 0, 0, 0, 0
for index, noise_img in enumerate(x_train[start:start + number]):
    temp_img = divide_image(noise_img, 64)
    denoise_imgs = model.predict(temp_img) * 255
    denoise_img = merge_image(denoise_imgs, noise_img, 64)
Esempio n. 2
0
Path(model_prefix).mkdir(exist_ok=True, parents=True)
model_path = model_prefix + model_name + "_{epoch:03d}-{loss:.2f}.hdf5"
model_checkpoint = ModelCheckpoint(model_path,
                                   save_best_only=True,
                                   save_weights_only=True,
                                   mode='auto')
# tensorboard
log_filepath = '../experiment/keras_log'
tb_cb = TensorBoard(log_dir=log_filepath, write_images=1, histogram_freq=0)
callbacks = [lrs, model_checkpoint, tb_cb]

# create model
# optimization details
adam = Adam(lr=learning_rate)
# model = model_getter(model_name,load_model_path)
model = model_getter(model_name)
model.compile(loss=mean_absolute_error,
              optimizer=adam,
              metrics=['accuracy', psnr_metrics])

mdl = MatDataLoader(data_path, batch_size)

# training
# hostory_temp = model.fit(x_train,y_train,
#                         batch_size,max_epoches,
#                         verbose=1,
#                         callbacks=callbacks,
#                         validation_split=0.1,
#                         shuffle=True)

hostory_temp = model.fit_generator(