Beispiel #1
0
def param_list2str(p_list, prefix=None, keep_empty=False):
    if is_scalar(p_list):
        p_list = param_str2list(p_list, keep_empty)
    u_p_list = [unicode(p) for p in p_list]
    ret = "|".join(
        [prefixed(t, prefix) for t in u_p_list if (t or keep_empty)])
    return unicode(ret)
Beispiel #2
0
def param_list2str(p_list, prefix=None, keep_empty=False):
    if is_scalar(p_list):
        p_list = param_str2list(p_list, keep_empty)
    u_p_list = [unicode(p) for p in p_list]
    ret = "|".join([prefixed(t, prefix)
                    for t in u_p_list if (t or keep_empty)])
    return unicode(ret)
Beispiel #3
0
def split_train_test(ds_path):
    prefix = utils.prefixed(ds_path, BTS_SUBDIR)
    meta_path = prefix('meta.txt')
    with open(meta_path, 'r') as f:
        lines = f.readlines()
    random.shuffle(lines)
    train, test = lines[:-100], lines[-100:]
    train_path, test_path = prefix('train.txt'), prefix('test.txt')
    print(
        f'Splitting total {len(lines)} samples to {len(train)} train / {len(test)} test samples'
    )
    with open(train_path, 'w') as f:
        f.writelines(train)
    with open(test_path, 'w') as f:
        f.writelines(test)
Beispiel #4
0
def iterate_files(ds_path):
    if not ds_path:
        return
    prefix = utils.prefixed(ds_path)
    meta_path = prefix('meta')
    for meta in iterate_metas(meta_path):
        for cam in meta['cams'].values():
            image_path = prefix(cam['img'])
            image_name = os.path.split(image_path)[-1]
            image = Image.open(image_path)
            depth_path = cam.get('depth_map_name')
            depth_name, depth = None, None
            if depth_path:
                depth_path = prefix(depth_path)
                depth_name = os.path.split(depth_path)[-1]
                depth = np.fromfile(depth_path, np.float32) / 100
                w, h = image.size
                depth = np.reshape(depth, (h, w))
            yield cam, image_path, depth_path, image_name, depth_name, image, depth
 def get_command(self):
     "Returns the current command (i.e. all, entropy, etc etc.)"
     scheme, netloc, path, params, query, fragment = urlparse.urlparse(self.path)
     if utils.prefixed(path, self.path_prefix()):
         return path[len(self.path_prefix()) :]
     raise BadPrefix()