-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtrain_clap.py
33 lines (27 loc) · 876 Bytes
/
train_clap.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
'''
# @ Author: Yichao Cai
# @ Create Time: 2024-01-19 13:24:13
# @ Description: Training script
'''
import argparse
import torch
from main.trainer import ClipHCLTrainer
from utils.misc import Args, set_manual_seed, load_property
parser = argparse.ArgumentParser()
parser.add_argument("config", help="The path of config file for training.")
args = parser.parse_args()
# loading configs
configs = Args(args.config)
configs.set_device("cuda" if torch.cuda.is_available() else "cpu")
print(configs.device)
classes = []
for dset in configs.datasets:
classes.extend(load_property(f"data/classes/{dset}.yaml"))
configs.set_property("class_names", sorted(list(set(classes))))
# set manual seed
if configs.manual_seed:
set_manual_seed(configs.manual_seed)
print(configs)
# training the disentangled network
trainer = ClipHCLTrainer(configs)
trainer.train()