背景:
使用训练出来的.pth模型 ----> .onnx 模型 ----> .json .params .so 三件套
- 模型由格式pth 转 onnx
转换过程中建议用显卡直接专用,避免出现有关cuda的问题,并且完成这个过程后再装瀚博半导体载天VA1加速卡:
转换环境参考:ubuntu 18.04 OpenPCDet pointpillar v0.5.2 环境搭建与问题解决
安装过程:
$ conda create -n OpenPCDetv0602 python==3.7
$ conda activate OpenPCDetv0602
$ python -m pip install spconv-cu102 -i https://mirror.baidu.com/pypi/simple
$ conda install pytorch==1.10.0 torchvision==0.11.0 torchaudio==0.10.0 cudatoolkit=10.2 -c pytorch
打开 requirements.txt 把有关 pytorch 的注释掉
$ gedit requirements.txt
numpy
llvmlite
numba
#torch>=1.1
tensorboardX
easydict
pyyaml
scikit-image
tqdm
torchvision
SharedArray
opencv-python
$ python -m pip install -r requirements.txt -i https://mirror.baidu.com/pypi/simple
然后:
python setup.py develop
记得每次 pytorch 版本变动,都得 python setup.py develop,重新生成.so 动态库
用的配置文件根据自己的需要修改,pointpillar_single_head.yaml:
CLASS_NAMES: ['car', 'truck', 'bus', 'non_motor_vehicles', 'pedestrians']
DATA_CONFIG:
_BASE_CONFIG_: cfgs/dataset_configs/kitti_dataset.yaml
POINT_CLOUD_RANGE: [0, -49.6, -1,80, 49.6, 4] #[0, -49.6, -3,80, 49.6, 1]
DATA_PROCESSOR:
- NAME: mask_points_and_boxes_outside_range
REMOVE_OUTSIDE_BOXES: True
- NAME: shuffle_points
SHUFFLE_ENABLED: {
'train': True,
'test': False
}
- NAME: transform_points_to_voxels
VOXEL_SIZE: [0.2, 0.2, 5]
MAX_POINTS_PER_VOXEL: 32
MAX_NUMBER_OF_VOXELS: {
'train': 16000,
'test': 40000
}
DATA_AUGMENTOR:
DISABLE_AUG_LIST: ['placeholder']
AUG_CONFIG_LIST:
- NAME: gt_sampling
USE_ROAD_PLANE: False
DB_INFO_PATH:
- kitti_dbinfos_train.pkl
PREPARE: {
filter_by_min_points: ['car:5', 'truck:5', 'bus:5', 'non_motor_vehicles:5', 'pedestrians:5'],
filter_by_difficulty: [-1],
}
SAMPLE_GROUPS: ['car:20', 'truck:20', 'bus:20', 'non_motor_vehicles:15', 'pedestrians:15']
NUM_POINT_FEATURES: 4
DATABASE_WITH_FAKELIDAR: False
REMOVE_EXTRA_WIDTH: [0.0, 0.0, 0.0]
LIMIT_WHOLE_SCENE: False
- NAME: random_world_flip
ALONG_AXIS_LIST: ['x']
- NAME: random_world_rotation
WORLD_ROT_ANGLE: [-0.78539816, 0.78539816]
- NAME: random_world_scaling
WORLD_SCALE_RANGE: [0.95, 1.05]
MODEL:
NAME: PointPillar
VFE:
NAME: PillarVFE
WITH_DISTANCE: False
USE_ABSLOTE_XYZ: True
USE_NORM: True
NUM_FILTERS: [64]
MAP_TO_BEV:
NAME: PointPillarScatter
NUM_BEV_FEATURES: 64
BACKBONE_2D:
NAME: BaseBEVBackbone
LAYER_NUMS: [3, 5, 5]
LAYER_STRIDES: [2, 2, 2]
NUM_FILTERS: [64, 128, 256]
UPSAMPLE_STRIDES: [1, 2, 4]
NUM_UPSAMPLE_FILTERS: [128, 128, 128]
DENSE_HEAD:
NAME: AnchorHeadSingle
CLASS_AGNOSTIC: False
USE_DIRECTION_CLASSIFIER: True
DIR_OFFSET: 0.78539
DIR_LIMIT_OFFSET: 0.0
NUM_DIR_BINS: 2
ANCHOR_GENERATOR_CONFIG: [
{
'class_name': 'car',
'anchor_sizes': [ [ 4.6, 1.9, 1.7 ] ], #l,w,h
'anchor_rotations': [ 0, 1.57 ],
'anchor_bottom_heights': [ -0.005 ],
'align_center': False,
'feature_map_stride': 2,
'matched_threshold': 0.6,
'unmatched_threshold': 0.45
},
{
'class_name': 'truck',
'anchor_sizes': [ [ 7.2, 2.5, 2.7 ] ],
'anchor_rotations': [ 0, 1.57 ],
'anchor_bottom_heights': [ 0.016 ],
'align_center': False,
'feature_map_stride': 2,
'matched_threshold': 0.6,
'unmatched_threshold': 0.45
},
{
'class_name': 'bus',
'anchor_sizes': [ [ 10.0, 2.8, 3.2 ] ],
'anchor_rotations': [0, 1.57],
'anchor_bottom_heights': [ -0.056 ],
'align_center': False,
'feature_map_stride': 2,
'matched_threshold': 0.6,
'unmatched_threshold': 0.45
},
{
'class_name': 'non_motor_vehicles',
'anchor_sizes': [ [ 1.8, 0.81, 1.61 ] ],#1.98, 0.91, 1.52
'anchor_rotations': [ 0, 1.57 ],
'anchor_bottom_heights': [ 0.077 ],
'align_center': False,
'feature_map_stride': 2,
'matched_threshold': 0.5,
'unmatched_threshold': 0.35
},
{
'class_name': 'pedestrians',
'anchor_sizes': [ [ 0.7, 0.68, 1.65 ] ],# 0.83, 0.75, 1.66
'anchor_rotations': [ 0, 1.57 ],
'anchor_bottom_heights': [ 0.13 ],
'align_center': False,
'feature_map_stride': 2,
'matched_threshold': 0.5,
'unmatched_threshold': 0.35
}
]
TARGET_ASSIGNER_CONFIG:
NAME: AxisAlignedTargetAssigner
POS_FRACTION: -1.0
SAMPLE_SIZE: 512
NORM_BY_NUM_EXAMPLES: False
MATCH_HEIGHT: False
BOX_CODER: ResidualCoder
LOSS_CONFIG:
LOSS_WEIGHTS: {
'cls_weight': 1.0,
'loc_weight': 2.0,
'dir_weight': 0.2,
'code_weights': [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
}
POST_PROCESSING:
RECALL_THRESH_LIST: [0.3, 0.5, 0.7]
SCORE_THRESH: 0.3
OUTPUT_RAW_SCORE: False
EVAL_METRIC: kitti
NMS_CONFIG:
MULTI_CLASSES_NMS: False
NMS_TYPE: nms_gpu
NMS_THRESH: 0.01
NMS_PRE_MAXSIZE: 4096
NMS_POST_MAXSIZE: 500
OPTIMIZATION:
BATCH_SIZE_PER_GPU: 8
NUM_EPOCHS: 200
OPTIMIZER: adam_onecycle
LR: 0.003
WEIGHT_DECAY: 0.01
MOMENTUM: 0.9
MOMS: [0.95, 0.85]
PCT_START: 0.2
DIV_FACTOR: 10
DECAY_STEP_LIST: [35, 45]
LR_DECAY: 0.1
LR_CLIP: 0.0000001
LR_WARMUP: False
WARMUP_EPOCH: 1
GRAD_NORM_CLIP: 10
修改 export_ls.py:
import argparse
import glob
from pathlib import Path
import numpy as np
import torch
from pcdet.config import cfg, cfg_from_yaml_file
from pcdet.datasets import DatasetTemplate
from pcdet.models import build_network
from pcdet.utils import common_utils
from torch.onnx import register_custom_op_symbolic
from torch.onnx.symbolic_helper import parse_args
@parse_args("v","v","v","i","i","i","i")
def symbolic(g, pillar_features,
coords,
mask,
size_x,size_y,size_z,
size_features):
return g.op('custom::PointPillarScatterFunction',
pillar_features,
coords,
mask,
size_x,size_y,size_z,
size_features)
register_custom_op_symbolic("vacc::PointPillarScatterFunction", symbolic,11)
class DemoDataset(DatasetTemplate):
def __init__(self, dataset_cfg, class_names, training=True, root_path=None, logger=None, ext='.bin'):
"""
Args:
root_path:
dataset_cfg:
class_names:
training:
logger:
"""
super().__init__(
dataset_cfg=dataset_cfg, class_names=class_names, training=training, root_path=root_path, logger=logger
)
self.root_path = root_path
self.ext = ext
data_file_list = glob.glob(str(root_path / f'*{self.ext}')) if self.root_path.is_dir() else [self.root_path]
data_file_list.sort()
self.sample_file_list = data_file_list
def __len__(self):
return len(self.sample_file_list)
def __getitem__(self, index):
if self.ext == '.bin':
points = np.fromfile(self.sample_file_list[index], dtype=np.float32).reshape(-1, 4)
elif self.ext == '.npy':
points = np.load(self.sample_file_list[index])
else:
raise NotImplementedError
input_dict = {
'points': points,
'frame_id': index,
}
data_dict = self.prepare_data(data_dict=input_dict)
return data_dict
def parse_config():
parser = argparse.ArgumentParser(description='arg parser')
parser.add_argument('--cfg_file', type=str, default='cfgs_ls/config/pointpillar_single_head.yaml',
help='specify the config for demo')
parser.add_argument('--data_path', type=str, default='data/000006.bin',
help='specify the point cloud data file or directory')
parser.add_argument('--ckpt', type=str, default="../pointpillar_7728.pth", help='specify the pretrained model')
parser.add_argument('--ext', type=str, default='.bin', help='specify the extension of your point cloud data file')
parser.add_argument('--model_path', type=str, default='./', help='specify model file or directory')
args = parser.parse_args()
cfg_from_yaml_file(args.cfg_file, cfg)
return args, cfg
def main():
args, cfg = parse_config()
logger = common_utils.create_logger()
logger.info('-----------------Quick Demo of OpenPCDet-------------------------')
demo_dataset = DemoDataset(
dataset_cfg=cfg.DATA_CONFIG, class_names=cfg.CLASS_NAMES, training=False,
root_path=Path(args.data_path), ext=args.ext, logger=logger
)
logger.info(f'Total number of samples: \t{len(demo_dataset)}')
model = build_network(model_cfg=cfg.MODEL, num_class=len(cfg.CLASS_NAMES), dataset=demo_dataset)
print("model is:",model)
model.load_params_from_file(filename=args.ckpt, logger=logger, to_cpu=True)
############## onnx 导出################################
model_path = args.model_path + args.ckpt.split("/")[-1].split(".")[-2]+ ".onnx"
print(model_path)
np.set_printoptions(threshold=np.inf)
with torch.no_grad():
MAX_VOXELS = 12000
dummy_voxels = torch.zeros(
(MAX_VOXELS, 32, 10),
dtype=torch.float32,
device='cpu')
dummy_voxel_idxs = torch.zeros(
(MAX_VOXELS,4),
dtype=torch.int16,
device='cpu')
dummy_mask = torch.ones(
(1,MAX_VOXELS),
dtype=torch.int8,
device='cpu')
dummy_input = dict()
dummy_input['voxels'] = dummy_voxels
dummy_input['voxel_coords'] = dummy_voxel_idxs
dummy_input['mask'] = dummy_mask
#dummy_input['spatial_features'] = dummy_spatial_features
dummy_input['batch_size'] = 1
torch.onnx.export(model, # model being run
dummy_input, # model input (or a tuple for multiple inputs)
model_path, # where to save the model (can be a file or file-like object)
export_params=True, # store the trained parameter weights inside the model file
opset_version=9, # the ONNX version to export the model to
do_constant_folding=True, # whether to execute constant folding for optimization
keep_initializers_as_inputs=True,
#custom_opsets = 10
input_names = ['voxels', 'voxel_coords', 'mask'], # the model's input names
#input_names = ['spatial_features',],
output_names = ['cls_preds', 'box_preds', 'dir_cls_preds'], # the model's output names
)
print("export ok")
exit(0)
if __name__ == '__main__':
main()
转换模型:
$ python export_ls.py --ckpt /home/wxf/vacc/OpenPCDet/tools/checkpoint_epoch_191.pth
转换模型中出现一些问题时,不妨提高 pytorch 的版本,之前 pytorch 1.8.1 时转换有问题,提高到 1.10.0 后,成功转换
此时:
$ conda list
# packages in environment at /home/xxx/3rdparty/anaconda3/envs/OpenPCDetv0602:
#
# Name Version Build Channel
_libgcc_mutex 0.1 main https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
_openmp_mutex 5.1 1_gnu https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
blas 1.0 mkl https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
bzip2 1.0.8 h7b6447c_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
ca-certificates 2023.01.10 h06a4308_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
ccimport 0.4.2 pypi_0 pypi
certifi 2022.12.7 py37h06a4308_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
charset-normalizer 3.1.0 pypi_0 pypi
cudatoolkit 10.2.89 hfd86e86_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
cumm-cu102 0.4.7 pypi_0 pypi
easydict 1.10 pypi_0 pypi
ffmpeg 4.3 hf484d3e_0 pytorch
fire 0.5.0 pypi_0 pypi
flit-core 3.6.0 pyhd3eb1b0_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
freetype 2.12.1 h4a9f257_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
giflib 5.2.1 h5eee18b_3 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
gmp 6.2.1 h295c915_3 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
gnutls 3.6.15 he1e5248_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
idna 3.4 pypi_0 pypi
imageio 2.26.0 pypi_0 pypi
importlib-metadata 6.0.0 pypi_0 pypi
intel-openmp 2021.4.0 h06a4308_3561 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
jpeg 9e h5eee18b_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
lame 3.100 h7b6447c_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
lark 1.1.5 pypi_0 pypi
lcms2 2.12 h3be6417_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
lerc 3.0 h295c915_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libdeflate 1.17 h5eee18b_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libedit 3.1.20221030 h5eee18b_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libffi 3.2.1 hf484d3e_1007 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libgcc-ng 11.2.0 h1234567_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libgomp 11.2.0 h1234567_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libiconv 1.16 h7f8727e_2 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libidn2 2.3.2 h7f8727e_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libpng 1.6.39 h5eee18b_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libstdcxx-ng 11.2.0 h1234567_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libtasn1 4.16.0 h27cfd23_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libtiff 4.5.0 h6a678d5_2 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libunistring 0.9.10 h27cfd23_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libuv 1.44.2 h5eee18b_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libwebp 1.2.4 h11a3e52_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libwebp-base 1.2.4 h5eee18b_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
llvmlite 0.39.1 pypi_0 pypi
lz4-c 1.9.4 h6a678d5_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
mkl 2021.4.0 h06a4308_640 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
mkl-service 2.4.0 py37h7f8727e_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
mkl_fft 1.3.1 py37hd3c417c_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
mkl_random 1.2.2 py37h51133e4_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
ncurses 6.4 h6a678d5_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
nettle 3.7.3 hbbd107a_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
networkx 2.6.3 pypi_0 pypi
ninja 1.11.1 pypi_0 pypi
numba 0.56.4 pypi_0 pypi
numpy 1.21.6 pypi_0 pypi
numpy-base 1.21.5 py37ha15fc14_3 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
opencv-python 4.7.0.72 pypi_0 pypi
openh264 2.1.1 h4ff587b_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
openssl 1.0.2u h7b6447c_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
packaging 23.0 pypi_0 pypi
pccm 0.4.6 pypi_0 pypi
pcdet 0.6.0+31f6758 dev_0 <develop>
pillow 9.4.0 py37h6a678d5_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
pip 22.3.1 py37h06a4308_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
portalocker 2.7.0 pypi_0 pypi
protobuf 3.20.3 pypi_0 pypi
pybind11 2.10.3 pypi_0 pypi
python 3.7.0 h6e4f718_3 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
pytorch 1.10.0 py3.7_cuda10.2_cudnn7.6.5_0 pytorch
pytorch-mutex 1.0 cuda pytorch
pywavelets 1.4.0 pypi_0 pypi
pyyaml 6.0 pypi_0 pypi
readline 7.0 h7b6447c_5 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
requests 2.28.2 pypi_0 pypi
scikit-image 0.19.3 pypi_0 pypi
scipy 1.7.3 pypi_0 pypi
setuptools 65.6.3 py37h06a4308_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
sharedarray 3.2.2 pypi_0 pypi
six 1.16.0 pyhd3eb1b0_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
spconv-cu102 2.3.3 pypi_0 pypi
sqlite 3.33.0 h62c20be_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
tensorboardx 2.6 pypi_0 pypi
termcolor 2.2.0 pypi_0 pypi
tifffile 2021.11.2 pypi_0 pypi
tk 8.6.12 h1ccaba5_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
torchaudio 0.10.0 py37_cu102 pytorch
torchvision 0.11.0 py37_cu102 pytorch
tqdm 4.65.0 pypi_0 pypi
typing-extensions 4.5.0 pypi_0 pypi
typing_extensions 4.4.0 py37h06a4308_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
urllib3 1.26.15 pypi_0 pypi
wheel 0.38.4 py37h06a4308_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
xz 5.2.10 h5eee18b_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
zipp 3.15.0 pypi_0 pypi
zlib 1.2.13 h5eee18b_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
zstd 1.5.2 ha4553b6_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- 模型由格式onnx 转 模型三件套
卸掉显卡,安装瀚博半导体载天VA1 加速卡
查看驱动环境:
$ sudo dpkg --get-selections | grep vastai
vastai-pci-d2-4-v2-1-a1-3-hv-hwtype-2-dkms install
这个时候也需要python环境,为了避免干扰重新建立一个Python 虚拟环境
因为 vamc 是配Python 3.7 的,所以虚拟环境 Python 的版本 为3.7
$ conda create --name VACC python=3.7
$ conda activate VACC
$ /xxx/1_模型转换工具/vamc工具使用/2.1.0/vamc_2.1.0
$ python -m pip install --no-cache-dir \
-r requirements.txt -i https://mirror.baidu.com/pypi/simple
$ cd ..
$ pip install vamc-2.1.0-cp37-cp37m-linux_x86_64.whl
然后;
$ vamc
Usage: vamc [OPTIONS] COMMAND [ARGS]...
vamc Command Line Interface.
vamc provides a unified API for deploy and run vastai model zoo.
Options:
--modelType show vamc support modelType and exit.
--version Show the version and exit.
-h, --help Show this message and exit.
此时不能使用 vamc build 命令
$ vamc build
Usage: vamc [OPTIONS] COMMAND [ARGS]...
Try 'vamc -h' for help.
Error: No such command 'build'.
需要改变环境变量:
$ cd /xxx/vaststream
$ gedit env.sh
修改 env.sh 中的 export VASTSTREAM_HOME
#!/bin/bash
export VASTSTREAM_HOME=/xxx/vaststream
export LIBVA_DRIVER_NAME=hantro
export VACC_IRTEXT_ENABLE=1
export VASTSTREAM_PIPELINE=true
export TVM_HOME=$VASTSTREAM_HOME/tvm
export PYTHONPATH=$TVM_HOME/python:$TVM_HOME/topi/python:$TVM_HOME/vacc/python
export OS_NAME=ubuntu
export OS_VERSION=18.04
export LD_LIBRARY_PATH=$TVM_HOME/lib:$VASTSTREAM_HOME/lib:$LD_LIBRARY_PATH
export PATH=$VASTSTREAM_HOME/tool/:$PATH
$ source env.sh
$ vamc
[03/14/23-11:10:47][I][global]: *****************************************************
[03/14/23-11:10:47][I][global]: Hardware name is vacc
[03/14/23-11:10:47][I][global]: DLC core number is 8
[03/14/23-11:10:47][I][global]: DLC big core number is 4
[03/14/23-11:10:47][I][global]: DLC tiny core number is 4
[03/14/23-11:10:47][I][global]: CE batch channel max is 192
[03/14/23-11:10:47][I][global]: PEP batch channel max is 128
[03/14/23-11:10:47][I][global]: TIEQ FIFO SIZE is 256
[03/14/23-11:10:47][I][global]: ODMA has 2 workers
[03/14/23-11:10:47][I][global]: Bank size of SRAM is 5120K
[03/14/23-11:10:47][I][global]: Sram alignment is 128 bytes
[03/14/23-11:10:47][I][global]: Capacity of big core's wdbuf is 4096K
[03/14/23-11:10:47][I][global]: Capacity of tiny core's wdbuf is 2048K
[03/14/23-11:10:47][I][global]: Bank size of WDBUF is 128K
[03/14/23-11:10:47][I][global]: Wdbuf alignment is 256 bytes
[03/14/23-11:10:47][I][global]: Margin for wdbuf weight area is 4096 bytes
[03/14/23-11:10:47][I][global]: *****************************************************
[03/14/23-11:10:47][I][global]: Stage cost time: 0.0s
Usage: vamc [OPTIONS] COMMAND [ARGS]...
vamc Command Line Interface.
vamc provides a unified API for deploy and run vastai model zoo.
Options:
--modelType show vamc support modelType and exit.
--version Show the version and exit.
-h, --help Show this message and exit.
Commands:
build convert front frame model to static vacc model
build-dynamic convert front frame model to dynamic vacc model
run debug engine model.
run-dynamic debug dynamic engine model.
修改 cfg_ls.yaml;
model:
name: pointpillar
inputs:
voxels: [16000, 32, 10]
voxel_coords: [3, 16000]
mask: [1, 16000]
checkpoint: /xxx/OpenPCDet1/tools/checkpoint_epoch_191.onnx
engine:
type: vacc
common:
do_quantization: true
add_extra_ops_to_graph:
type: pointpillar_nms
params:
point_cloud_range: [0.0, -49.6, -1, 80, 49.6, 4]
voxel_size: [0.2, 0.2, 5]
grid_stride: [2, 2, 2]
num_classes: 5
nms_topk: 4096
post_nms: 500
confidence_thresh: 0.1
nms_thresh: 0.02
dir_offset: 0.78539
dir_limit_offset: 0.0
anchor_size: [4.6, 1.9, 1.7, 7.2, 2.5, 2.7,10.2, 2.8,3.2,1.8,0.81,1.61,0.7,0.68,1.68]
anchor_rotations: [0.0, 1.57,0.0, 1.57,0.0, 1.57,0.0, 1.57,0.0, 1.57]
anchor_heights: [0, 0, 0, 0, 0]
calibration:
quant_mode: percentile
per_channel: true
skip_conv_layers: [0]
dataset:
path: /media/xxx/Elements/data/POINTPILLAR/bin_addZ_npy
sampler:
get_data_num: 253
workspace:
work_dir: /media/xxx/Elements/data/POINTPILLAR/model
enable_ir: false
save_log: false
模型转换:
vamc build /xxx/vaststream/sample/config/cfg_ls.yaml
在/media/xxx/Elements/data/POINTPILLAR/model 目录下, 成功生成:
$ tree
.
└── pointpillar-int8-percentile-mutil_input-vacc
├── pointpillar.json
├── pointpillar.params
└── pointpillar.so
1 directory, 3 files
如果量化时数据有问题,看看 /media/xxx/Elements/data/POINTPILLAR/bin_addZ_npy目录下是否有空数据。
未完待续…
后续有问题继续整理。