added openexr support
This commit is contained in:
parent
88c08bec0f
commit
eb3923bfba
|
@ -8,8 +8,8 @@ import warnings
|
|||
warnings.filterwarnings("ignore")
|
||||
|
||||
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
||||
torch.set_grad_enabled(False)
|
||||
if torch.cuda.is_available():
|
||||
torch.set_grad_enabled(False)
|
||||
torch.backends.cudnn.enabled = True
|
||||
torch.backends.cudnn.benchmark = True
|
||||
|
||||
|
@ -22,12 +22,19 @@ model = Model()
|
|||
model.load_model('./train_log', -1)
|
||||
model.eval()
|
||||
model.device()
|
||||
|
||||
img0 = cv2.imread(args.img[0])
|
||||
img1 = cv2.imread(args.img[1])
|
||||
|
||||
img0 = (torch.tensor(img0.transpose(2, 0, 1)).to(device) / 255.).unsqueeze(0)
|
||||
img1 = (torch.tensor(img1.transpose(2, 0, 1)).to(device) / 255.).unsqueeze(0)
|
||||
if args.img[0].endswith('.exr') and args.img[1].endswith('.exr'):
|
||||
img0 = cv2.imread(args.img[0], cv2.IMREAD_COLOR | cv2.IMREAD_ANYDEPTH)
|
||||
img1 = cv2.imread(args.img[1], cv2.IMREAD_COLOR | cv2.IMREAD_ANYDEPTH)
|
||||
img0 = (torch.tensor(img0.transpose(2, 0, 1)).to(device)).unsqueeze(0)
|
||||
img1 = (torch.tensor(img1.transpose(2, 0, 1)).to(device)).unsqueeze(0)
|
||||
|
||||
else:
|
||||
img0 = cv2.imread(args.img[0])
|
||||
img1 = cv2.imread(args.img[1])
|
||||
img0 = (torch.tensor(img0.transpose(2, 0, 1)).to(device) / 255.).unsqueeze(0)
|
||||
img1 = (torch.tensor(img1.transpose(2, 0, 1)).to(device) / 255.).unsqueeze(0)
|
||||
|
||||
n, c, h, w = img0.shape
|
||||
ph = ((h - 1) // 32 + 1) * 32
|
||||
pw = ((w - 1) // 32 + 1) * 32
|
||||
|
@ -48,4 +55,7 @@ for i in range(args.exp):
|
|||
if not os.path.exists('output'):
|
||||
os.mkdir('output')
|
||||
for i in range(len(img_list)):
|
||||
cv2.imwrite('output/img{}.png'.format(i), (img_list[i][0] * 255).byte().cpu().numpy().transpose(1, 2, 0)[:h, :w])
|
||||
if args.img[0].endswith('.exr') and args.img[1].endswith('.exr'):
|
||||
cv2.imwrite('output/img{}.exr'.format(i), (img_list[i][0]).cpu().numpy().transpose(1, 2, 0)[:h, :w], [cv2.IMWRITE_EXR_TYPE, cv2.IMWRITE_EXR_TYPE_HALF])
|
||||
else:
|
||||
cv2.imwrite('output/img{}.png'.format(i), (img_list[i][0] * 255).byte().cpu().numpy().transpose(1, 2, 0)[:h, :w])
|
||||
|
|
Loading…
Reference in New Issue