posted on 2023-06-06 11:19 read(1175) comment(0) like(12) collect(2)
Recently, I have been researching some BEV visual perception algorithms. Here is a record of the Fast-BEV code reproduction practice. The ^_^
theory of professional stepping on pits will not be introduced in detail here. For details, see the original author's paper Fast-BEV: A Fast and Strong Bird's-Eye View Perception
BaselineOthers csdn, the theoretical explanation on Zhihu is also more detailed. The main reason is that I am too good at talking about theory, here I only talk about engineering reproduction^_^
conda create -n fastbev python=3.8
conda activate fastbev
cuda and torch version query I use torch-1.10.0
pip install torch==1.10.0+cu113 torchvision==0.11.0+cu113 torchaudio==0.10.0 -f https://download.pytorch.org/whl/torch_stable.html
Since fastbev
it has been out for a long time, mmcv-full
it has been updated to 2.x.x
the version, renamed mvcc
, and fastbev
still usedmmcv-full
# 安装mmcv-full安装时终端会卡住,不是卡住,是下载时间比较长,耐心等待
pip install mmcv-full==1.4.0
# 安装mmdet
pip install mmdet==2.14.0
# 安装mmdet
pip install mmsegmentation==0.14.1
# 下载fastbev工程
git clone https://github.com/Sense-GVT/Fast-BEV.git
# 激活虚拟环境
conda activate fastbev
# 进入Fast-BEV
cd Fast-BEV
# 配置所需依赖包
pip install -v -e .
# or "python setup.py develop"
python -c 'import mmcv;import mmdet;import mmdet3d;import mmseg;print(mmcv.__version__);print(mmdet.__version__);print(mmdet3d.__version__);print(mmseg.__version__)'
The displayed version numbers are as follows: the corresponding version numbers of mmcv, mmdet, mmdet3d, mmseg
Other dependent packages:
pip install ipdb
pip install timm
Since then the basic environment has been installed.
Only the nuscenes dataset is introduced here, the nuscenes download address
Since the nuscenes data is too large, here we only test the mini version of nuscense, download the map and mini, click the US in the red box as shown below
After downloading, you get 2 compressed files
nuScenes-map-expansion-v1.3与v1.0-mini
two directories, nuScenes-map-expansion-v1.3
copy the three files v1.0-mini/map
in the directory. Finally, get the new v1.0-mini
directory, and use the data set required for training.Enter Fast-BEV
the project target, create a data directory, then copy the above v1.0-mini
folder to ./Fast-BEV/data
the next, and v1.0-mini
rename it to nuscenes
, the directory structure is shown in the figure below:
Because of the mini data set used, add parameters when converting. --version
The data does not provide v1.0-test
a file
If you use all the nuscenes data, you don't need to follow--version
python tools/create_data.py nuscenes --root-path ./data/nuscenes --out-dir ./data/nuscenes --extra-tag nuscenes --workers 10 --version v1.0-mini
After execution, the file in the red box below is generated
After modification, run
python tools/data_converter/nuscenes_seq_converter.py
Generate nuscenes_infos_train_4d_interval3_max60.pkl
and nuscenes_infos_val_4d_interval3_max60.pkl
Two files,
these two files are the data sets required for training, as shown in the following figure:
The download address requires Magic Internet access . Three residual network models
are generally provided . r18,r34,r50
download herecascade_mask_rcnn_r18_fpn_coco-mstrain_3x_20e_nuim_bbox_mAP_0.5110_segm_mAP_0.4070.pth
This needs to be consistent with the configuration file. The configuration file is also r18
, after downloading, create a new pretrained_models
directory and put it in it. As shown below:
Take configs/fastbev/exp/paper/fastbev_m0_r18_s256x704_v200x200x4_c192_d2_f4.py
the file as an example: (Of course, several other configuration files are also available)
In the configuration file, change SyncBN to BN, and AdamW2 to Adam;
In the configuration file, the 146 lines of code remove the comments; the 147-150 codes add comments, as shown below
file_client_args = dict(backend='disk')
# file_client_args = dict(
# backend='petrel',
# path_mapping=dict({
# data_root: 'public-1424:s3://openmmlab/datasets/detection3d/nuscenes/'}))
conda install setuptools==58.0.4
load_from
parameter points to the address of the pre-training model downloaded in step 1. If you don’t know the relative path, you can directly give the absolute path. Here I am the relative pathload_from = 'pretrained_models/cascade_mask_rcnn_r18_fpn_coco-mstrain_3x_20e_nuim_bbox_mAP_0.5110_segm_mAP_0.4070.pth'
python tools/train.py configs/fastbev/exp/paper/fastbev_m0_r18_s256x704_v200x200x4_c192_d2_f4.py --work-dir work_dir --gpu-ids 0
Parameter Description
--gpu-ids 0代表gpu使用第1块。本机只有一块gpu
--work-dir 输出文件目录,包含日志等文件
其他参数详情建train.py中parse_args()函数
The content in the red box in the following figure appears on the terminal, which means that the training has been successfully run. The specific training cycle epoch, batch_size and other parameters can be fastbev_m0_r18_s256x704_v200x200x4_c192_d2_f4.py
modified in the configuration file
Solution 1: Click the line above the red box to jump to the error file and comment out the code using distutils
Scenario 2:
AttributeError: module 'distutils' has no attribute 'version'
conda install setuptools==58.0.4
Remove the comments on line 146, add comments on lines 147-150
Change SyncBN to BN
Replace AdamW2 with Adam
Due to the limited video memory of my own graphics card, the test results of the trained model are not ideal, so I directly use the trained model provided by the original author for testing, download link
I used fastbev_m0_r18_s256x704_v200x200x4_c192_d2_f4中epoch_20.pth
, download address
python tools/test.py configs/fastbev/exp/paper/fastbev_m0_r18_s256x704_v200x200x4_c192_d2_f4.py pretrained_models/epoch_20.pth --out output/result.pkl
--out 必须跟.pkl后缀。用来保存检测结果
--show 不要加,加上会报错,可能原作者未优化好
Since an error will be reported when adding –show when the test runs the code, tools/misc/visualize_results.py
the result.pkl from the previous step can be generated as a video stream for display.
python tools/misc/visualize_results.py configs/fastbev/exp/paper/fastbev_m0_r18_s256x704_v200x200x4_c192_d2_f4.py --result output/result.pkl --show-dir show_dir
assert len(_list) == len(sort)
Solution: Fast -BEV/mmdet3d/datasets/nuscenes monocular_dataset.py
, find line 192 and change it to line 193:
The solution, install these 2 packages:
pip install imageio[ffmpeg] imageio[pyav]
Finally run visualize_results.py to generate video_pred.mp4与video_gt.mp4
two videos:
One of the frames is visualized:
It is found that m5-r18
the effect of the model is not very good. Many of them only detect loneliness. You can try to use it m5-r50的epoch_20pth
. Download link
Thank you for your hard work, Resby ^-^
! !!
Author source code github address
Friends encountered problems during deployment, welcome to leave a message, welcome to bev exchange button 472648720, let's learn bev together!
If you think the article is good, one-click three consecutive support for one wave, Rui Sibai^-^
Author:Fiee
link:http://www.pythonblackhole.com/blog/article/80214/857bf4bfbb7ed459ff24/
source:python black hole net
Please indicate the source for any form of reprinting. If any infringement is discovered, it will be held legally responsible.
name:
Comment content: (supports up to 255 characters)
Copyright © 2018-2021 python black hole network All Rights Reserved All rights reserved, and all rights reserved.京ICP备18063182号-7
For complaints and reports, and advertising cooperation, please contact vgs_info@163.com or QQ3083709327
Disclaimer: All articles on the website are uploaded by users and are only for readers' learning and communication use, and commercial use is prohibited. If the article involves pornography, reactionary, infringement and other illegal information, please report it to us and we will delete it immediately after verification!