Exemplo n.º 1
0
def compute_predictions():
  global data_y_gt, y_test_delta_gt, y_delta_test_1, y_delta_test_step, y_delta_pred, yy_test_step, yy_pred, yy_test_1
  # orijinal locations of camera
  dsRawData = tdl.load_data(params["dataset"][id], params["im_type"], params["n_output"])
  dir_list = dsRawData[0]
  data_y_gt = dsRawData[1]
  data_y_gt = data_y_gt * cm_mul * cm_mul
  dsSplits = tdl.split_data(dir_list, id, data_y_gt, params["test_size"], params["val_size"])
  tmp_X_train, y_train_delta_gt = dsSplits[0]
  tmp_X_test, y_test_delta_gt = dsSplits[is_test]
  # location differences with orijinal, step_size=1 setted this means only looking consequtive locations
  X_test, y_delta_test_1, overlaps_test = tdl.prepare_data(1, tmp_X_test, y_test_delta_gt)
  # location differences with step_size=step{10} data augmented with stplits
  X_test_aug, y_delta_test_step, overlaps_test_step = tdl.prepare_data(step, tmp_X_test, y_test_delta_gt)
  # location prediction over augmented data
  y_delta_pred = pred.predict_location.predict(X_test_aug, params)
  y_delta_pred = np.asarray(y_delta_pred)
  y_delta_pred = y_delta_pred * cm_mul
  # camera location restored from augmented data
  yy_test_step = utils.up_sample(overlaps_test_step, y_delta_test_step, step)
  yy_test_step = yy_test_step.reshape(len(yy_test_step), params['n_output'])
  yy_test_step = np.vstack([y_test_delta_gt[0, :], yy_test_step])
  yy_test_step = np.cumsum(yy_test_step, axis=0)
  # camera location restored from predicted data
  yy_pred = utils.up_sample(overlaps_test_step, y_delta_pred, step)
  yy_pred = yy_pred.reshape(len(yy_pred), params['n_output'])
  yy_pred = np.vstack([y_test_delta_gt[0, :], yy_pred])
  yy_pred = np.cumsum(yy_pred, axis=0)
  # camera location restored from differences data
  q = np.squeeze(np.asarray(y_delta_test_1))
  w = np.squeeze(np.asarray(y_test_delta_gt))[0, :]
  yy_test_1 = np.vstack((w, q))
  yy_test_1 = np.array(np.cumsum(yy_test_1, axis=0))

  #save generated data
  model_saver.save_pred(ext_raw_data, data_y_gt,params)
  model_saver.save_pred(ext_y_pred, yy_pred,params)
  model_saver.save_pred(ext_y_delta_pred, y_delta_pred,params)
  model_saver.save_pred(ext_y_delta_test_step, y_delta_test_step,params)
  model_saver.save_pred(ext_yy_test, yy_test_1,params)
  model_saver.save_pred(ext_yy_test_aug, yy_test_step,params)
  model_saver.save_pred(ext_y_test_gt, y_test_delta_gt,params)
Exemplo n.º 2
0
import helper.tum_dataset_loader as tdl
from helper import config, model_saver, utils
from plot import plot_data
import numpy as np

params= config.get_params()

id=4 #data will be loaded according to this id
params['shufle_data']=0
params['im_type']="depth"
params['step_size']=[10]
step=params['step_size'][0]

#orijinal locations of camera
dsRawData=tdl.load_data(params["dataset"][id],params["im_type"])
dir_list=dsRawData[0]
data_y_gt=dsRawData[1]

dsSplits=tdl.split_data(dir_list,id, data_y_gt,params["test_size"],params["val_size"])
tmp_X_train,y_train_delta_gt=dsSplits[0]
tmp_X_test,y_test_delta_gt=dsSplits[1]
tmp_X_val,y_val_delta_gt=dsSplits[2]

plot_data.plot_orijinal_y(y_train_delta_gt,y_test_delta_gt,y_val_delta_gt)


print("ok")