-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy patheval.py
38 lines (29 loc) · 1.06 KB
/
eval.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
34
35
36
37
38
import torch
import logging
from pytorch_lightning import Trainer
from argparse import ArgumentParser
from models.model import AffWild2VA
logging.basicConfig(level=logging.INFO)
def main(hparams):
# init module
model = AffWild2VA(hparams)
# make it easier for us to add new params
checkpoint = torch.load(hparams.checkpoint, map_location=lambda storage, loc: storage)
model.load_state_dict(checkpoint['state_dict'])
print ('Loaded pretrained weights')
trainer = Trainer(
gpus=hparams.gpus,
nb_gpu_nodes=hparams.nodes,
distributed_backend='ddp' if hparams.distributed else 'dp'
)
trainer.test(model)
if __name__ == '__main__':
parser = ArgumentParser(add_help=False)
parser.add_argument('--gpus', type=str, default='2')
parser.add_argument('--nodes', type=int, default=1)
parser.add_argument('--checkpoint', type=str, default='')
# give the module a chance to add own params
parser = AffWild2VA.add_model_specific_args(parser)
# parse params
hparams = parser.parse_args()
main(hparams)