end='')

        end = time.time()

        print('\repochs: {:4d}, loss_batch(R=L1):{:.4f}'.format(
            ep, np.mean(loss_it)),
              end='')
        if isAdv:
            print(', loss_gen: {:.4f}, loss_dis: {:.4f}'.format(
                np.mean(loss_gen), np.mean(loss_dis)),
                  end='')
        print(' in {:3.2f}s'.format(end - start))

        # Save model each {opts.save_epoch} epochs
        if ep % opts.save_epoch == 0:
            print('saving model at epoch {:4d}'.format(ep))
            model.save_model(ep)


if __name__ == '__main__':
    # Get parameters
    opts = baseOpt().parse()

    # Build model, and run test
    model, isAdv = setModel(opts.model, opts)

    # Loading a model
    if opts.load_epoch > 0:
        print('Loading model at epoch {:d}'.format(opts.load_epoch))
        model.load_model(opts.load_epoch)
    train_op(model, opts, isAdv)
Exemplo n.º 2
0
        #ambnt_batch = [ambnt_imgs[it]]
        flash_batch = [flash_imgs[it]]
        flash_file = file_list[it]

        # Set inputs of the model and run
        model.set_inputs(flash_batch, None)

        # For the DeepFlash model
        if opts.model == 'DeepFlash':
            flash_bf_batch = [flash_bf_imgs[it]]

            # Setting input and target images filtered
            model.set_filtered_inputs(flash_bf_batch, None)

        model.forward()
        saveimg(results_path, flash_file, model.fake_Y, opts.out_act)
        print('\riter:{:4d}/{:4d}'.format(it + 1, len(flash_imgs)), end='')
    print('\rTesting [{:4d}/{:4d}]: check the results on "{}"'.format(
        it + 1, len(flash_imgs), results_path))


if __name__ == "__main__":
    # Get parameters
    opts = baseOpt().parse()

    # Build model, load, and run test
    print('Testing {} model '.format(opts.model))
    model, _ = setModel(opts, False)

    model.load_model(opts.load_epoch)
    test_op(model, opts)