Пример #1
0
def load_vox(vox_path):  # 用于加载单个体素,参数是体素的路径,返回以np.ndarray存储的体素
    with open(vox_path, 'rb') as f:  # rb是以二进制读形式打开
        # third_party.binvox_rw.read_as_3d_array().data将体素数据读取成三维数组,具体进入.\third_party\binvox_rw.py中查看
        # 其中,三维数组代表体素的x,y,z。占用的体素值为true,非占用的体素值为false
        # keras.utils.to_categorical()用于将数据转换成0,1独热编码的形式
        # 在这个例子中,to_categorical将false转换成[1,0],将true转换成[0,1]
        return to_categorical(
            binvox_rw.read_as_3d_array(f).data)  # 返回转换成独热编码的数组
Пример #2
0
def load_label(label_samples):
    if isinstance(label_samples, str):
        label_samples = [label_samples]

    ret = []
    for voxel_path in label_samples:
        with open(voxel_path, 'rb') as f:
            ret.append(binvox_rw.read_as_3d_array(f).data)

    return (np.stack(ret) if len(ret) != 1 else ret[0])
Пример #3
0
def load_vox(vox_path):
    with open(vox_path, 'rb') as f:
        return to_categorical(binvox_rw.read_as_3d_array(f).data)