示例#1
0
    def test_cifar10_dcgan_wbgan_gpreal(self):
        """
    Usage:
        export CUDA_VISIBLE_DEVICES=4
        export PORT=6010
        export TIME_STR=1
        export PYTHONPATH=../submodule:.
        python -c "import test_DCGAN; \
          test_DCGAN.test_cifar10_DCGAN().test_cifar10_dcgan_wbgan_gpreal()"

    :return:
    """
        if 'CUDA_VISIBLE_DEVICES' not in os.environ:
            os.environ['CUDA_VISIBLE_DEVICES'] = '5'
        if 'PORT' not in os.environ:
            os.environ['PORT'] = '6011'
        if 'TIME_STR' not in os.environ:
            os.environ['TIME_STR'] = '0'

        # func name
        outdir = os.path.join('results/DCGAN', sys._getframe().f_code.co_name)
        myargs = argparse.Namespace()

        def build_args():
            argv_str = f"""
            --config DCGAN/configs/dcgan_cifar10.yaml
            --command wbgan_gpreal_cifar10
            --resume False 
            --resume_path None 
            --resume_root None 
            --evaluate False --evaluate_path None
            """
            parser = utils.args_parser.build_parser()
            if len(sys.argv) == 1:
                args = parser.parse_args(args=argv_str.split())
            else:
                args = parser.parse_args()
            args = utils.config_utils.DotDict(vars(args))
            return args, argv_str

        args, argv_str = build_args()

        # parse the config json file
        args = utils.config.process_config(outdir=outdir,
                                           config_file=args.config,
                                           resume_root=args.resume_root,
                                           args=args,
                                           myargs=myargs)
        from scripts import dcgan_cifar10
        dcgan_cifar10.run(args=args, myargs=myargs)
        input('End %s' % outdir)
        return
示例#2
0
    def test_cifar10_dcgan_wgan_gpreal_adv(self):
        """
    Usage:
        source activate Peterou_torch_py36
        export CUDA_VISIBLE_DEVICES=1
        export PORT=6107
        export TIME_STR=1
        export PYTHONPATH=../../submodule:..
        python -c "import test_DCGAN; \
          test_DCGAN.test_cifar10_DCGAN().test_cifar10_dcgan_wgan_gpreal_adv()"

    :return:
    """
        if 'CUDA_VISIBLE_DEVICES' not in os.environ:
            os.environ['CUDA_VISIBLE_DEVICES'] = '3'
        if 'PORT' not in os.environ:
            os.environ['PORT'] = '6009'
        if 'TIME_STR' not in os.environ:
            os.environ['TIME_STR'] = '0'

        # func name
        outdir = os.path.join('results/DCGAN', sys._getframe().f_code.co_name)
        myargs = argparse.Namespace()

        def build_args():
            argv_str = f"""
            --config DCGAN/configs/dcgan_cifar10.yaml
            --command wgan_gpreal_adv_cifar10
            --resume False 
            --resume_path None 
            --resume_root None 
            --evaluate False --evaluate_path None
            """
            parser = utils.args_parser.build_parser()
            if len(sys.argv) == 1:
                args = parser.parse_args(args=argv_str.split())
            else:
                args = parser.parse_args()
            args = utils.config_utils.DotDict(vars(args))
            return args, argv_str

        args, argv_str = build_args()

        args.outdir = outdir
        args, myargs = utils.config.setup_args_and_myargs(args=args,
                                                          myargs=myargs)
        from scripts import dcgan_cifar10
        dcgan_cifar10.run(args=args, myargs=myargs)
        input('End %s' % outdir)
        return