def cubify(voxel_scores, voxel_size, cubify_threshold): V = voxel_size N = voxel_scores.shape[0] voxel_probs = voxel_scores.sigmoid() active_voxels = voxel_probs > cubify_threshold voxels_per_mesh = (active_voxels.view(N, -1).sum(dim=1)).tolist() start = V // 4 stop = start + V // 2 for i in range(N): if voxels_per_mesh[i] == 0: voxel_probs[i, start:stop, start:stop, start:stop] = 1 meshes = pytorch3d.ops.cubify(voxel_probs, cubify_threshold) meshes = add_dummy_meshes(meshes) meshes = voxel_to_world(meshes) return meshes
def cubify(self, voxel_scores): V = self.voxel_size N = voxel_scores.shape[0] voxel_probs = voxel_scores.sigmoid() active_voxels = voxel_probs > self.cubify_threshold voxels_per_mesh = (active_voxels.view(N, -1).sum(dim=1)).tolist() start = V // 4 stop = start + V // 2 for i in range(N): if voxels_per_mesh[i] == 0: print('ERROR is here') voxel_probs[i, start:stop, start:stop, start:stop] = 1 meshes = cubify(voxel_probs, self.cubify_threshold) meshes = self._add_dummies(meshes) meshes = voxel_to_world(meshes) return meshes