forked from hjf1997/DualSTN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
36 lines (27 loc) · 1.39 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
35
36
# implemented by p0werHu
from options.test_options import TestOptions
from data import create_dataset
from models import create_model
import time
from utils.visualizer import Visualizer
if __name__ == '__main__':
opt, model_config = TestOptions().parse() # get training options
dataset = create_dataset(opt) # create a dataset given opt.dataset_mode and other options
dataset_size = len(dataset) # get the number of samples in the dataset.
print('The number of training samples = %d' % dataset_size)
model = create_model(opt, model_config) # create a model given opt.model and other options
model.setup(opt) # regular setup: load and print networks; create schedulers
visualizer = Visualizer(opt) # create a visualizer that display/save and plots
total_iters = 0 # the total number of training iterations
model.eval()
val_start_time = time.time()
for i, data in enumerate(dataset): # inner loop within the test dataset
model.set_input(data) # unpack data from dataset and apply preprocessing
model.test()
model.cache_results() # store current batch results
model.compute_visuals() # visualization
t_val = time.time() - val_start_time
model.compute_metrics()
metrics = model.get_current_metrics()
visualizer.print_current_metrics(-1, total_iters, metrics, t_val)
model.save_data()