def __init__(self, data_root, split): super(Dataset, self).__init__() self.data_root = data_root self.split = split ann_file = os.path.join(data_root, 'annots.npy') annots = np.load(ann_file, allow_pickle=True).item() self.cams = annots['cams'] K, RT = render_utils.load_cam(ann_file) render_w2c = render_utils.gen_path(RT) i = 0 i = i + cfg.begin_i self.ims = np.array([ np.array(ims_data['ims'])[cfg.training_view] for ims_data in annots['ims'][i:i + cfg.ni * cfg.i_intv] ]) self.K = K[0] self.render_w2c = render_w2c self.Ks = np.array(K)[cfg.training_view].astype(np.float32) self.RT = np.array(RT)[cfg.training_view].astype(np.float32) self.Ds = np.array(self.cams['D'])[cfg.training_view].astype( np.float32) self.ni = cfg.ni * cfg.i_intv
def __init__(self, data_root, human, ann_file, split): super(Dataset, self).__init__() self.data_root = data_root self.human = human self.split = split annots = np.load(ann_file, allow_pickle=True).item() self.cams = annots['cams'] K, RT = render_utils.load_cam(ann_file) render_w2c = RT self.ts = np.arange(0, np.pi * 2, np.pi / 72) self.nt = len(self.ts) i = 0 i = i + cfg.begin_i self.ims = np.array([ np.array(ims_data['ims'])[cfg.training_view] for ims_data in annots['ims'][i:i + cfg.ni * cfg.i_intv] ]) self.K = K[0] self.render_w2c = render_w2c img_root = 'data/render/{}'.format(cfg.exp_name) # base_utils.write_K_pose_inf(self.K, self.render_w2c, img_root) self.Ks = np.array(K)[cfg.training_view].astype(np.float32) self.RT = np.array(RT)[cfg.training_view].astype(np.float32) self.center_rayd = [ render_utils.get_center_rayd(K_, RT_) for K_, RT_ in zip(self.Ks, self.RT) ] self.Ds = np.array(self.cams['D'])[cfg.training_view].astype( np.float32) self.nrays = cfg.N_rand
def __init__(self, data_root, human, ann_file, split): super(Dataset, self).__init__() self.data_root = data_root self.human = human self.split = split annots = np.load(ann_file, allow_pickle=True).item() self.cams = annots['cams'] num_cams = len(self.cams['K']) test_view = [i for i in range(num_cams) if i not in cfg.training_view] view = cfg.training_view if split == 'train' else test_view i = 0 i = i + cfg.begin_i i_intv = cfg.i_intv self.ims = np.array([ np.array(ims_data['ims'])[view] for ims_data in annots['ims'][i:i + cfg.ni * i_intv][::i_intv] ]).ravel() self.cam_inds = np.array([ np.arange(len(ims_data['ims']))[view] for ims_data in annots['ims'][i:i + cfg.ni * i_intv][::i_intv] ]).ravel() self.num_cams = len(view) K, RT = render_utils.load_cam(ann_file) self.Ks = np.array(K)[cfg.training_view].astype(np.float32) self.RT = np.array(RT)[cfg.training_view].astype(np.float32) self.Ds = np.array(self.cams['D'])[cfg.training_view].astype( np.float32) self.train_ims = np.array([ np.array(ims_data['ims'])[cfg.training_view] for ims_data in annots['ims'][i:i + cfg.ni * i_intv][::i_intv] ]) self.nrays = cfg.N_rand