在OpenPCDet上训练KITTI数据集并进行测试和验证

文章目录

  • 一、数据预处理
  • 二、训练
    • 2.1 模型训练
    • 2.2 tensorBoard可视化
  • 三、测试
  • 四、推理
  • Debug 记录
      • qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
      • KeyError: 'road_plane'

https://xiaohu.blog.csdn.net/article/details/124515876

在进行训练之前

  1. 需要配置好Openpcdet的环境——Ubuntu18.04复现OpenPCDet
  2. 下载并组织好KITTI文件——KITTI数据集解析和可视化

一、数据预处理

生成数据pkl文件和gt_database文件夹

python -m pcdet.datasets.kitti.kitti_dataset create_kitti_infos tools/cfgs/dataset_configs/kitti_dataset.yaml

在OpenPCDet上训练KITTI数据集并进行测试和验证_第1张图片
在OpenPCDet上训练KITTI数据集并进行测试和验证_第2张图片

二、训练

2.1 模型训练

用于训练的文件在OpenPCDet-master/tools/train.py
在OpenPCDet上训练KITTI数据集并进行测试和验证_第3张图片

cd tools
# 单卡训练
python train.py --cfg_file cfgs/kitti_models/pointpillar.yaml

# 多卡训练
CUDA_VISIBLE_DEVICES=5,6,7 python -m torch.distributed.launch --nproc_per_node=3 tools/train.py --cfg_file tools/cfgs/kitti_models/pointpillar.yaml --launcher pytorch

sh scripts/dist_train.sh 8 --cfg_file tools/cfgs/kitti_models/pointpillar.yaml

2.2 tensorBoard可视化

tensorBoard可视化

cd output/kitti_models/pointpillar/default/
tensorboard --logdir tensorboard/

在这里插入图片描述
然后远程连接服务器桌面,打开浏览器输入http://localhost:6006/

在OpenPCDet上训练KITTI数据集并进行测试和验证_第4张图片

三、测试

运行test.py脚本验证模型在测试集上的性能
在OpenPCDet上训练KITTI数据集并进行测试和验证_第5张图片

cd tools
python test.py --cfg_file cfgs/kitti_models/pointpillar.yaml --batch_size 4 --ckpt ../output/kitti_models/pointpillar/default/ckpt/latest_model.pth

四、推理

cd tools
python demo.py --cfg_file cfgs/kitti_models/pointpillar.yaml  --data_path ../data/kitti/testing/velodyne/000099.bin --ckpt ../output/kitti_models/pointpillar/default/ckpt/latest_model.pth

在OpenPCDet上训练KITTI数据集并进行测试和验证_第6张图片

Debug 记录

qt.qpa.plugin: Could not load the Qt platform plugin “xcb” in “” even though it was found.

  • 问题描述

报错如下

qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.

Aborted (core dumped)
  • 寻找原因
  1. 在终端输入如下命令,开启debug模式
export QT_DEBUG_PLUGINS=1
  1. 然后再次之前运行报错的那条命令
python3 demo.py --cfg_file cfgs / kitti_models / pointpillars.yaml

debug报错记录如下
在OpenPCDet上训练KITTI数据集并进行测试和验证_第7张图片

Got keys from plugin meta data ("xcb")
QFactoryLoader::QFactoryLoader() checking directory path "/home/ubuntu/anaconda3/envs/openpcdet/bin/platforms" ...
Cannot load library /home/ubuntu/anaconda3/envs/openpcdet/lib/python3.7/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so: (libxcb-xinerama.so.0: cannot open shared object file: No such file or directory)
QLibraryPrivate::loadPlugin failed on "/home/ubuntu/anaconda3/envs/openpcdet/lib/python3.7/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so" : "Cannot load library /home/ubuntu/anaconda3/envs/openpcdet/lib/python3.7/site-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so: (libxcb-xinerama.so.0: cannot open shared object file: No such file or directory)"
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.

Aborted (core dumped)

也就是Qt动态链接库的问题,当加载libqxcb.so库的时候,还需要加载libxcb-xinerama库。
切换到报错libxcb.so所在目录:

cd /home/ubuntu/anaconda3/envs/openpcdet/lib/python3.7/site-packages/PyQt5/Qt5/plugins/platforms

运行ldd libqxcb.so,查看关联内容:

ldd libqxcb.so

在OpenPCDet上训练KITTI数据集并进行测试和验证_第8张图片
发现不存在libxcb-xinerama.so.0库。

  • 解决方案
    安装libxcb-xinerama库:
sudo apt-get install libxcb-xinerama0

安装完成后,再次查看关联内容,发现已经修复问题:

ldd libqxcb.so

在OpenPCDet上训练KITTI数据集并进行测试和验证_第9张图片

KeyError: ‘road_plane’

  • 问题描述
    运行python train.py --cfg_file cfgs/kitti_models/pointpillar.yaml 命令进行训练时。
    报错如下:
File "../pcdet/datasets/augmentor/database_sampler.py", line 372, in add_sampled_boxes_to_scene
    sampled_gt_boxes, data_dict['road_plane'], data_dict['calib']
KeyError: 'road_plane'
  • 寻找原因
    没有road_plane这个文件夹的数据。
  • 解决方案
    USE_ROAD_PLANE 的值改成False
    在OpenPCDet上训练KITTI数据集并进行测试和验证_第10张图片

你可能感兴趣的:(#,代码实现——3D目标检测,Openpcdet,1024程序员节)