-
Notifications
You must be signed in to change notification settings - Fork 4
/
test.py
34 lines (30 loc) · 1.38 KB
/
test.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
import os
import time
from options.train_options import TrainOptions
from options.test_options import TestOptions
from models.denseloss_model import *
from util.util import *
from datasets.base_dataset import CustomDatasetDataLoader
from models.base_model import create_model
def test():
opt = TestOptions().parse()
test_data_loader = CustomDatasetDataLoader(opt)
model = create_model(opt)
print(opt)
model.train(False)
val_start_time = time.time()
for i, batch_test_data in enumerate(test_data_loader, start=0):
model.test(batch_test_data,False)
model.save_feature('test', 'test_epoch')
if not opt.retrieval_now:
#print(model.test_features)
model.test_features = model.combine_features(model.test_features)
model.retrieval_evaluation(model.test_features, model.test_result_record['total']['loss_value'].avg, model.test_features['labels'])
print('Test Result:{}'.format(model.generate_message(model.test_result_record)))
val_end_time = time.time()
print('Validation Final Time:{:.6f} \t{}'.format(
val_end_time - val_start_time,
model.generate_message(model.test_result_record)))
model.reset_test_features()
model.reset_test_records()
test()