Skip to content

Commit

Permalink
fix opt_with_domain
Browse files Browse the repository at this point in the history
  • Loading branch information
awkrail committed Sep 26, 2024
1 parent 4279ef5 commit 5ffb02b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
11 changes: 7 additions & 4 deletions training/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
5 changes: 2 additions & 3 deletions training/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5ffb02b

Please sign in to comment.