Esempio n. 1
0
File: run.py Progetto: LoSealL/srcnn
else:
    optimizer = 'adam'
if 'loss' in param:
    loss = param['loss']
else:
    loss = {'name': 'mse'}
if output_format.upper() == 'RGB':
    export_bgr = False
else:
    export_bgr = True

expt = Experiment(scale=param['scale'],
                  channel=channel,
                  build_model=build_model,
                  optimizer=optimizer,
                  loss=loss,
                  lr_sub_size=param['lr_sub_size'],
                  lr_sub_stride=param['lr_sub_stride'],
                  random=random,
                  save_dir=Path('./results') / save_dir)

if args.export_only:
    expt.export_pb_model(['input_lr'], ['output_hr'],
                         Path('./results') / save_dir / 'model.pb', export_bgr)
    exit()

# Training
expt.train(train_set=param['train_set'],
           val_set=param['val_set'],
           epochs=param['epochs'],
           batch_size=param['batch'],
Esempio n. 2
0
File: run.py Progetto: zfang92/srcnn
from toolbox.image import bicubic_resize

# Model
scale = 3
model = espcn(c=1, f1=9, f2=1, f3=5, n1=64, n2=32)
model.summary()

# Data
train_set = '91-image'
val_set = 'Set5'
test_sets = ['Set5', 'Set14']
preprocess = partial(bicubic_resize, size=scale)
load_set = partial(load_set,
                   sub_size=11,
                   sub_stride=5,
                   scale=scale,
                   channel=0,
                   preprocess=preprocess)

# Training
experiment = Experiment(scale=scale,
                        model=model,
                        preprocess=preprocess,
                        load_set=load_set,
                        save_dir='.')
experiment.train(train_set=train_set, val_set=val_set, epochs=500, resume=True)

# Evaluation
for test_set in test_sets:
    experiment.test(test_set=test_set)
Esempio n. 3
0
parser = argparse.ArgumentParser()
parser.add_argument('param_file', type=Path)
args = parser.parse_args()
param = json.load(args.param_file.open())

# Model
scale = param['scale']
build_model = partial(get_model(param['model']['name']),
                      **param['model']['params'])
if 'optimizer' in param:
    optimizer = getattr(optimizers, param['optimizer']['name'].lower())
    optimizer = optimizer(**param['optimizer']['params'])
else:
    optimizer = 'adam'

# Data
load_set = partial(load_set,
                   lr_sub_size=param['lr_sub_size'],
                   lr_sub_stride=param['lr_sub_stride'])

# Training
expt = Experiment(scale=param['scale'], load_set=load_set,
                  build_model=build_model,optimizer=optimizer,
                  save_dir=param['save_dir'])
expt.train(train_set=param['train_set'], val_set=param['val_set'],
           epochs=param['epochs'], resume=True)

# Evaluation
for test_set in param['test_sets']:
    expt.test(test_set=test_set)
Esempio n. 4
0
# Model
scale = param['scale']
build_model = partial(get_model(param['model']['name']),
                      **param['model']['params'])
if 'optimizer' in param:
    optimizer = getattr(optimizers, param['optimizer']['name'].lower())
    optimizer = optimizer(**param['optimizer']['params'])
else:
    optimizer = 'adam'

# Data
load_set = partial(load_set_same_size,
                   lr_sub_size=param['lr_sub_size'],
                   lr_sub_stride=param['lr_sub_stride'])

# Training
expt = Experiment(scale=param['scale'],
                  load_set=load_set,
                  build_model=build_model,
                  optimizer=optimizer,
                  save_dir=param['save_dir'])
expt.train(train_set=param['train_set'],
           val_set=param['val_set'],
           epochs=param['epochs'],
           resume=True)

# Evaluation
# for test_set in param['test_sets']:
#     expt.test(test_set=test_set)
Esempio n. 5
0
def get_experiment(parameters):
    return Experiment(parameters)