目录
1 数据采集:
通过RGBD或双目采集得到三维点云数据
2 数据读入:
pcl读入或open3d读入三维点云数据
3 点云计算:
可以计算点云法向量,和点云FPFH特征进行点云过滤和特征提取,也可以进行ICP配准,或点云融合。
4 点云分割:
通过聚类或RANSAC把点云分割出来。
5 点云保存:
单独保存分割后的点云为pcd,ply,txt文件。
6 数据集制作:
制作点云数据集标签,对每个点云类型进行标签标注。
7 网络模型搭建:
通过pytorch搭建pointnet/pointpillar深度学习网络
8 模型构建:
编写pytorch数据集生成初始化网络文件__len__,__getitem__方法实现
9 模型训练:
编写网络模型文件pointnet/pointpillar.py,继承torch.nn.module 组合网络模型 sequential,包括forward ,epoch训练模型方法model.train(),保存.pt 模型权重文件
10 模型推理:
编写demo推理测试文件,加载数据集Dataloader(),遍历数据集进行推理model.eval(),输出推理结果,语义分割结果。
pointnet网络模型示例:
import torch.nn as nn 读入模型
import torch.nn.functional as F 读入F函数
from torch.autograd import Variable 读入梯度
import torch 加载张量
import pretty_errors
class PointNet(nn.Module): 网络模型定义
def __init__(self):
super(PointNet, self).__init__()
self.conv1 = nn.Conv1d(3, 64, 1) 卷积层1
self.conv2 = nn.Conv1d(64, 128, 1) 卷积层2
self.conv3 = nn.Conv1d(128, 1024, 1) 卷积层3
self.fc1 = nn.Linear(1024, 512) 全连接层
self.fc2 = nn.Linear(512, 256) 全连接层
self.fc3 = nn.Linear(256, 40) 全连接层
self.bn1 = nn.BatchNorm1d(64) 归一化
self.bn2 = nn.BatchNorm1d(128) 归一化
self.bn3 = nn.BatchNorm1d(1024) 归一化
self.bn4 = nn.BatchNorm1d(512)归一化
self.bn5 = nn.BatchNorm1d(256)归一化
self.relu = nn.ReLU(inplace=True) 激活函数
self.dropout = nn.Dropout(p=0.3) 丢弃防止过拟合
def forward(self, x): 前向传播
# TODO: use functions in __init__ to build network
#shared mlp
x=self.relu(self.bn1(self.conv1(x))) 卷积 归一化 激活
x=self.relu(self.bn2(self.conv2(x)))卷积 归一化 激活
x=self.relu(self.bn3(self.conv3(x))) 卷积 归一化 激活
#max pool
x=torch.max(x,dim=2)[0] 最大池化
#mlp 多层感知机
x=self.relu(self.bn4(self.fc1(x)))
x=self.relu(self.bn5(self.dropout(self.fc2(x))))
x=self.fc3(x)
return x
if __name__ == "__main__":
net = PointNet() 调用网络
sim_data = Variable(torch.rand(3, 3, 10000)) 模拟数据
out = net(sim_data) 推理
print('gfn', out.size()) 打印
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
import torch
import pretty_errors
class PointNet(nn.Module):
def __init__(self):
super(PointNet, self).__init__()
self.conv1 = nn.Conv1d(3, 64, 1)
self.conv2 = nn.Conv1d(64, 128, 1)
self.conv3 = nn.Conv1d(128, 1024, 1)
self.fc1 = nn.Linear(1024, 512)
self.fc2 = nn.Linear(512, 256)
self.fc3 = nn.Linear(256, 40)
self.bn1 = nn.BatchNorm1d(64)
self.bn2 = nn.BatchNorm1d(128)
self.bn3 = nn.BatchNorm1d(1024)
self.bn4 = nn.BatchNorm1d(512)
self.bn5 = nn.BatchNorm1d(256)
self.relu = nn.ReLU(inplace=True)
self.dropout = nn.Dropout(p=0.3)
def forward(self, x):
# TODO: use functions in __init__ to build network
#shared mlp
x=self.relu(self.bn1(self.conv1(x)))
x=self.relu(self.bn2(self.conv2(x)))
x=self.relu(self.bn3(self.conv3(x)))
#max pool
x=torch.max(x,dim=2)[0]
#mlp
x=self.relu(self.bn4(self.fc1(x)))
x=self.relu(self.bn5(self.dropout(self.fc2(x))))
x=self.fc3(x)
return x
if __name__ == "__main__":
net = PointNet()
sim_data = Variable(torch.rand(3, 3, 10000))
out = net(sim_data)
print('gfn', out.size())