setup.py 584 字节
Newer Older
L
LielinJiang 已提交
1 2 3 4 5 6 7 8 9
import os
import time
import paddle

from .logger import setup_logger


def setup(args, cfg):
    if args.evaluate_only:
L
LielinJiang 已提交
10 11 12
        cfg.is_train = False
    else:
        cfg.is_train = True
L
LielinJiang 已提交
13 14

    cfg.timestamp = time.strftime('-%Y-%m-%d-%H-%M', time.localtime())
L
LielinJiang 已提交
15 16
    cfg.output_dir = os.path.join(cfg.output_dir,
                                  str(cfg.model.name) + cfg.timestamp)
L
LielinJiang 已提交
17 18 19 20 21

    logger = setup_logger(cfg.output_dir)

    logger.info('Configs: {}'.format(cfg))

L
LielinJiang 已提交
22 23 24 25
    if paddle.is_compiled_with_cuda():
        paddle.set_device('gpu')
    else:
        paddle.set_device('cpu')