• 欢迎光临~

学习汇报 2022-05-26

开发技术 开发技术 2022-05-26 次浏览

学习汇报 2022-05-26

数据集制作

  • 将CSV文件按ShapeNet数据集格式保存为txt文件
clc
clear
%% csv数据保存为mat
filename=dir('D:leidashujilidar_labelcodecsvdata*.csv');
for i=1:length(filename)
csvname=[filename(i,1).folder '' filename(i,1).name];
csvdata{i} = readmatrix(csvname);
data_orgin{i}(:,1:3) =csvdata{i}(:,1:3);
data_orgin{i}(:,4:6) =csvdata{i}(:,6:8);
data_orgin{i}(:,7) =csvdata{i}(:,4);
numPoint(i)=length(data_orgin{i});
pointcloud{i}=pointCloud(data_orgin{i}(:,1:3));
end
%%
for i=1:length(filename)
a=data_orgin{i};
path='D:leidashujilidar_labelcodemat_data';
name=['lidar_',num2str(i)];
name1=['lidar_',num2str(i),'.txt'];
path_name{i}=fullfile(path,name);
path_name1{i}=fullfile(path,name1);
save (path_name{i}, 'a');
save (path_name1{i},'a','-ascii')
end

学习汇报 2022-05-26

  • 划分训练集,测试集,验证集
clc
clear
path='shape_data/02691156/';
filename_train=dir('D:leidashujilidar_labelcodelidar_data2691156*.txt');%加载文件路径
train_num=0.7;
test_num=0.2;
val_num=0.1;%划分数据集比例
r=1:length(filename_train);
randIndex = randperm(size(r,2));%生成随机种子
r=r(:,randIndex);
train_list=[];
test_list=[];
val_list=[];
%将数据集按比例进行划分
for i=1:fix(train_num*length(filename_train))
train_list=[train_list,'"' path 'lidar_' num2str(r(i)) '", '];
end
for i=fix(train_num*length(filename_train))+1:fix(train_num*length(filename_train))+...
    fix(test_num*length(filename_train))
test_list=[test_list,'"' path 'lidar_' num2str(r(i)) '", '];
end
for i=fix(train_num*length(filename_train))+fix(test_num*length(filename_train))+1:length(filename_train)
val_list=[val_list,'"' path 'lidar_' num2str(r(i)) '", '];
end
  • 将生成的test_list,train_list,val_list保存为.json文件

学习汇报 2022-05-26

测试训练

  • 将分类标签进行更改
seg_classes = {'road': [1,2,3]}#road代表大类名称,[1,2,3]代表属于该大类的标签数值
  • 在train_partseg设置数据加载根目录
root = 'data/lidar_data/'#数据根目录
TRAIN_DATASET = PartNormalDataset(root=root, npoints=args.npoint, split='trainval', normal_channel=args.normal)
trainDataLoader = torch.utils.data.DataLoader(TRAIN_DATASET, batch_size=args.batch_size, shuffle=True, num_workers=10, drop_last=True)
TEST_DATASET = PartNormalDataset(root=root, npoints=args.npoint, split='test', normal_channel=args.normal)
testDataLoader = torch.utils.data.DataLoader(TEST_DATASET, batch_size=args.batch_size, shuffle=False, num_workers=10)
  • 在ShapeNetDataLoader中设置数据路径
def __init__(self,root = 'Pointnet_Pointnet2_pytorch-master-0524datalidar_data', npoints=2500, split='train', class_choice=None, normal_channel=False):
self.meta = {}
        with open(os.path.join(self.root, 'train_test_split', 'train.json'), 'r') as f:
            train_ids = set([str(d.split('/')[2]) for d in json.load(f)])
        with open(os.path.join(self.root, 'train_test_split', 'val.json'), 'r') as f:
            val_ids = set([str(d.split('/')[2]) for d in json.load(f)])
        with open(os.path.join(self.root, 'train_test_split', 'test.json'), 'r') as f:
            test_ids = set([str(d.split('/')[2]) for d in json.load(f)])
        for item in self.cat:
  • 训练结果

存在的问题

  1. 训练结果的可视化
程序员灯塔
转载请注明原文链接:学习汇报 2022-05-26
喜欢 (0)