From 5ffb02b5cd11eb8875fac7232c12b54e3551767c Mon Sep 17 00:00:00 2001 From: awkrail Date: Thu, 26 Sep 2024 19:52:45 +0900 Subject: [PATCH] fix opt_with_domain --- training/config.py | 11 +++++++---- training/train.py | 5 ++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/training/config.py b/training/config.py index cc76c53..2575ec7 100755 --- a/training/config.py +++ b/training/config.py @@ -20,6 +20,7 @@ import argparse import shutil import yaml +import copy from lighthouse.common.utils.basic_utils import mkdirp, load_json, save_json, make_zipfile, dict_to_markdown from easydict import EasyDict @@ -125,10 +126,12 @@ def parse(self): self.opt.t_feat_dir_pretrain_eval = t_feat_dir_pretrain_eval def change_save_path_with_domain(self, domain): - self.opt.results_dir = os.path.join(self.opt.results_dir, domain) - self.opt.ckpt_filepath = os.path.join(self.opt.results_dir, self.opt.ckpt_filename) - self.opt.train_log_filepath = os.path.join(self.opt.results_dir, self.opt.train_log_filename) - self.opt.eval_log_filepath = os.path.join(self.opt.results_dir, self.opt.eval_log_filename) + opt_with_domain = copy.deepcopy(self.opt) + opt_with_domain.results_dir = os.path.join(opt_with_domain.results_dir, domain) + opt_with_domain.ckpt_filepath = os.path.join(opt_with_domain.results_dir, opt_with_domain.ckpt_filename) + opt_with_domain.train_log_filepath = os.path.join(opt_with_domain.results_dir, opt_with_domain.train_log_filename) + opt_with_domain.eval_log_filepath = os.path.join(opt_with_domain.results_dir, opt_with_domain.eval_log_filename) + return opt_with_domain def clean_and_makedirs(self): if 'results_dir' not in self.opt: diff --git a/training/train.py b/training/train.py index c336dc3..6125eaf 100755 --- a/training/train.py +++ b/training/train.py @@ -298,9 +298,8 @@ def check_valid_combination(dataset, feature): if 'domains' in option_manager.option: for domain in option_manager.option.domains: - option_manager.change_save_path_with_domain(domain) - opt = option_manager.option - main(opt, resume=args.resume, domain=domain) + opt_with_domain = option_manager.change_save_path_with_domain(domain) + main(opt_with_domain, resume=args.resume, domain=domain) else: opt = option_manager.option main(opt, resume=args.resume)