コード例 #1
0
    depth_threshold = 15
    inlier_thresh = 0.02
    cam_height = 1.70
    plotting = False
    plot_range = slice(0, -1)

    u_crop_min_num = 1
    u_crop_min_den = 6
    u_crop_max_num = 5
    u_crop_max_den = 6
    v_crop_min_num = 4
    v_crop_min_den = 7
    v_crop_max_num = 1
    v_crop_max_den = 1

    config = load_obj('{}/config'.format(dir))
    print(config)
    pretrained_depth_path = glob.glob(
        '{}/**depth**best-loss-val_seq-**-test_seq-{}**.pth'.format(dir,
                                                                    ''))[0]
    pretrained_pose_path = glob.glob(
        '{}/**pose**best-loss-val_seq-**-test_seq-{}**.pth'.format(dir, ''))[0]

    config['data_dir'] = path_to_dset_downsized + config[
        'img_resolution'] + '_res/'  #

    ## uncomment for KITTI to oxford
    # config['estimator'] = 'orbslam'

    config['load_stereo'] = False
    config['augment_motion'] = False
コード例 #2
0
import sys
sys.path.append('../')
import numpy as np
import matplotlib.pyplot as plt
from utils.learning_helpers import save_obj, load_obj
import os
import matplotlib
# Removes the XWindows backend (useful for producing plots via tmux without -X)
matplotlib.use('Agg', warn=False)
os.makedirs('figures', exist_ok=True)

path_to_ws = '/home/brandon-wagstaff/learned_scale_recovery/'
scaled_file = path_to_ws + 'results/202007111233-kitti-scaled-good/scale_factor'
scale = load_obj(scaled_file)

plt.rc('text', usetex=True)
plt.rc('font', family='serif')
f, axarr = plt.subplots(2, sharex=True, sharey=True)
axarr[0].tick_params(labelsize=22)
axarr[1].tick_params(labelsize=22)

axarr[0].plot(scale[1][0:-1500:3], linewidth=2, rasterized=True)
axarr[1].plot(scale[19][0:-1500:3], linewidth=2, rasterized=True)
axarr[0].set_ylabel('Scale Factor', fontsize=22)
axarr[1].set_ylabel('Scale Factor', fontsize=22)
axarr[1].set_xlabel('Minibatch', fontsize=22)

axarr[0].set_title('First Epoch', fontsize=19)
axarr[1].set_title('Final Epoch', fontsize=19)
axarr[0].grid()
axarr[1].grid()
コード例 #3
0
from validate import compute_trajectory as tt
from pose_evaluation_utils import dump_pose_seq_TUM, rot2quat, pose_vec_to_mat, compute_ate
from glob import glob
import os
import matplotlib.pyplot as plt

seq = '10_02'
path_to_ws = '/home/brandonwagstaff/learned_scale_recovery/'
model_dir = 'results/202101281256-3-iter-unscaled-good'
path_to_dset_downsized = '/media/datasets/KITTI-odometry-downsized-stereo/'
out_folder = 'pose_data/our_predictions/{}'.format(seq[0:2])
# out_folder = 'pose_data/sfmlearner_results/{}'.format(seq[0:2])
os.makedirs(out_folder, exist_ok=True)
gt_folder = 'pose_data/ground_truth/{}/'.format(seq[0:2])
dir = path_to_ws + model_dir
config = load_obj('{}/config'.format(dir))
config[
    'data_dir'] = path_to_dset_downsized + config['img_resolution'] + '_res/'
config['img_per_sample'] = 2

test_dset = KittiLoaderPytorch(
    config, [[seq], [seq], [seq]],
    mode='test',
    transform_img=get_data_transforms(config)['test'])
test_dset_loaders = torch.utils.data.DataLoader(test_dset,
                                                batch_size=config['minibatch'],
                                                shuffle=False,
                                                num_workers=6)

ts = test_dset.raw_ts[0]
コード例 #4
0
import sys
sys.path.append('../')
import numpy as np
import matplotlib.pyplot as plt
from utils.learning_helpers import save_obj, load_obj
import os
os.makedirs('figures', exist_ok=True)

path_to_ws = '/home/brandon-wagstaff/learned_scale_recovery/'

scaled_file = path_to_ws + 'results/202008041237-oxford-to-kitti-1-epoch-scaled/scale_factor'
unscaled_file = path_to_ws + 'results/202008041450-oxford-to-kitti-1-epoch-unscaled/scale_factor'

scale = load_obj(scaled_file)
unscale = load_obj(unscaled_file)

scaled_average = []
for i in range(0, len(scale[1]), 100):
    scaled_average.append(np.mean(scale[1][i:i + 100]))

plt.rc('text', usetex=True)
plt.rc('font', family='serif')
f, axarr = plt.subplots(1)
axarr.tick_params(labelsize=19)

axarr.plot(scale[1][0:-1000:3], linewidth=2)  #,color='red',linestyle='--')
axarr.plot(unscale[1][0:-1000:3], linewidth=2)  #,color='gold',linestyle='-')

axarr.set_ylabel('Scale Factor', fontsize=19)
axarr.set_xlabel('Minibatch', fontsize=19)
コード例 #5
0
    MAX_DEPTH = 80

    path_to_ws = '/home/brandonwagstaff/learned_scale_recovery/'  ##update this
    path_to_dset_downsized = '/media/datasets/KITTI-eigen-split/'

    dir = path_to_ws + 'results/final_models/eigen-depth-eval-scaled-202102141219'
    pretrained_plane_dir = 'results/plane-model-eigen-202101201842'

    cam_height = 1.70
    median_scaling = False  #align scale of predicted depth with ground truth using median depth
    plane_rescaling = False  #align scale using ground plane detection and known camera height
    post_process = True  #use the standard post-processing that flips images, recomputes depth, and merges with unflipped depth
    benchmark = 'eigen'  ### eigen_benchmark for improved gt, 'eigen' for standard benchmark

    splits_dir = '{}/data/splits/{}'.format(path_to_ws, benchmark)
    config = load_obj('{}/config'.format(dir))
    pretrained_depth_path = glob.glob(
        '{}/**depth**best-loss-val_seq-**-test_seq-{}**.pth'.format(dir,
                                                                    ''))[0]
    pretrained_pose_path = glob.glob(
        '{}/**pose**best-loss-val_seq-**-test_seq-{}**.pth'.format(dir, ''))[0]

    config['data_dir'] = path_to_dset_downsized + config[
        'img_resolution'] + '_res/'  #
    config['minibatch'] = 6
    config['load_pretrained'] = True

    _, models, device = data_and_model_loader(config,
                                              pretrained_depth_path,
                                              pretrained_pose_path,
                                              seq=None)