Ejemplo n.º 1
0
from data.custom_dataset_data_loader import CreateDataLoader
from models.models import create_model
from util.visualizer import Visualizer
from pdb import set_trace as st
from util import html
from util.metrics import *
from PIL import Image
import time

opt = TestOptions().parse()
opt.nThreads = 1  # test code only supports nThreads = 1
opt.batchSize = 1  # test code only supports batchSize = 1
opt.serial_batches = True  # no shuffle
opt.no_flip = True  # no flip

data_loader = CreateDataLoader(opt)
dataset = data_loader.load_data()
model = create_model(opt)
visualizer = Visualizer(opt)
# create website
web_dir = os.path.join(opt.results_dir, opt.name,
                       '%s_%s' % (opt.phase, opt.which_epoch))
webpage = html.HTML(
    web_dir, 'Experiment = %s, Phase = %s, Epoch = %s' %
    (opt.name, opt.phase, opt.which_epoch))
# test

counter = 0

dataset_size = len(data_loader)
print('#test images = %d' % dataset_size)
Ejemplo n.º 2
0
                errors = model.get_current_errors()
                t = (time.time() - iter_start_time) / opt.batchSize
                visualizer.print_current_errors(epoch, epoch_iter, errors, t)
                if opt.display_id > 0:
                    visualizer.plot_current_errors(epoch, float(epoch_iter)/dataset_size, opt, errors)

            if total_steps % opt.save_latest_freq == 0:
                print('saving the latest model (epoch %d, total_steps %d)' % (epoch, total_steps))
                model.save('latest')

        if psnr_all/cnt >28.: ## negelete some unimportant checkpoint
            saving_flag=1

        if epoch % opt.save_epoch_freq == 0 or saving_flag:
            print('saving the model at the end of epoch %d, iters %d' %  (epoch, total_steps))
            model.save('latest')
            model.save(epoch)
            saving_flag = 0

        print('End of epoch %d / %d \t Time Taken: %d sec  avg.psnr=%f dB' %
            (epoch, opt.niter + opt.niter_decay, time.time() - epoch_start_time, psnr_all/cnt))

        if epoch > opt.niter:
            model.update_learning_rate()
			
opt = TrainOptions().parse()
data_loader = CreateDataLoader(opt)
model = create_model(opt)
visualizer = Visualizer(opt)
train(opt, data_loader, model, visualizer)