Ejemplo n.º 1
0
    def get_logger(self, opts):
        self.logger = Logger(self.run_dir, self.epoch, self.run_name)
        self.logger.add_iter_visual_log(self.get_visuals, 1, "test_visuals")
        self.logger.add_metric_log(self.get_pairs,
            (("ssim", self.get_metric(ssim)), ("psnr", self.get_metric(psnr))))

        return self.logger
Ejemplo n.º 2
0
 def get_logger(self, opts):
     self.logger = Logger(self.run_dir, self.epoch, self.run_name)
     return self.logger
Ejemplo n.º 3
0
    dataset_opts = opts['dataset']
    train_dataset = get_dataset(**dataset_opts)
    train_loader = DataLoader(train_dataset,
        batch_size=opts["batch_size"], num_workers=opts['num_workers'], shuffle=True)
    train_loader = add_post(train_loader, get_image)

    # Get checkpoint
    if opts['last_epoch'] == 'last':
        checkpoint, start_epoch = get_last_checkpoint(run_dir)
    else:
        start_epoch = opts['last_epoch']
        checkpoint = path.join(run_dir, "net_{}".format(start_epoch))
        if type(start_epoch) is not int: start_epoch = 0

    # Get model
    model = ADNTrain(opts['learn'], opts['loss'], **opts['model'])
    if opts['use_gpu']: model.cuda()
    if path.isfile(checkpoint): model.resume(checkpoint)

    # Get logger
    logger = Logger(run_dir, start_epoch, args.run_name)
    logger.add_loss_log(model.get_loss, opts["print_step"], opts['window_size'])
    logger.add_iter_visual_log(model.get_visuals, opts['visualize_step'], "train_visuals")
    logger.add_save_log(model.save, opts['save_step'])

    # Train the model
    for epoch in range(start_epoch, opts['num_epochs']):
        for data in logger(train_loader):
            model.optimize(*data)
        model.update_lr()