forked from wywu/ReenactGAN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
30 lines (26 loc) · 904 Bytes
/
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
import time
import os
from options.test_options import TestOptions
from data.data_loader import CreateDataLoader
from models.test_model import TestModel
from util.visualizer import Visualizer
import torch
opt = TestOptions().parse()
opt.nThreads = 1 # test code only supports nThreads = 1
opt.batchSize = 1 # test code only supports batchSize = 1
opt.serial_batches = True # no shuffle
opt.no_flip = True # no flip
data_loader = CreateDataLoader(opt)
dataset = data_loader.load_data()
dataset_size = len(data_loader)
model = TestModel(opt)
visualizer = Visualizer(opt)
print('#testing images = %d' % dataset_size)
for i, data in enumerate(dataset):
model.set_input(data)
model.test()
visuals = model.get_current_visuals()
img_path = model.get_image_paths()
print('%04d: process image... %s' % (i, img_path))
visualizer.save_images_split(visuals, img_path)
print('Done!')