#parser.add_argument('-cfg', '--cfg', default='deepmedic_ce_50_50_check', type=str) parser.add_argument('-cfg', '--cfg', default='deepmedic_ce_50_50_redo', type=str) #parser.add_argument('-cfg', '--cfg', default='deepmedic_ce_50_50_c25_redo', type=str) #parser.add_argument('-cfg', '--cfg', default='deepmedic_ce_50_50_all', type=str) parser.add_argument('-gpu', '--gpu', default='0', type=str) parser.add_argument('-out', '--out', default='', type=str) path = os.path.dirname(__file__) ## parse arguments args = parser.parse_args() args = Parser(args.cfg, log='train').add_args(args) args.gpu = str(args.gpu) ckpts = args.makedir() resume = os.path.join(ckpts, 'model_last.tar') if not args.resume and os.path.exists(resume): args.resume = resume def main(): # setup environments and seeds os.environ['CUDA_VISIBLE_DEVICES'] = args.gpu torch.manual_seed(args.seed) torch.cuda.manual_seed(args.seed) random.seed(args.seed) np.random.seed(args.seed)
from models import criterions from data import datasets from data.dataloader import DataLoader from utils import Parser path = os.path.dirname(__file__) cfg_name = 'deepmedic' mode = 'train' args = Parser().add_cfg(cfg_name) ckpts = args.getdir() args.gpu = str(args.gpu) args.gpu = '0' out_dir = os.path.join('output', cfg_name, mode) if not os.path.exists(out_dir): os.makedirs(out_dir) # setup logs log = os.path.join(out_dir, 'log.txt') fmt = '%(asctime)s %(message)s' logging.basicConfig(level=logging.INFO, format=fmt, filename=log) console = logging.StreamHandler() console.setLevel(logging.INFO) console.setFormatter(logging.Formatter(fmt)) logging.getLogger('').addHandler(console)