Beispiel #1
0
def load_sample_dict():
    # load data
    os.chdir('/home/jonfrey/PLR2')
    sys.path.append('src')
    sys.path.append('src/dense_fusion')

    from loaders_v2 import ConfigLoader, GenericDataset

    exp_cfg = ConfigLoader().from_file(
        '/home/jonfrey/PLR2/yaml/exp/exp_ws_deepim.yml')
    env_cfg = ConfigLoader().from_file(
        '/home/jonfrey/PLR2/yaml/env/env_natrix_jonas.yml')
    generic = GenericDataset(cfg_d=exp_cfg['d_train'], cfg_env=env_cfg)
    img = Image.open(
        '/media/scratch1/jonfrey/datasets/YCB_Video_Dataset/data/0000/000001-color.png'
    )
    out = generic[0]
    generic.visu = True
    names = [
        'cloud', 'choose', 'img_masked', 'target', 'model_points', 'idx',
        'add_depth', 'add_mask', 'img', 'cam', 'rot', 'trans', 'desig'
    ]

    sample = {}
    print(len(out[0]))
    for i, o in enumerate(out[0]):
        sample[names[i]] = o

    return sample
Beispiel #2
0
        doc['visu']['on_pred_fail'] = 0.03
        doc['d_test']['noise_translation'] = 0.001
        doc['d_test']['noise_rotation'] = 1

        new_file = p + f'/model{j}.yml'
        new_exps.append(new_file)
        try:
            os.makedirs(p)
        except:
            pass
        with open(new_file, 'w') as f:
            print(f'Created exp {j} at {new_file}')
            yaml.dump(doc, f, default_flow_style=False, sort_keys=False)

    env = ConfigLoader().from_file(env_cfg_path).get_FullLoader()
    env_cfg_path = args.env
    for exp_cfg_path in new_exps:
        seed_everything(42)
        # for exp_cfg_path in exp_cfg_paths:
        exp = ConfigLoader().from_file(exp_cfg_path).get_FullLoader()
        model_path = exp['model_path']
        # copy config files to model path

        if not os.path.exists(model_path):
            os.makedirs(model_path)
            print((pad("Generating network run folder")))
        else:
            print((pad("Network run folder already exits")))

        exp_cfg_fn = os.path.split(exp_cfg_path)[-1]
def get_flags():
    parser = argparse.ArgumentParser()
    parser.add_argument(
        '--exp',
        type=file_path,
        default='yaml/exp/exp_ws_motion_train.yml',  # required=True,
        help='The main experiment yaml file.')
    parser.add_argument('--env',
                        type=file_path,
                        default='yaml/env/env_natrix_jonas.yml',
                        help='The environment yaml file.')
    return parser.parse_args()


if __name__ == "__main__":
    args = get_flags()
    exp = ConfigLoader().from_file(args.exp).get_FullLoader()
    env = ConfigLoader().from_file(args.env).get_FullLoader()
    dataset_train = GenericDataset(cfg_d=exp['d_train'], cfg_env=env)
    K1 = np.array([[1066.778, 0, 312.9869], [0, 1067.487, 241.3109], [0, 0,
                                                                      1]])
    K2 = np.array([[1066.778, 0, 312.9869], [0, 1067.487, 241.3109], [0, 0,
                                                                      1]])

    obj_name_2_idx = copy.deepcopy(dataset_train._backend._name_to_idx)

    RendererYCB('/media/scratch1/jonfrey/datasets/YCB_Video_Dataset',
                obj_name_2_idx=obj_name_2_idx,
                K1=K1,
                K2=K2)
            tarls[j, :, :] = copy.deepcopy(
                self.pose_dict[i[0]][best_match, :4, :4])

        # print(f'loading time is {time.time()-st}')
        return imgls, depls, tarls


if __name__ == "__main__":
    import sys
    import os
    sys.path.insert(0, os.getcwd())
    sys.path.append(os.path.join(os.getcwd() + '/src'))
    sys.path.append(os.path.join(os.getcwd() + '/lib'))

    from loaders_v2 import ConfigLoader
    from loaders_v2 import GenericDataset

    exp_cfg_path = 'yaml/exp/exp_ws_deepim.yml'
    env_cfg_path = 'yaml/env/env_natrix_jonas.yml'
    exp = ConfigLoader().from_file(exp_cfg_path).get_FullLoader()
    env = ConfigLoader().from_file(env_cfg_path).get_FullLoader()
    dataset_train = GenericDataset(cfg_d=exp['d_train'], cfg_env=env)
    store = env['p_ycb'] + '/viewpoints_renderings'
    vm = ViewpointManager(store=store,
                          name_to_idx=dataset_train._backend._name_to_idx,
                          nr_of_images_per_object=10,
                          device='cuda:0',
                          load_images=True)
    i = 19
import os 
import sys 
import yaml
sys.path.insert(0, os.getcwd())
sys.path.append(os.path.join(os.getcwd() + '/src'))
sys.path.append(os.path.join(os.getcwd() + '/lib'))

from loaders_v2 import ConfigLoader
from loaders_v2 import GenericDataset
import torch
import time
import datetime
exp = ConfigLoader().from_file('yaml/exp/exp_natrix.yml').get_FullLoader()
env = ConfigLoader().from_file('yaml/env/env_natrix_jonas.yml').get_FullLoader()

dataset_test = GenericDataset(
            cfg_d=exp['d_test'],
            cfg_env=env)
store = env['p_ycb'] + '/viewpoints_renderings'
dataloader_test = torch.utils.data.DataLoader(dataset_test,
                                      batch_size = 1,
                                      num_workers = 15,
                                      pin_memory= False,
                                      shuffle= False)
print(len(dataloader_test))
st = time.time()
for j, b in enumerate( dataloader_test ): 
  if j % 50 == 0 and j != 0:
    ti = (time.time()-st)/j *len(dataset_test)
    t1 = str(datetime.timedelta(seconds=(time.time()-st) ))