Learning3D:3维点云数据的深度学习库
源链接:https://github.com/vinits5/learning3d
Learning3D是一个开源库,支持处理3维数据的深度学习算法的开发。Learning3D有在python中目前效果好的深度神经网络。为了进一步开发,这里提供了模块化的代码。欢迎开源社区的贡献。
在Learning3D 可用的CV算法
| 序号 | 任务 | 算法 |
|---|---|---|
| 1 | 分类 | PointNet, DGCNN, PPFNet, PointConv |
| 2 | 分割 | PointNet, DGCNN |
| 3 | 重建 | Point Completion Network (PCN) |
| 4 | 配准 | PointNetLK, PCRNet, DCP, PRNet, RPM-Net, DeepGMR |
| 5 | Flow Estimation | FlowNet3D |
| 6 | Inlier Estimation | MaskNet |
可使用的预训练模型
- PointNet
- PCN
- PointNetLK
- PCRNet
- DCP
- PRNet
- FlowNet3D
- RPM-Net (clean-trained.pth, noisy-trained.pth, partial-pretrained.pth)
- DeepGMR
- PointConv (通过这个 链接下载)
- MaskNet
可使用的数据集
- ModelNet40
可使用的损失函数
- 分类损失函数(交叉熵(Cross Entropy))
- 配准损失函数 (FrobeniusNormLoss, RMSEFeaturesLoss)
- 距离损失函数(Chamfer Distance, Earth Mover’s Distance)
- 对应关系损失函数(Correspondence Loss) (基于这篇文章)
技术细节
支持的系统
- Ubuntu 16.04
- Ubuntu 18.04
- Linux Mint
开发环境
- CUDA 10.0 或更高的版本
- Pytorch 1.3 或更高的版本
如何使用这个库
请注意:要Clone 这个库到你的项目里,请不要将自己的代码添加到**learning3d**中
- 所有的网络都定义在
models这个模块中; - 所有的损失函数都定义在
losses这个模块中; Data loaders提前定义在data_utils/dataloaders.py这个文件中;- 所有的预训练模型都在
learning3d/pretrained文件夹之中;
文档
B: 批量大小(Batch Size), N: 点的数量(No. of points ), C: 通道(Channels.)
Point Embedding Networks的使用:
from learning3d.models import PointNet, DGCNN, PPFNet
pn = PointNet(emb_dims=1024, input_shape=‘bnc’, use_bn=False)
dgcnn = DGCNN(emb_dims=1024, input_shape=‘bnc’)
ppf = PPFNet(features=[‘ppf’, ‘dxyz’, ‘xyz’], emb_dims=96, radius=‘0.3’, num_neighbours=64)
| 序号 | 变量 | 数据类型 | 大小(Shape) | 可选择的值(Choices) | 变量含义(Use) |
|---|---|---|---|---|---|
| 1. | emb_dims | Integer | 标量 | 1024, 512 | 每个点的特征向量的大小 |
| 2. | input_shape | String | - | ‘bnc’, ‘bcn’ | 输入点云的形式(shape) |
| 3. | output | tensor | BxCxN | - | 每个点的高维embeddings |
| 4. | features | List of Strings | - | [‘ppf’, ‘dxyz’, ‘xyz’] | 使用各种各样的特征 |
| 5. | radius | Float | 标量 | 0.3 | features 计算局部特征的聚类半径 |
| 6. | num_neighbours | Integer | 标量 | 64 | 每个聚类中的最大点数 |
Classification / Segmentation Network的使用:
from learning3d.models import Classifier, PointNet, Segmentation
classifier = Classifier(feature_model=PointNet(), num_classes=40)
seg = Segmentation(feature_model=PointNet(), num_classes=40)
| 序号 | 变量 | 数据类型 | 大小(Shape) | 可选择的值(Choices) | 变量含义(Use) |
|---|---|---|---|---|---|
| 1. | feature_model | Object | - | PointNet / DGCNN | 点云的embedding 网络 |
| 2. | num_classes | Integer | 标量 | 10, 40 | 分类物品的类别数量 |
| 3. | output | tensor | 分类: Bx40, 分割: BxNx40 | 10, 40 | 每个类别的概率或每个点云的概率 |
Registration Networks的使用:
from learning3d.models import PointNet, PointNetLK, DCP, iPCRNet, PRNet, PPFNet, RPMNet
pnlk = PointNetLK(feature_model=PointNet(), delta=1e-02, xtol=1e-07, p0_zero_mean=True, p1_zero_mean=True, pooling=‘max’)
dcp = DCP(feature_model=PointNet(), pointer_=‘transformer’, head=‘svd’)
pcrnet = iPCRNet(feature_moodel=PointNet(), pooling=‘max’)
rpmnet = RPMNet(feature_model=PPFNet())
deepgmr = DeepGMR(use_rri=True, feature_model=PointNet(), nearest_neighbors=20)
| 序号 | 变量 | 数据类型 | 可选择的值(Choices) | 变量含义(Use) | 使用的算法 |
|---|---|---|---|---|---|
| 1. | feature_model | Object | PointNet / DGCNN | 点云的 embedding 网络 | PointNetLK |
| 2. | delta | Float | Scalar | 计算近似雅可比(approximate jacobian)的参数 | PointNetLK |
| 3. | xtol | Float | Scalar | 迭代数(Check tolerance to stop iterations ) | PointNetLK |
| 4. | p0_zero_mean | Boolean | True/False | 从模板点云中减去平均值 | PointNetLK |
| 5. | p1_zero_mean | Boolean | True/False | 从源点云中减去平均值 | PointNetLK |
| 6. | pooling | String | ‘max’ / ‘avg’ | 用于获取全局特征向量的池化层(Pooling)类型 | PointNetLK |
| 7. | pointer_ | String | ‘transformer’ / ‘identity’ | 使用Transformer/Attention | DCP |
| 8. | head | String | ‘svd’ / ‘mlp’ | 选择估计配准的参数 | DCP |
| 9. | use_rri | Boolean | True/False | 使用最近邻估计点云特征 | DeepGMR |
| 10. | nearest_neighbores | Integer | 20/any integer | 用多少个最近邻来估计 | DeepGMR |
Inlier Estimation Network (MaskNet)的使用:
from learning3d.models import MaskNet, PointNet
masknet = MaskNet(feature_model=PointNet(), is_training=True)
| 序号 | 变量 | 数据类型 | 可选择的值(Choices) | 变量含义(Use) |
|---|---|---|---|---|
| 1. | feature_model | Object | PointNet / DGCNN | Point cloud embedding network |
| 2. | is_training | Boolean | True / False | Specify if the network will undergo training or testing |
Point Completion Network的使用:
from learning3d.models import PCN
pcn = PCN(emb_dims=1024, input_shape=‘bnc’, num_coarse=1024, grid_size=4, detailed_output=True)
| 序号 | 变量 | 数据类型 | 可选择的值(Choices) | 可选择的值(Choices) |
|---|---|---|---|---|
| 1. | emb_dims | Integer | 1024, 512 | 每个点的特征向量大小 |
| 2. | input_shape | String | ‘bnc’ / ‘bcn’ | 输入点云的形式(shape) |
| 3. | num_coarse | Integer | 1024 | 输出点云的形式(shape) |
| 4. | grid_size | Integer | 4, 8, 16 | 用于生成详细输出(detailed output)的网格(grid)大小 |
| 5. | detailed_output | Boolean | True / False | 是否用额外模块去创建详细输出detailed output)点云 |
PointConv的使用:
使用以下作者预训练好的模型来创建
from learning3d.models import create_pointconv
PointConv = create_pointconv(classifier=True, pretrained=‘path of checkpoint’)
ptconv = PointConv(emb_dims=1024, input_shape=‘bnc’, input_channel_dim=6, classifier=True)
或者 像下面一样 用自己的PointConv模型来创建
PointConv = create_pointconv(classifier=False, pretrained=None)
ptconv = PointConv(emb_dims=1024, input_shape=‘bnc’, input_channel_dim=3, classifier=True)
PointConv 的变量是一个类,使用者可以使用它去创建一个子类来重载*create_classifier和create_structure* 方法去改变PointConv的网络架构。
| 序号 | 变量 | 数据类型 | 可选择的值(Choices) | 变量含义(Use) |
|---|---|---|---|---|
| 1. | emb_dims | Integer | 1024, 512 | 每个点的特征向量的大小 |
| 2. | input_shape | String | ‘bnc’ / ‘bcn’ | 输入点云的形式(shape) |
| 3. | input_channel_dim | Integer | 3/6 | 点云是否拥有xyz维度,法向量维度和颜色维度 |
| 4. | classifier | Boolean | True / False | 是否使用PointConv来分类 |
| 5. | pretrained | Boolean | String | 给定预训练分类模型的路径(仅供作者所给出的权重使用) |
Flow Estimation Network的使用:
from learning3d.models import FlowNet3D
flownet = FlowNet3D()
Data Loaders的使用:
from learning3d.data_utils import ModelNet40Data, ClassificationData, RegistrationData, FlowData
modelnet40 = ModelNet40Data(train=True, num_points=1024, download=True)
classification_data = ClassificationData(data_class=ModelNet40Data())
registration_data = RegistrationData(algorithm=‘PointNetLK’, data_class=ModelNet40Data(), partial_source=False, partial_template=False, noise=False)
flow_data = FlowData()
| 序号 | 变量 | 数据类型 | 可选择的值(Choices) | 变量含义(Use) |
|---|---|---|---|---|
| 1. | train | Boolean | True / False | 分数据给训练/测试集 |
| 2. | num_points | Integer | 1024 | 每个点云里点的数量 |
| 3. | download | Boolean | True / False | 如果数据不存在会去下载 |
| 4. | data_class | Object | - | 指定所使用的数据集 |
| 5. | algorithm | String | ‘PointNetLK’, ‘PCRNet’, ‘DCP’, ‘iPCRNet’ | 配准的算法 |
| 6. | partial_source | Boolean | True / False | 创造源点云的一部分 |
| 7. | partial_template | Boolean | True / False | 创造模板点云的一部分 |
| 8. | noise | Boolean | True / False | 为源点云添加噪声 |
使用自己的数据:
from learning3d.data_utils import UserData
dataset = UserData(application, data_dict)
| 序号 | 应用的领域 | 需要的键 | 对应的值 |
|---|---|---|---|
| 1. | ‘classification’ | ‘pcs’ | Point Clouds (BxNx3) |
| ‘labels’ | Ground Truth Class Labels (BxN) | ||
| 2. | ‘registration’ | ‘template’ | Template Point Clouds (BxNx3) |
| ‘source’ | Source Point Clouds (BxNx3) | ||
| ‘transformation’ | Ground Truth Transformation (Bx4x4) | ||
| 3. | ‘flow_estimation’ | ‘frame1’ | Point Clouds (BxNx3) |
| ‘frame2’ | Point Clouds (BxNx3) | ||
| ‘flow’ | Ground Truth Flow Vector (BxNx3) |
损失函数的使用:
from learning3d.losses import RMSEFeaturesLoss, FrobeniusNormLoss, ClassificationLoss, EMDLoss, ChamferDistanceLoss, CorrespondenceLoss
rmse = RMSEFeaturesLoss()
fn_loss = FrobeniusNormLoss()
classification_loss = ClassificationLoss()
emd = EMDLoss()
cd = ChamferDistanceLoss()
corr = CorrespondenceLoss()
| 序号 | 损失函数的类型 | 含义(Use) |
|---|---|---|
| 1. | RMSEFeaturesLoss | 用于求 两点云全局特征向量的均方根(RSM)的值 |
| 2. | FrobeniusNormLoss | 用于求 两变换矩阵的frobenius 范数 |
| 3. | ClassificationLoss | 用于计算交叉熵损失 |
| 4. | EMDLoss | 求两给定点云的Earth Mover 距离 |
| 5. | ChamferDistanceLoss | 求两给定点云的Chamfer 距离 |
| 6. | CorrespondenceLoss | 使用每个源点的 预测对应关系(correspondence)和ground truth 对应关系 计算交叉熵损失 |
示例代码的运行:
- 将
examples文件夹复制到learning3d文件夹外的文件夹 - 然后运行文件(如 python test_pointnet.py)
- 文件目录\文件地址
- learning3d
- test_pointnet.py
参考文献:
- PointNet: Deep Learning on Point Sets for 3D Classification and Segmentation
- Dynamic Graph CNN for Learning on Point Clouds
- PPFNet: Global Context Aware Local Features for Robust 3D Point Matching
- PointConv: Deep Convolutional Networks on 3D Point Clouds
- PointNetLK: Robust & Efficient Point Cloud Registration using PointNet
- PCRNet: Point Cloud Registration Network using PointNet Encoding
- Deep Closest Point: Learning Representations for Point Cloud Registration
- PRNet: Self-Supervised Learning for Partial-to-Partial Registration
- FlowNet3D: Learning Scene Flow in 3D Point Clouds
- PCN: Point Completion Network
- RPM-Net: Robust Point Matching using Learned Features
- 3D ShapeNets: A Deep Representation for Volumetric Shapes
- DeepGMR: Learning Latent Gaussian Mixture Models for Registration
- CMU: Correspondence Matrices are Underrated
- MaskNet: A Fully-Convolutional Network to Estimate Inlier Points
Learning3D是一个开源的Python库,专注于3D点云数据的深度学习算法。该库提供了多种预训练模型,如PointNet、PPFNet等,支持的数据集包括ModelNet40,并涵盖了点云分类、分割、配准等多种任务。此外,还包含各种损失函数,如Chamfer Distance和Correspondence Loss。库的使用包括数据加载、模型创建和损失函数应用等步骤,适用于不同的3D深度学习场景。

3203

被折叠的 条评论
为什么被折叠?



