-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrain_fix_exp.py
More file actions
32 lines (21 loc) · 948 Bytes
/
train_fix_exp.py
File metadata and controls
32 lines (21 loc) · 948 Bytes
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
import os
import __init_paths
import pytorch_lightning as pl
from pytorch_lightning.loggers import WandbLogger
from dataset.FFHQDataset import FFHQDataModule
from options.train_options import TrainOptions
from model.ExpressionModel_static_exp import ExpressionModule
def main():
opts = TrainOptions().parse()
model = ExpressionModule(opts)
dm = FFHQDataModule(opts)
run_name = "Run#3_E1_{}".format(opts.training_stage)
checkpoint_path = os.path.join(os.path.expanduser("~"), "checkpoints", run_name)
os.makedirs(checkpoint_path, exist_ok=True)
wandb_logger = WandbLogger(project="Expression", name=run_name)
trainer = pl.Trainer(max_epochs=opts.max_epoch, gpus=-1, strategy="ddp", logger=wandb_logger,
enable_checkpointing=True, weights_save_path=checkpoint_path,
limit_train_batches=0.20)
trainer.fit(model, dm)
if __name__ == "__main__":
main()