forked from misads/AliProducts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
46 lines (33 loc) · 1023 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# encoding=utf-8
"""
python3 test.py --tag complex_256 --dataset complex --load checkpoints/complex --which-epoch 499
"""
import os, sys
import pdb
# from dataloader.image_folder import get_data_loader_folder
from torch_template.dataloader.tta import OverlapTTA
import dataloader as dl
from network import get_model
from options import opt
from misc_utils import get_file_name
sys.path.insert(1, '../')
import torch
import torchvision
import numpy as np
from PIL import Image
import misc_utils as utils
if not opt.load:
raise Exception('Checkpoint must be specified at test phase, try --load <checkpoint_dir>')
result_dir = os.path.join(opt.result_dir, opt.tag, str(opt.which_epoch))
utils.try_make_dir(result_dir)
Model = get_model(opt.model)
model = Model(opt)
model = model.cuda(device=opt.device)
model.eval()
load_epoch = model.load(opt.load)
for i, data in enumerate(dl.test_dataloader):
print('Testing image %d' % i)
img, paths = data['input'], data['path']
"""
Test Codes
"""