hello, thanks for your nice job. I test the finetuning_model on some middlebury images, however, in some cases the performance is not satisfying. do you know the reason.
below is the code I used for testing.
from future import print_function, division
import argparse
import os
import glob
from PIL import Image
from matplotlib import pyplot as plt
import cv2
import torch
import torch.nn as nn
import torch.nn.parallel
import torch.backends.cudnn as cudnn
import torch.optim as optim
import torch.utils.data
from torch.autograd import Variable
import torchvision.utils as vutils
import torch.nn.functional as F
import numpy as np
import time
from datasets import datasets
from models import models
from utils import *
import PIL.Image
from torch.utils.data import DataLoader
from datasets import listfiles as ls
from datasets import MiddleburyLoader as DA
import sys
import gc
import skimage
cudnn.benchmark = False
parser = argparse.ArgumentParser(description='Cascade and Fused Cost Volume for Robust Stereo Matching(CFNet)')
parser.add_argument('--model', default='cfnet', help='select a model structure', choices=models.keys())
parser.add_argument('--maxdisp', type=int, default=256, help='maximum disparity')
parser.add_argument('--dataset', default='kitti', help='dataset name', choices=datasets.keys())
parser.add_argument('--loadckpt', default='/home/jucic/my_code/CFNet/finetuning_model', help='load the weights from a specific checkpoint')
parse arguments
args = parser.parse_args()
model, optimizer
model = modelsargs.model
model = nn.DataParallel(model)
model.cuda()
model.eval()
load parameters
print("loading model {}".format(args.loadckpt))
state_dict = torch.load(args.loadckpt)
model.load_state_dict(state_dict['model'])
def save_pfm(file, image, scale = 1):
color = None
if image.dtype.name != 'float32':
raise Exception('Image dtype must be float32.')
if len(image.shape) == 3 and image.shape[2] == 3: # color image
color = True
elif len(image.shape) == 2 or len(image.shape) == 3 and image.shape[2] == 1: # greyscale
color = False
else:
raise Exception('Image must have H x W x 3, H x W x 1 or H x W dimensions.')
file.write('PF\n' if color else 'Pf\n')
file.write('%d %d\n' % (image.shape[1], image.shape[0]))
endian = image.dtype.byteorder
if endian == '<' or endian == '=' and sys.byteorder == 'little':
scale = -scale
hello, thanks for your nice job. I test the finetuning_model on some middlebury images, however, in some cases the performance is not satisfying. do you know the reason.
below is the code I used for testing.
from future import print_function, division import argparse import os import glob from PIL import Image from matplotlib import pyplot as plt import cv2 import torch import torch.nn as nn import torch.nn.parallel import torch.backends.cudnn as cudnn import torch.optim as optim import torch.utils.data from torch.autograd import Variable import torchvision.utils as vutils import torch.nn.functional as F import numpy as np import time from datasets import datasets from models import models from utils import * import PIL.Image from torch.utils.data import DataLoader from datasets import listfiles as ls from datasets import MiddleburyLoader as DA import sys import gc import skimage
cudnn.benchmark = False
parser = argparse.ArgumentParser(description='Cascade and Fused Cost Volume for Robust Stereo Matching(CFNet)') parser.add_argument('--model', default='cfnet', help='select a model structure', choices=models.keys()) parser.add_argument('--maxdisp', type=int, default=256, help='maximum disparity')
parser.add_argument('--dataset', default='kitti', help='dataset name', choices=datasets.keys()) parser.add_argument('--loadckpt', default='/home/jucic/my_code/CFNet/finetuning_model', help='load the weights from a specific checkpoint')
parse arguments
args = parser.parse_args()
model, optimizer
model = modelsargs.model model = nn.DataParallel(model) model.cuda() model.eval()
load parameters
print("loading model {}".format(args.loadckpt)) state_dict = torch.load(args.loadckpt) model.load_state_dict(state_dict['model'])
def save_pfm(file, image, scale = 1): color = None
if image.dtype.name != 'float32': raise Exception('Image dtype must be float32.')
if len(image.shape) == 3 and image.shape[2] == 3: # color image color = True elif len(image.shape) == 2 or len(image.shape) == 3 and image.shape[2] == 1: # greyscale color = False else: raise Exception('Image must have H x W x 3, H x W x 1 or H x W dimensions.')
file.write('PF\n' if color else 'Pf\n') file.write('%d %d\n' % (image.shape[1], image.shape[0]))
endian = image.dtype.byteorder
if endian == '<' or endian == '=' and sys.byteorder == 'little': scale = -scale
file.write('%f\n' % scale)
image.tofile(file)
def test():
if name == 'main': test()