-
Notifications
You must be signed in to change notification settings - Fork 0
/
eval.py
67 lines (56 loc) · 2.17 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import os
import torch
from lib.dataset import ThreeDPW
from lib.models import VIBE, VIBE_w_HMR
from lib.core.evaluate import Evaluator
from lib.core.config import parse_args
from torch.utils.data import DataLoader
def main(cfg):
print('...Evaluating on 3DPW test set...')
# model = VIBE(
# n_layers=cfg.MODEL.TGRU.NUM_LAYERS,
# batch_size=cfg.TRAIN.BATCH_SIZE,
# seqlen=cfg.DATASET.SEQLEN,
# hidden_size=cfg.MODEL.TGRU.HIDDEN_SIZE,
# pretrained=cfg.TRAIN.PRETRAINED_REGRESSOR,
# add_linear=cfg.MODEL.TGRU.ADD_LINEAR,
# bidirectional=cfg.MODEL.TGRU.BIDIRECTIONAL,
# use_residual=cfg.MODEL.TGRU.RESIDUAL,
# ).to(cfg.DEVICE)
model = VIBE_w_HMR(
n_layers=cfg.MODEL.TGRU.NUM_LAYERS,
batch_size=cfg.TRAIN.BATCH_SIZE,
seqlen=cfg.DATASET.SEQLEN,
hidden_size=cfg.MODEL.TGRU.HIDDEN_SIZE,
pretrained=cfg.TRAIN.PRETRAINED_REGRESSOR,
add_linear=cfg.MODEL.TGRU.ADD_LINEAR,
bidirectional=cfg.MODEL.TGRU.BIDIRECTIONAL,
use_residual=cfg.MODEL.TGRU.RESIDUAL,
) # .to(cfg.DEVICE)
# generator = torch.nn.DataParallel(generator, device_ids=[0, 1, 2, 3])
model.cuda()
# if cfg.TRAIN.PRETRAINED != '' and os.path.isfile(cfg.TRAIN.PRETRAINED):
# #checkpoint = torch.load(cfg.TRAIN.PRETRAINED)
checkpoint = torch.load('/home/yu/Documents/VIBE/results/vibe_tests/20201211Best/model_best.pth.tar')
best_performance = checkpoint['performance']
model.load_state_dict(checkpoint['gen_state_dict'])
# print(f'==> Loaded pretrained model from {cfg.TRAIN.PRETRAINED}...')
print(f'Performance on 3DPW test set {best_performance}')
# else:
# print(f'{cfg.TRAIN.PRETRAINED} is not a pretrained model!!!!')
# exit()
test_db = ThreeDPW(set='test', seqlen=cfg.DATASET.SEQLEN, debug=cfg.DEBUG)
test_loader = DataLoader(
dataset=test_db,
batch_size=cfg.TRAIN.BATCH_SIZE,
shuffle=False,
num_workers=cfg.NUM_WORKERS,
)
Evaluator(
model=model,
device=cfg.DEVICE,
test_loader=test_loader,
).run()
if __name__ == '__main__':
cfg, cfg_file = parse_args()
main(cfg)