• win10 mmdetection3d环境搭建


    官网:mmdetection3d/README_zh-CN.md at master · open-mmlab/mmdetection3d · GitHub

    安装过程参照:win10 mmdetection3d 训练KITTI_树和猫的博客-CSDN博客_pointnet训练kitti

    官网安装过程

    前言

    3D目标检测框架综述-知乎中描述了当前3D目标检测的数据和模型状况,为了能将数据和评价标准等统一,介绍了4个比较统一的检测算法框架。

    OpenPCDet

    社区活跃,代码轻量化且可读性强(有些顶刊论文是基于这个框架开发的)

    基于Pytorch框架

    mmdetection3d

    社区活跃,有官方文档,便于上手;代码封装性好,codeview比较吃力(近年的顶刊会议有些是基于这个框架开发的)

    基于Pytorch框架

    Det3D

    和OpenPCDet类似,也比较轻量,但是最近不怎么更新了。

    基于Pytorch框架

    Paddle3D

    2022年8月刚开源出来,暂时还不清楚效果

    基于PaddlePaddle框架

    小结:

    最终选定了应用比较多的OpenPCDet和mmdetection3d,但是OpenPCDet在win10系统下没有安装成功(唯一看到成功的博客,如果有兴趣可以自己尝试),最终选择mmdetection3d进行安装

    mmdetection3d的安装(安装失败)

    主要是python版本错误导致的,若想看安装教程,直接跳转到正确安装部分。

    1. 准备工作

    本机环境:

    win10 + anaconda3 +python3.9+CUDA11.5 + CUDNN8.3 + torch1.11 + torchvision0.12.

    准备工作:下载官网文件到本地文件夹下E:\LCH_Content\Code\1Preparations\mmdetection3d__open-mmlab

    (1)安装过程可依照如下步骤

    1. pip install openmim -i https://pypi.tuna.tsinghua.edu.cn/simple
    2. mim install mmcv-full
    3. mim install mmdet
    4. mim install mmsegmentation

    mmdet安装时出错,遂改用

    1. # install mmdetection
    2. pip install git+https://github.com/open-mmlab/mmdetection.git

    注意,此方法需要提前安装git包,安装方式

    conda install git

    (2)跳转到本地文件夹下

    cd \d E:\LCH_Content\Code\1Preparations\mmdetection3d__open-mmlab

    (3) 安装spconv

    pip install spconv-cu114 -i https://pypi.tuna.tsinghua.edu.cn/simple

    (4) 安装依赖包

    pip install -e . -i https://pypi.tuna.tsinghua.edu.cn/simple
    

    注意:

    官网说,sponv比原生mmvc sponv使用内存更少,所以先安装了spconv(别人有些最后才安装这个库)。由于网路原因,最后一步可能会报错,多试几次或者加镜像。

    2. 测试和验证

    (1). 数据集存放的位置

    KITTI数据集官网

    将下载好的数据集按照下列顺序放到mmdetection3d项目路径下(其中ImageSet文件夹用来存放数据集划分文本)

    mmdetection3d
    ├── mmdet3d
    ├── tools
    ├── configs
    ├── data
    │   ├── kitti
    │   │   ├── ImageSets
    │   │   ├── testing
    │   │   │   ├── calib
    │   │   │   ├── image_2
    │   │   │   ├── velodyne
    │   │   ├── training
    │   │   │   ├── calib
    │   │   │   ├── image_2
    │   │   │   ├── label_2
    │   │   │   ├── velodyne

    主要是testing和training中存放这些数据,目前选择了0-200的编号。

    (2). 数据集处理

    (1) 在项目mmdetection3d文件夹下,进入cmd,并输入下列内容以创建文件夹。

    mkdir .\data\kitti\ImageSets

    (2) 在cmd中继续输入下列内容,下载数据划分文件(生成4个txt文件)

    1. wget -c https://raw.githubusercontent.com/traveller59/second.pytorch/master/second/data/ImageSets/test.txt --no-check-certificate --content-disposition -O ./data/kitti/ImageSets/test.txt
    2. wget -c https://raw.githubusercontent.com/traveller59/second.pytorch/master/second/data/ImageSets/train.txt --no-check-certificate --content-disposition -O ./data/kitti/ImageSets/train.txt
    3. wget -c https://raw.githubusercontent.com/traveller59/second.pytorch/master/second/data/ImageSets/val.txt --no-check-certificate --content-disposition -O ./data/kitti/ImageSets/val.txt
    4. wget -c https://raw.githubusercontent.com/traveller59/second.pytorch/master/second/data/ImageSets/trainval.txt --no-check-certificate --content-disposition -O ./data/kitti/ImageSets/trainval.txt

    此前需要安装wget,Wget for windows安装方法

    注:在环境变量中添加路径时,要先新建,再浏览输入保存。

    问题:

    1. Resolving raw.githubusercontent.com (raw.githubusercontent.com)... failed: 请求的名称有效,但是找不到请求的类型的数据。 .
    2. wget: unable to resolve host address 'raw.githubusercontent.com'

    解决方案

    如,在文件中添加了下列内容:

    185.199.108.133 raw.githubusercontent.com

    (3) 激活项目的虚拟环境,输入以下命令对数据集进行预处理

    python tools/create_data.py kitti --root-path ./data/kitti --out-dir ./data/kitti --extra-tag kitti

    注意:由于数据只解压了0-200的数据,故需要先将ImageSets中的数据进行修改。(只保留了000200之前的数据)。

    错误1:

    ImportError: cannot import name 'gcd' from 'fractions' (D:\PythonVirtualEnv\envs\py39\lib\fractions.py)

    解决1:同样问题的解决方法

    1. conda install -y networkx">=2.5"
    2. conda install -y networkx==2.2

    (4) 处理完成后,得到的目录如下:

    (3). 数据训练

    数据训练对训练参数讲的很详细

    单GPU训练

    python tools/train.py configs/pointpillars/hv_pointpillars_secfpn_6x8_160e_kitti-3d-car.py

    训练结束后,我们可以在/mmdetection3d/work-dirs/hv_pointpillars_secfpn_6x8_160e_kitti-3d-3class文件夹中看到训练结果,包括日志文件(.log)、权重文件(.pth)以及模型配置文件(.py)等。

    数据测试

    1. python demo/pcd_demo.py demo/data/kitti/kitti_000008.bin configs/second/hv_second_secfpn_6x8_80e_kitti-3d-car.py checkpoints/hv_second_secfpn_6x8_80e_kitti-3d-car_20200620_230238-393f000c.pth

    报错

    AttributeError: 'EnforcedForest' object has no attribute 'node'.

    根据官网解答, networkx的版本需求如下

    pip install 'networkx>=2.2,<2.3'

    进一步测试发现,它要求的python版本为3.8, 故宣告失败,按照官网步骤重新来。

    mmdetection3d的正确安装

    1. 安装步骤

    官方安装步骤

    由于安装过程也出现一些问题,故重头描述安装过程。

    (1) 安装cuda, cudnn

    (2) 创建虚拟环境,注最好安装python=3.8(上述已证明3.9不行);

    1. conda create --name mmdet3d python=3.8 -y
    2. conda activate mmdet3d

    (3) 安装pytorch和torchvision

    官方提供的办法,安装为cpu版本。建议在whl下载中直接下载对应cuda版本的pytorch和torchvision。在whl下载目录下进行安装:

    1. pip install torch-1.11.0+cu115-cp39-cp39-win_amd64.whl
    2. pip install torchvision-0.12.0+cu115-cp39-cp39-win_amd64.whl

    (4) 安装spconv

    比mmcv spconv使用更少的内存,故提前安装该依赖。

    由于cuda11.5没有对应的spconv, 故安装11.4版本的。

    pip install spconv-cu114
    

    (5) 安装mmdetection 3d

    在想要安装的文件夹下,依次输入下列语句:

    1. pip install openmim
    2. mim install mmcv-full
    3. mim install mmdet
    4. mim install mmsegmentation
    5. git clone https://github.com/open-mmlab/mmdetection3d.git
    6. cd mmdetection3d
    7. pip install -e .

    2. 测试:

    为了将数据可视化,需要提前安装open3d依赖

    pip install opend3d -i https://pypi.tuna.tsinghua.edu.cn/simple

    (1) 使用官方给定的demo进行测试,其中checkpoints中内容需要在模型库中下载

    python demo/pcd_demo.py demo/data/kitti/kitti_000008.bin configs/second/hv_second_secfpn_6x8_80e_kitti-3d-car.py checkpoints/hv_second_secfpn_6x8_80e_kitti-3d-car_20200620_230238-393f000c.pth

    若demo文件夹下出现了下列文件夹及其包含的内容,说明安装成功。

    上述obj文件可用MeshLab打开将其可视化.

    (2) 可视化数据集(即,数据集中的点云依次用open3d可视化), 在线显示并存入磁盘。

    python tools/misc/browse_dataset.py configs/_base_/datasets/kitti-3d-car.py --task det --output-dir data/lch_data/output --online

    (3) 显示2D图像以及投影的3d边界框

    python tools/misc/browse_dataset.py configs/mvxnet/dv_mvx-fpn_second_secfpn_adamw_2x8_80e_kitti-3d-3class.py --task multi_modality-det --output-dir data/lch_data/testmulti --online
    

    (4) demo的检测结果。

    1. python demo/pcd_demo.py demo/data/kitti/kitti_000008.bin configs/pointpillars/hv_pointpillars_secfpn_6x8_160e_kitti-3d-car.py checkpoints/hv_second_secfpn_6x8_80e_kitti-3d-car_20200620_230238-393f000c.pth --out-dir data/lch_data/out_display --show
    2. python demo/pcd_demo.py demo/data/kitti/kitti_000008.bin configs/pointpillars/hv_pointpillars_secfpn_6x8_160e_kitti-3d-car.py checkpoints/hv_second_secfpn_6x8_80e_kitti-3d-car_20200620_230238-393f000c.pth --score-thr 0.7 --out-dir data/lch_data/demo --show

    (5) 想要查看检测的准确度,可输入下列指令:

    python tools/test.py configs/pointpillars/hv_pointpillars_secfpn_6x8_160e_kitti-3d-car.py checkpoints/hv_second_secfpn_6x8_80e_kitti-3d-car_20200620_230238-393f000c.pth --eval 'mAP' --eval-options 'show=True' 'out_dir=./data/lch_data/show_results'
    

    出错:

    OSError: [WinError 1455] 页面文件太小,无法完成操作。 Error loading "D:\PythonVirtualEnv\envs\mmdet3d\lib\site-packages\torch\lib\shm.dll" or one of its dependencies.

    解决方案

  • 相关阅读:
    Docker-Compose构建spark集群
    利用ImportBeanDefinitionRegistrar和BeanPostProcessor实现Spring对自定义注解bean的管理
    Android应用开发(38)全屏显示隐藏状态栏和导航栏
    OMC IT监控运维管理平台建设方案
    研发效能DevOps: OpenEuler 部署 drone 持续集成平台
    食品添加剂:健康还是危险?——从肠道微生物角度分析
    408王道数据结构强化——应用题
    Mybatis Mapper接口和xml绑定的多种方式、内部实现原理和过程
    51-1 内网信息收集 - 内网资源探测
    权威认证!瀚高股份IvorySQL通过强制性国标GB18030-2022最高级别认证
  • 原文地址:https://blog.csdn.net/gloria_iris/article/details/127689518