forked from kdabi/CS698-cartoon-painter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
executable file
·81 lines (74 loc) · 2.7 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
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import time
import os
from pix2pix import Pix2Pix
from data.custom_dataset_data_loader import CustomDatasetDataLoader
from test_model import TestModel
from util.visualizer import Visualizer
from util import html
class Options():
def __init__(self):
# super(Options, self).__init__()
self.batchSize = 1
self.beta1 = 0.5
self.continue_train = False
self.dataroot = "/data/kdabi/CS698O/Autopainter/CS698-cartoon-painter/Dataset_Generator"
self.display_freq = 100
self.display_id = 1
self.display_port = 8097
self.display_single_pane_ncols = 0
self.display_winsize = 256
self.epoch_count = 1
self.fineSize = 256
self.identity = 0.0
self.input_nc = 3
self.isTrain = False
self.lambda_A = 100.0
self.lambda_B = 10.0
self.loadSize = 286
self.lr = 0.0002
self.lr_decay_iters = 50
self.max_dataset_size = 10000000
self.model = "featureloss"
self.nThreads = 1
self.n_layers_D = 3
self.name = "facades_featureloss"
self.ndf = 64
self.ngf = 64
self.niter = 100
self.niter_decay = 100
self.no_dropout = False
self.no_flip = True
self.no_html = False
self.no_lsgan = True
self.output_nc = 3
self.phase = "test"
self.pool_size = 0
self.print_freq = 100
self.resize_or_crop = "resize_and_crop"
self.save_epoch_freq = 5
self.save_latest_freq = 5000
self.serial_batches = True
self.which_direction = "BtoA"
self.which_epoch = "latest"
self.how_many = 106 # number of images on which testModel will run
self.checkpoints_dir = "/data/kdabi/CS698O/Autopainter/CS698-cartoon-painter/saved_models"
self.results_dir = "/data/kdabi/CS698O/Autopainter/CS698-cartoon-painter/saved_models"
opt = Options()
# data_loader = CreatDataLoader(opt)
data_loader = CustomDatasetDataLoader()
data_loader.initialize(opt)
dataset = data_loader.load_data()
model = TestModel(opt)
visualizer = Visualizer(opt)
web_dir = os.path.join(opt.results_dir, opt.name, '%s_%s' % (opt.phase, opt.which_epoch))
webpage = html.HTML(web_dir, 'Experiment = %s, Phase = %s, Epoch = %s' % (opt.name, opt.phase, opt.which_epoch))
for i, data in enumerate(dataset):
if i >= opt.how_many:
break
model.set_input(data)
model.test()
visuals = model.get_current_visuals()
img_path = model.get_image_paths()
print('Generating output for image..... %s' %img_path)
visualizer.save_images(webpage, visuals, img_path)
webpage.save()