예제 #1
0
def load_img(config, data_dir): 
    img, geom, vis, depth, kp, desc = loadFromDir(
        data_dir,
        "-16x16",
        bUseColorImage=True,
        crop_center=config.data_crop_center,
        load_lift=config.use_lift)
    return img, geom, vis
예제 #2
0
#  train_path = getattr(config, "data_dir_" + _set[:2]) + split + "/"
train_path = getattr(config, "data_dir_tr")

# Create data dump directory name
data_names = getattr(config, "data_tr")
data_name = data_names.split(".")[0]
cur_folder = "/".join(
    [data_folder, data_name, "numkp-{}".format(config.obj_num_kp)])

if not os.path.exists(cur_folder):
    os.makedirs(cur_folder)

img, kp, desc, aff, K, R, t = loadFromDir(train_path,
                                          cur_folder,
                                          "-16x16",
                                          bUseColorImage=True,
                                          crop_center=crop_center,
                                          load_hessian=True)

if len(kp) == 0:
    kp = [None] * len(img)
if len(desc) == 0:
    desc = [None] * len(img)

pair_index = np.loadtxt(train_path + "pair_index.txt")

# Check if we've done this folder already.
print(" -- Waiting for the data_folder to be ready")
ready_file = os.path.join(cur_folder, "ready")
if not os.path.exists(ready_file):
    print(" -- No ready file {}".format(ready_file))
예제 #3
0
# Now start data prep
print("Preparing data for {}".format(config.data_tr.split(".")[0]))

for _set in ["train", "valid", "test"]:
    num_sample = getattr(
        config, "train_max_{}_sample".format(_set[:2]))

    # Load the data
    print("Loading Raw Data for {}".format(_set))
    if _set == "valid":
        split = "val"
    else:
        split = _set
    img, geom, vis, depth, kp, desc = loadFromDir(
        getattr(config, "data_dir_" + _set[:2]) + split + "/",
        "-16x16",
        bUseColorImage=True,
        crop_center=crop_center,
        load_lift=config.use_lift)
    if len(kp) == 0:
        kp = [None] * len(img)
    if len(desc) == 0:
        desc = [None] * len(img)
    z = [None] * len(img)

    # Generating all possible pairs
    print("Generating list of all possible pairs for {}".format(_set))
    pairs = []
    for ii, jj in itertools.product(xrange(len(img)), xrange(len(img))):
        if ii != jj:
            if vis[ii][jj] > getattr(config, "data_vis_th_" + _set[:2]):
                pairs.append((ii, jj))
# Now start data prep
print("Preparing data for {}".format(config.data_tr.split(".")[0]))

for _set in ["train", "valid", "test"]:
    num_sample = getattr(config, "train_max_{}_sample".format(_set[:2]))

    # Load the data
    print("Loading Raw Data for {}".format(_set))
    if _set == "valid":
        split = "val"
    else:
        split = _set
    img, geom, vis, depth, kp, desc = loadFromDir(
        getattr(config, "data_dir_" + _set[:2]) + split + "/",
        "-16x16",
        bUseColorImage=True,
        crop_center=crop_center,
        precomputed_kp_method=config.precomputed_kp_method)
    if len(kp) == 0:
        kp = [None] * len(img)
    if len(desc) == 0:
        desc = [None] * len(img)
    z = [None] * len(img)

    # Generating all possible pairs
    print("Generating list of all possible pairs for {}".format(_set))
    pairs = []
    for ii, jj in itertools.product(xrange(len(img)), xrange(len(img))):
        if ii != jj:
            if vis[ii][jj] > getattr(config, "data_vis_th_" + _set[:2]):
                pairs.append((ii, jj))