问题描述
我正在研究 3D 体素模型重建网络,并且正在努力将 .mat 体素模型(来自 Pix3D 数据集)加载为 TF2 中的标签。我有两个想法:
- 使用
tf.data.Dataset.from_tensor_slices(img_paths,voxel_mat_paths)
和train_ds.map(self.process_path)
和scipy.io.loadmat
函数。但是loadmat
无法处理来自 TF 的string tensor
。
def process_path(self,img_path,voxel):
label = self.get_label(label_path)
img = tf.io.read_file(img_path)
img = self.decode_img(img)
return img,voxel
def get_label(self,voxel_path):
mat = scipy.io.loadmat(voxel_path)
return mat['voxel']
- 第二个想法是将所有
.mat
文件加载到list
中,然后将其传递给from_tensor_slices
train_img_paths = [cfg.PIX3D_PATH + example['img'] for example in self.dataset_desc_train]
train_voxel_paths = [cfg.PIX3D_PATH + example['voxel'] for example in self.dataset_desc_train]
train_voxel = [scipy.io.loadmat(path)['voxel'] for path in train_voxel_paths]
train_ds = tf.data.Dataset.from_tensor_slices((train_img_paths,train_voxel))
train_ds = train_ds.map(self.process_path,num_parallel_calls=1)
那么应该可以在process_path
中解码图像并通过体素数据。但是,tf.data.Dataset.from_tensor_slices((train_img_paths,train_voxel))
永远不会结束。
基本上,我想加载图像(效果很好)和体素作为这些图像的标签,但是,我不确定应该如何实现这一点。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)