# CenterNet.pytorch **Repository Path**: Btreee/CenterNet.pytorch ## Basic Information - **Project Name**: CenterNet.pytorch - **Description**: No description available - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-08-16 - **Last Updated**: 2021-08-16 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # CenterNet模型PyTorch离线推理指导 ## 1 环境准备 1.安装必要的依赖,测试环境可能已经安装其中的一些不同版本的库了,故手动测试时不推荐使用该命令安装 ``` pip3.7 install -r requirements.txt ``` 2.获取,修改与安装开源模型代码 ``` cd CenterNet git clone https://github.com/xingyizhou/CenterNet cd CenterNet patch p1 < dcn.patch cd /src/lib/external make cd ../model/network/DCNv2 bash make.sh ``` 另外,需要单独修改python环境中的utils.py文件 ``` cd /usr/local/python3.7.5/lib/python3.7/site-packages/torch/onnx patch p1 < environment.patch ``` 如果开源模型代码仓没有安装脚本,可以通过sys.path.append(r"./reid-strong-baseline")添加搜索路径,然后在pth2onnx脚本中就可以引用模型代码的函数或类~~ 3.获取权重文件 [ctdet_coco_dla_2x.pth](https://drive.google.com/open?id=1pl_-ael8wERdUREEnaIfqOV_VF2bEVRT),放在? 4.数据集 获取COCO数据集:获取[2017 Val images](http://images.cocodataset.org/zips/val2017.zip)以及[2017 Train/Val annotations](http://images.cocodataset.org/annotations/annotations_trainval2017.zip),解压后放在coco文件夹中 5.[获取benchmark工具](https://support.huawei.com/enterprise/zh/ascend-computing/cann-pid-251168373/software/) 将benchmark.x86_64放到当前目录 ## 2 离线推理 CenterNet模型pth2onnx脚本由于算子暂不支持cpu,故只能在gpu运行,故将pth2om.sh拆为pth2onnx.sh和onnx2om.sh 在gpu上: ``` bash test/pth2onnx.sh ``` 并将生成的CenterNet.onnx移到310上,路径为:{当前目录}/test 在310上: ``` bash test/onnx2om.sh bash test/eval_acc_perf.sh --datasets_path=/root/datasets ``` **评测结果:** | 模型 | 官网pth精度 | 310离线推理精度 | 基准性能 | 310性能 | | ------------- | ----------- | --------------- | -------- | --------- | | CenterNet bs1 | AP : 36.6 | AP : 36.4 | 23.25fps | 18.654fps | 备注: 原官网pth精度 AP : 37.4 是在线推理时keep_res(保持分辨率)的结果,但由于离线推理需要固定shape,故需要去掉keep_res(保持分辨率)。去掉keep_res(保持分辨率)后,跑在线推理精度评估得到 AP : 36.6 ,故以 AP : 36.6 作为精度基准 #加上TEST.NECK_FEAT "('before')" TEST.FEAT_NORM "('no')"导出的onnx可以进行离线推理 #不加TEST.NECK_FEAT "('before')" TEST.FEAT_NORM "('no')"导出的onnx转换的om精度与官网精度一致 onnx因包含npu自定义算子dcnv2而不能推理,且原模型中暂未实现batch 16的在线推理精度和性能测试。