forked from naoto0804/pytorch-inpainting-with-partial-conv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
33 lines (26 loc) · 981 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
import argparse
import torch
from torchvision import transforms
import opt
from places2 import Places2
from evaluation import evaluate
from net import PConvUNet
from util.io import load_ckpt
parser = argparse.ArgumentParser()
# training options
parser.add_argument('--root', type=str, default='./data')
parser.add_argument('--snapshot', type=str, default='')
parser.add_argument('--image_size', type=int, default=256)
args = parser.parse_args()
device = torch.device('cuda')
size = (args.image_size, args.image_size)
img_transform = transforms.Compose(
[transforms.Resize(size=size), transforms.ToTensor(),
transforms.Normalize(mean=opt.MEAN, std=opt.STD)])
mask_transform = transforms.Compose(
[transforms.Resize(size=size), transforms.ToTensor()])
dataset_val = Places2(args.root, img_transform, mask_transform, 'val')
model = PConvUNet().to(device)
load_ckpt(args.snapshot, [('model', model)])
model.eval()
evaluate(model, dataset_val, device, 'result.jpg')