参考网上的博客,出现各种错误,最大的是:
AssertionError: Samples in split doesn't match samples in predictions.
给了解决方案,也不知道那个数字是怎么来的。索性自己来一遍,参考了github issue。
第一步,下载数据集并解压:
wget https://www.nuscenes.org/data/v1.0-mini.tgz # Download the nuScenes mini split.
tar -xf v1.0-mini.tgz -C /data/sets/nuscenes # Uncompress the nuScenes mini split.
第二步,修改代码 tools/create_data.py
elif args.dataset == 'nuscenes' and args.version != 'v1.0-mini':
train_version = f'{args.version}-trainval'
nuscenes_data_prep(
root_path=args.root_path,
info_prefix=args.extra_tag,
version=train_version,
dataset_name='NuScenesDataset',
out_dir=args.out_dir,
max_sweeps=args.max_sweeps)
"""
test_version = f'{args.version}-test'
nuscenes_data_prep(
root_path=args.root_path,
info_prefix=args.extra_tag,
version=test_version,
dataset_name='NuScenesDataset',
out_dir=args.out_dir,
max_sweeps=args.max_sweeps)
"""
第三步,制作数据集
# 进入解压目录
cd /data/sets/nuscenes
# split重命名
mv v1.0-mini v1.0-trainval
python tools/create_data.py nuscenes(固定) --root-path ./data/nuscenes --out-dir ./data/nuscenes --extra-tag nuscenes(固定) --workers 20
第四步,修改配置文件
configs/base/datasets/nus-mini-mono3d.py
dataset_type = 'NuScenesDataset'
data_root = 'data/nuscenes/'
configs/fcos3d/fcos3d_r101-caffe-dcn_fpn_head-gn_8xb2-1x_nus-mini-mono3d.py
_base_ = [
'../_base_/datasets/nus-mini-mono3d.py', '../_base_/models/fcos3d.py',
'../_base_/schedules/mmdet-schedule-1x.py', '../_base_/default_runtime.py'
]
...
#batch_size 根据需要修改
train_dataloader = dict(
batch_size=4, num_workers=4, dataset=dict(pipeline=train_pipeline))
test_dataloader = dict(dataset=dict(pipeline=test_pipeline))
val_dataloader = dict(dataset=dict(pipeline=test_pipeline))
...
# 修改训练epoch
# learning rate
param_scheduler = [
dict(
type='LinearLR',
start_factor=1.0 / 3,
by_epoch=False,
begin=0,
end=200),
dict(
type='MultiStepLR',
begin=0,
end=12,
by_epoch=True,
milestones=[8, 11],
gamma=0.1)
]
第五步,多卡单卡训练
# 多卡训练
CUDA_VISIBLE_DEVICES=0,1 tools/dist_train.sh configs/fcos3d/fcos3d_r101-caffe-dcn_fpn_head-gn_8xb2-1x_nus-mini-mono3d.py 2
# 单卡训练
CUDA_VISIBLE_DEVICES=0 tools/dist_train.sh configs/fcos3d/fcos3d_r101-caffe-dcn_fpn_head-gn_8xb2-1x_nus-mini-mono3d.py 1
版权归原作者 FlyingAnt_ 所有, 如有侵权,请联系我们删除。