diff --git a/contrib/Collision/README.md b/contrib/Collision/README.md index dfc22daf99d70be6f17cb7e5a5669fe078501462..0502845021e5959506398b802d4073cf8fcd656b 100644 --- a/contrib/Collision/README.md +++ b/contrib/Collision/README.md @@ -1,22 +1,11 @@ # 车辆碰撞识别 ## 1 介绍 -此项目的碰撞插件基于MindXSDK开发,在昇腾芯片上进行目标检测和跟踪,可以对车辆进行画框和编号,检测到车辆碰撞后,可将动向编号提示为“Collision”并将检测结果可视化并保存。 +### 1.1 简介 +此项目的碰撞插件基于mxVision开发,在昇腾芯片上进行目标检测和跟踪,可以对车辆进行画框和编号,检测到车辆碰撞后,可将动向编号提示为“Collision”并将检测结果可视化并保存。 项目主要流程为:通过live555服务器进行拉流输入视频,然后进行视频解码将264格式的视频解码为YUV格式的图片,图片缩放后经过模型推理进行车辆识别,识别结果经过yolov3后处理后得到识别框,对识别框进行跟踪并编号,用编号覆盖原有的类别信息,如检测到车辆发生碰撞,碰撞的车辆的编号将会被“Collision”所替换,再将识别框和类别信息分别转绘到图片上,最后将图片编码成视频进行输出。 -### 1.1 支持的产品 - -昇腾310(推理) - -### 1.2 支持的版本 - -本样例配套的CANN版本为[7.0.RC1](https://gitee.com/link?target=https%3A%2F%2Fwww.hiascend.com%2Fsoftware%2Fcann%2Fcommercial)。支持的SDK版本为[5.0.RC3](https://gitee.com/link?target=https%3A%2F%2Fwww.hiascend.com%2Fsoftware%2FMindx-sdk)。 - -MindX SDK安装前准备可参考《用户指南》,[安装教程](https://gitee.com/ascend/mindxsdk-referenceapps/blob/master/docs/quickStart/1-1安装SDK开发套件.md) - -### 1.3 特性及适用场景 - 本案例可以满足对视频的检测,对检测到的碰撞的车辆在碰撞时刻,输出“Collision”的字样进行提醒。经过测试我们可以知道有以下限制条件: 1.对一个正常清晰的路面,我们可以完成绝大多数正常的一个车辆碰撞检测。 @@ -25,9 +14,7 @@ MindX SDK安装前准备可参考《用户指南》,[安装教程](https://git 3.当车辆很密集时,障碍物很多时,就会导致物体画框增多,画框不同角度的重叠就可能导致碰撞误判。 -### 1.4 软件方案介绍 - -基于MindX SDK的车辆碰撞识别业务流程为:待检测视频存放在live555服务器上经mxpi_rtspsrc拉流插件输入,然后使用视频解码插件mxpi_videodecoder将视频解码成图片,再通过图像缩放插件mxpi_imageresize将图像缩放至满足检测模型要求的输入图像大小要求,缩放后的图像输入模型推理插件mxpi_tensorinfer得到检测结果,再经yolov3后处理插件处理推理结果,得到识别框。再接入跟踪插件中识别框进行目标跟踪,得到目标的跟踪编号,然后在使用mxpi_trackidreplaceclassname插件将跟踪编号覆盖类名信息,再接入本项目开发的碰撞检测插件mxpi_collisionclassname,使用mxpi_object2osdinstances和mxpi_opencvosd分别将识别框和类名(更替写入跟踪编号或者“Collison”碰撞提醒)绘制到原图片,再通过mxpi_videoencoder将图片合成视频 +本案例的车辆碰撞识别业务流程为:待检测视频存放在live555服务器上经mxpi_rtspsrc拉流插件输入,然后使用视频解码插件mxpi_videodecoder将视频解码成图片,再通过图像缩放插件mxpi_imageresize将图像缩放至满足检测模型要求的输入图像大小要求,缩放后的图像输入模型推理插件mxpi_tensorinfer得到检测结果,再经yolov3后处理插件处理推理结果,得到识别框。再接入跟踪插件中识别框进行目标跟踪,得到目标的跟踪编号,然后在使用mxpi_trackidreplaceclassname插件将跟踪编号覆盖类名信息,再接入本项目开发的碰撞检测插件mxpi_collisionclassname,使用mxpi_object2osdinstances和mxpi_opencvosd分别将识别框和类名(更替写入跟踪编号或者“Collison”碰撞提醒)绘制到原图片,再通过mxpi_videoencoder将图片合成视频 表1.1 系统方案各子系统功能描述: @@ -47,93 +34,79 @@ MindX SDK安装前准备可参考《用户指南》,[安装教程](https://git | 12 | OSD可视化插件 | 主要实现对每帧图像标注跟踪结果。 | | 13 | 视频编码插件 | 用于将OSD可视化插件输出的图片进行视频编码,输出视频。 | -### 1.5 代码目录结构与说明 - -``` -├── model -│ ├── aipp_yolov3_416_416.aippconfig # 模型转换aipp配置文件 -│ ├── coco.names # 类名 -│ ├── yolov3.cfg # yolov3配置文件 -│ └── yolov3.om # om模型 -│ -├── plugins -│ ├── MxpiCollisionClassName # 碰撞检测插件 -│ │ ├── CMakeLists.txt -│ │ ├── MxpiCollisionClassName.cpp -│ │ ├── MxpiCollisionClassName.h -│ │ └── build.sh -│ └── MxpiTrackIdReplaceClassName # 跟踪编号取代类名插件 -│ ├── CMakeLists.txt -│ ├── MxpiTrackIdReplaceClassName.cpp -│ ├── MxpiTrackIdReplaceClassName.h -│ └── build.sh -│ -├── build.sh -├── collision.pipeline # pipeline文件 -└── collision.py -``` - -### 1.6 技术实现流程图 +本案例的技术实现流程图如下所示: ![SDK流程图](../Collision/image/SDK_process.png) 注:红色为本项目开发插件 蓝色为沿用其他项目开发插件 其余为SDK内置插件 +### 1.2 支持的产品 -## 2 环境依赖 - -推荐系统为ubuntu 18.04,环境依赖软件和版本如下表: +本项目以昇腾Atlas 300I pro和 Atlas300V pro为主要的硬件平台。 -| 软件名称 | 版本 | 说明 | 获取方式 | -| ------------------- | ----------- | ----------------------------- | ------------------------------------------------------------ | -| MindX SDK | 5.0.RC3 | mxVision软件包 | [链接](https://gitee.com/link?target=https%3A%2F%2Fwww.hiascend.com%2Fsoftware%2FMindx-sdk) | -| ubuntu | 18.04.1 LTS | 操作系统 | Ubuntu官网获取 | -| Ascend-CANN-toolkit | 7.0.RC1 | Ascend-cann-toolkit开发套件包 | [链接](https://gitee.com/link?target=https%3A%2F%2Fwww.hiascend.com%2Fsoftware%2Fcann%2Fcommercial) | +### 1.3 支持的版本 -在编译运行项目前,需要设置环境变量: +| MxVision版本 | CANN版本 | Driver/Firmware版本 | + | --------- | ------------------ | -------------- | +| 6.0.RC3 | 8.0.RC3 | 24.1.RC3 | -- 环境变量介绍 +### 1.4 代码目录结构与说明 ``` -export MX_SDK_HOME=${SDK安装路径}/mxVision -export install_path=/usr/local/Ascend/ascend-toolkit/latest -export PATH=/usr/local/python3.9.2/bin:${install_path}/atc/ccec_compiler/bin:${install_path}/atc/bin:$PATH -export ASCEND_OPP_PATH=${install_path}/opp -export ASCEND_AICPU_PATH=${install_path} -export LD_LIBRARY_PATH=${install_path}/atc/lib64:${MX_SDK_HOME}/lib:${MX_SDK_HOME}/opensource/lib:$LD_LIBRARY_PATH -export GST_PLUGIN_SCANNER=${MX_SDK_HOME}/opensource/libexec/gstreamer-1.0/gst-plugin-scanner -export GST_PLUGIN_PATH=${MX_SDK_HOME}/opensource/lib/gstreamer-1.0:${MX_SDK_HOME}/lib/plugins -#用于设置python3.9.2库文件路径 -export LD_LIBRARY_PATH=/usr/local/python3.9.2/lib:$LD_LIBRARY_PATH -#如果用户环境存在多个python3版本,则指定使用python3.9.2版本 -export PATH=/usr/local/python3.9.2/bin:$PATH -``` - -注:其中SDK安装路径${MX_SDK_HOME}替换为用户的SDK安装路径;install_path替换为开发套件包所在路径。LD_LIBRARY_PATH用以加载开发套件包中lib库。 +├── build.sh +├── collision.pipeline # pipeline文件 +├── collision.py +├── image +│ ├── after_collision.png +│ ├── before_collision.png +│ ├── collision.png +│ ├── error.png +│ ├── SDK_process.png +│ └── video_conversion.png +├── model +│ ├── aipp_yolov3_416_416.aippconfig # 模型转换aipp配置文件 +│ ├── coco.names # 类名 +│ └── yolov3.cfg # yolov3配置文件 +├── plugins +│ ├── MxpiCollisionClassName # 碰撞检测插件 +│ │ ├── build.sh +│ │ ├── CMakeLists.txt +│ │ ├── MxpiCollisionClassName.cpp +│ │ └── MxpiCollisionClassName.h +│ └── MxpiTrackIdReplaceClassName # 跟踪编号取代类名插件 +│ ├── build.sh +│ ├── CMakeLists.txt +│ ├── MxpiTrackIdReplaceClassName.cpp +│ └── MxpiTrackIdReplaceClassName.h +└── README.md +``` -## 3 依赖安装 -推理中涉及到第三方软件依赖如下表所示。 +## 2 设置环境变量 -| 依赖软件 | 版本 | 说明 | 使用教程 | -| -------- | ---------- | ------------------------------ | -----------------------------------------------------------: | -| live555 | 1.09 | 实现视频转rstp进行推流 | [链接]([guide/mindx/sdk/tutorials/reference_material/Live555离线视频转RTSP说明文档.md · Ascend/docs-openmind - Gitee.com](https://gitee.com/ascend/docs-openmind/blob/master/guide/mindx/sdk/tutorials/reference_material/Live555离线视频转RTSP说明文档.md)) | -| ffmpeg | 2021-07-21 | 实现mp4格式视频转为264格式视频 | [链接]([guide/mindx/sdk/tutorials/reference_material/pc端ffmpeg安装教程.md · Ascend/docs-openmind - Gitee.com](https://gitee.com/ascend/docs-openmind/blob/master/guide/mindx/sdk/tutorials/reference_material/pc端ffmpeg安装教程.md)) | -| python | 3.9.2 | 与SDK配套 | [链接]([Linux(Ubuntu)系统安装Python (biancheng.net)](http://c.biancheng.net/view/4162.html)) | +在执行后续步骤前,需要设置环境变量: +```bash +# 执行环境变量脚本使环境变量生效 +. ${ascend-toolkit-path}/set_env.sh +. ${mxVision-path}/set_env.sh +# mxVision-path: mxVision安装路径 +# ascend-toolkit-path: CANN安装路径 +``` -## 4 模型转换 +## 3 准备模型 +**步骤1** 下载模型相关文件 -本项目中适用的模型是yolov3模型,yolov3模型可以在昇腾官网ModelZoo直接下载:[YOLOv3-昇腾社区 (hiascend.com)]([ATC YOLOv3(FP16)-昇腾社区 (hiascend.com)](https://mindx.sdk.obs.cn-north-4.myhuaweicloud.com/mindxsdk-referenceapps%20/contrib/ActionRecognition/ATC%20YOLOv3%28FP16%29%20from%20TensorFlow%20-%20Ascend310.zip))。下载后使用模型转换工具 ATC 将 pb 模型转换为 om 模型,模型转换工具相关介绍参考链接:[https://gitee.com/ascend/docs-openmind/blob/master/guide/mindx/sdk/tutorials/%E5%8F%82%E8%80%83%E8%B5%84%E6%96%99.md](https://gitee.com/ascend/docs-openmind/blob/master/guide/mindx/sdk/tutorials/%E5%8F%82%E8%80%83%E8%B5%84%E6%96%99.md) 。 +根据[链接](https://mindx.sdk.obs.cn-north-4.myhuaweicloud.com/mindxsdk-referenceapps%20/contrib/ActionRecognition/ATC%20YOLOv3%28FP16%29%20from%20TensorFlow%20-%20Ascend310.zip)下载得到yolov3_tf.pb文件,并放到项目根目录的`model`文件夹。 -模型转换,步骤如下: +**步骤2** 转换模型格式 -从上述下载链接中下载yolov3模型解压缩文件yolov3_tf.pb至 ./model 文件夹下,进入 `./models` 文件夹下执行命令: +进入项目根目录的`model`文件夹下执行命令: ``` -atc --model=./yolov3_tf.pb --framework=3 --output=./yolov3 --soc_version=Ascend310 --insert_op_conf=./aipp_yolov3_416_416.aippconfig --input_shape="input:1,416,416,3" --out_nodes="yolov3/yolov3_head/Conv_6/BiasAdd:0;yolov3/yolov3_head/Conv_14/BiasAdd:0;yolov3/yolov3_head/Conv_22/BiasAdd:0" +atc --model=./yolov3_tf.pb --framework=3 --output=./yolov3 --soc_version=Ascend310P3 --insert_op_conf=./aipp_yolov3_416_416.aippconfig --input_shape="input:1,416,416,3" --out_nodes="yolov3/yolov3_head/Conv_6/BiasAdd:0;yolov3/yolov3_head/Conv_14/BiasAdd:0;yolov3/yolov3_head/Conv_22/BiasAdd:0" ``` 执行该命令后会在当前文件夹下生成项目需要的模型文件 yolov3.om。执行后终端输出为: @@ -146,123 +119,53 @@ ATC run success, welcome to the next use. 表示命令执行成功。 +## 4 编译与运行 -## 5 准备 +**步骤1** 启动rtsp服务 -按照第3小结**软件依赖**安装live555和ffmpeg,按照 [Live555离线视频转RTSP说明文档]([guide/mindx/sdk/tutorials/reference_material/Live555离线视频转RTSP说明文档.md · Ascend/docs-openmind - Gitee.com](https://gitee.com/ascend/docs-openmind/blob/master/guide/mindx/sdk/tutorials/reference_material/Live555离线视频转RTSP说明文档.md))将mp4视频转换为h264格式。并将生成的264格式的视频上传到`live/mediaServer`目录下,然后修改collision.pipeline文件中mxpi_rtspsrc0的内容。 +按照 [教程](https://gitee.com/ascend/mindxsdk-referenceapps/blob/master/docs/%E5%8F%82%E8%80%83%E8%B5%84%E6%96%99/Live555%E7%A6%BB%E7%BA%BF%E8%A7%86%E9%A2%91%E8%BD%ACRTSP%E8%AF%B4%E6%98%8E%E6%96%87%E6%A1%A3.md) 自行准备视频数据,并启动rtsp服务。 -``` - "mxpi_rtspsrc0": { - "factory": "mxpi_rtspsrc", - "props": { - "rtspUrl":"rtsp://xxx.xxx.xxx.xxx:xxxx/xxx.264", // 修改为自己所使用的的服务器和文件名 - "channelId": "0" - }, - "next": "mxpi_videodecoder0" - }, -``` - -我们默认ffmpeg转换视频为264格式时,分辨率统一为1280*720,如果自己需要更改分辨率,请同时修改collision.pipeline文件中mxpi_videoencoder0的"imageHeight"和"imageWidth"内容。 +**步骤2** 修改collision.pipeline配置文件 - "mxpi_videoencoder0": { - "props": { - "inputFormat": "YUV420SP_NV12", - "outputFormat": "H264", - "fps": "1", - "iFrameInterval": "50", - "imageHeight":"720", - "imageWidth":"1280" - }, - "factory": "mxpi_videoencoder", - "next": "queue7" - }, -## 6 编译与运行 +第**9**行 `"rtspUrl":"rtsp://xxx.xxx.xxx.xxx:xxxx/xxx.264"`中的rtsp://xxx.xxx.xxx.xxx:xxxx/xxx.264替换为可用的 rtsp 流地址。 -**步骤1** 按照第2小结**环境依赖**中的步骤设置环境变量。 +第**152**行 `"imageHeight":"720"`中的720替换为视频帧实际的高。 -**步骤2** 按照第 4 小节 **模型转换** 中的步骤获得 om 模型文件,放置在 `./model` 目录下。 +第**153**行 `"imageWidth":"1280"`中的1280替换为视频帧实际的宽。 -**步骤3** 修改`Collision/plugins/MxpiCollisionClassName`和`Collision/plugins/MxpiTrackIdReplaceClassName`文件夹下的CMakeLists.txt文件。将其中的"$ENV{MX_SDK_HOME}"修改成自己的SDK目录。 +**步骤3** 编译 -**步骤4** 编译。进入 `Collision` 目录,在 `Collision` 目录下执行命令: +进入mxVision安装目录的`operators/opencvosd`目录下执行命令: ``` -bash build.sh +bash generate_osd_om.sh ``` -命令执行成功后会在`Collision/plugins/MxpiCollisionClassName`和`Collision/plugins/MxpiTrackIdReplaceClassName`目录下分别生成build文件夹。将`Collision/plugins/MxpiTrackIdReplaceClassName/build`目录下生成的的libmxpi_trackidreplaceclassname.so下载后上传到`${SDK安装路径}/mxVision/lib/plugins`目录下,同时将`Collision/plugins/MxpiCollisionClassName/build`目录下生成的libmxpi_collisionclassname.so下载后上传到`${SDK安装路径}/mxVision/lib/plugins`目录下。 +进入 `Collision` 目录,在 `Collision` 目录下执行命令: -**步骤5** 运行。回到主目录下,在主目录下执行命令: - -``` -python3.9.2 collision.py ``` - -命令执行成功后会在当前目录下生成检测结果视频文件out_collision.h264,查看文件验证目标跟踪结果。 - - - -## 7 结果展示(部分截图) - -生成的out_collision.h264文件在本地我们可以用适配.h264文件格式的视频播放软件进行播放。也可以使用ffmpeg转换成.mp4格式进行本地播放。 - -``` -ffmpeg -i out_collision.h264 -vcodec h264 out_collision.mp4 -``` - -![碰撞前](../Collision/image/before_collision.png)![碰撞时](../Collision/image/collision.png)![碰撞后](../Collision/image/after_collision.png) - - - -## 8 性能测试 - -使用sdk自带的性能统计工具测试项目性能 - -**步骤1:**修改sdk插件性能统计工具的配置文件,文件位于 *${MX_SDK_HOME}/config/sdk.conf* - -``` -enable_ps=true #打开性能统计开关 - -ps_log_dir=logs #生成日志地址路径 - -ps_interval_time=1 #性能统计时间间隔,单位s +bash build.sh ``` -**步骤2:**执行运行命令 -``` -python3.9.2 collision.py -``` +**步骤4** 启动服务 -**步骤3:**在${ps_log_dir}下查看生成的性能日志,打开performance-statistics.log.tpr日式文件查看吞吐率,与推理视频帧率保持一致,满足实时性要求 +回到主目录下,在主目录下执行命令: ``` -{"streamName":"collision","throughput":33,"throughputRate":33,"type":"throughputRate"} -{"streamName":"collision","throughput":31,"throughputRate":31,"type":"throughputRate"} +python3 collision.py ``` +命令执行成功后会在标准输出实时打印已保存的视频帧数量。 -## 9 常见问题 - -视频编码参数配置错误 - -1.**问题描述:** - -`Collision/collision.pipeline`中视频编码分辨率参数已经手动指定imageHeight 和 imageWidth 属性,需要和视频输入分配率相同,否则会包如下类型的错: - -![error](../Collision/image/error.png) - -**解决方案:** - -确保`Collision/collision.pipeline`中 mxpi_videoencoder0 插件的 imageHeight 和 imageWidth 属性值是输入.h264视频的高和宽。此时我们可以在用ffmpeg进行视频拉流时找到设置.h264视频的高和宽。 +**步骤5** 停止服务 -2.**问题描述:** +命令行输入Ctrl+C组合键可手动停止服务。 -`Collision/collision.py`中视频帧数参数目前未确定,系统则会对缺省的视频拉流帧数进行识别并输出,所以会造成输出长视频不完整和短视频重复的结果。 +*考虑到保存检测结果的视频会占用较大存储空间,请用户合理控制服务运行时间、及时停止服务,避免视频文件过大、影响服务器正常工作。 -**解决方案:** -确保`Collision/collision.py`中第52行`if t > 'xxx'`的属性值是输入.h264视频帧数。此时我们可以在用ffmpeg进行视频拉流时找到设置.h264视频的帧数。 +**步骤6** 查看结果 -![视频格式转换](../Collision/image/video_conversion.png) \ No newline at end of file +命令执行成功后会在当前目录下生成检测结果视频文件out_collision.h264,打开out_collision.h264查看文件、观测目标跟踪结果。 diff --git a/contrib/Collision/collision.py b/contrib/Collision/collision.py index f2389fe78c0b05316d4b392ca585c3cebd7db39b..1d664ea522748bda1bced4dcaf03d231564d1df9 100644 --- a/contrib/Collision/collision.py +++ b/contrib/Collision/collision.py @@ -49,10 +49,7 @@ if __name__ == '__main__': fo.write(infer_result.data) T = T + 1 print(T) - # the toal frames of video - if T > 100: - print('ending') - break + fo.close() # destroy streams diff --git a/contrib/Collision/plugins/MxpiCollisionClassName/CMakeLists.txt b/contrib/Collision/plugins/MxpiCollisionClassName/CMakeLists.txt index 5926979a69e0b1b3582775f17a6721963d0f19c8..349ed8ac47e39b0d5c675df2bccc5d0ff5518f7f 100644 --- a/contrib/Collision/plugins/MxpiCollisionClassName/CMakeLists.txt +++ b/contrib/Collision/plugins/MxpiCollisionClassName/CMakeLists.txt @@ -18,7 +18,7 @@ include_directories(${MX_SDK_HOME}/opensource/lib/glib-2.0/include) link_directories(${MX_SDK_HOME}/lib) link_directories(${MX_SDK_HOME}/opensource/lib) -add_compile_options(-std=c++11 -fPIC -fstack-protector-all -pie -Wno-deprecated-declarations) +add_compile_options(-std=c++14 -fPIC -fstack-protector-all -pie -Wno-deprecated-declarations) add_compile_options("-DPLUGIN_NAME=${PLUGIN_NAME}") add_definitions(-DENABLE_DVPP_INTERFACE) @@ -28,3 +28,5 @@ add_library(${TARGET_LIBRARY} SHARED MxpiCollisionClassName.cpp) target_link_libraries(${TARGET_LIBRARY} glib-2.0 gstreamer-1.0 gobject-2.0 gstbase-1.0 gmodule-2.0) target_link_libraries(${TARGET_LIBRARY} mxpidatatype plugintoolkit mxbase mindxsdk_protobuf) + +install(TARGETS ${TARGET_LIBRARY} PERMISSIONS OWNER_READ GROUP_READ LIBRARY DESTINATION ${MX_SDK_HOME}/lib/plugins) diff --git a/contrib/Collision/plugins/MxpiTrackIdReplaceClassName/CMakeLists.txt b/contrib/Collision/plugins/MxpiTrackIdReplaceClassName/CMakeLists.txt index db54911597bd6084e5853b54e60e6d670667c3bc..8d7e8b2164df232d24e41ed3704a0dc3889e44e0 100644 --- a/contrib/Collision/plugins/MxpiTrackIdReplaceClassName/CMakeLists.txt +++ b/contrib/Collision/plugins/MxpiTrackIdReplaceClassName/CMakeLists.txt @@ -19,7 +19,7 @@ include_directories(${MX_SDK_HOME}/opensource/lib/glib-2.0/include) link_directories(${MX_SDK_HOME}/lib) link_directories(${MX_SDK_HOME}/opensource/lib) -add_compile_options(-std=c++11 -fPIC -fstack-protector-all -pie -Wno-deprecated-declarations) +add_compile_options(-std=c++14 -fPIC -fstack-protector-all -pie -Wno-deprecated-declarations) add_compile_options("-DPLUGIN_NAME=${PLUGIN_NAME}") add_definitions(-DENABLE_DVPP_INTERFACE) @@ -30,3 +30,5 @@ target_link_libraries(${TARGET_LIBRARY} glib-2.0 gstreamer-1.0 gobject-2.0 gstba target_link_libraries(${TARGET_LIBRARY} mxpidatatype plugintoolkit mxbase mindxsdk_protobuf) +install(TARGETS ${TARGET_LIBRARY} PERMISSIONS OWNER_READ GROUP_READ LIBRARY DESTINATION ${MX_SDK_HOME}/lib/plugins) + diff --git a/contrib/FCOS/README.md b/contrib/FCOS/README.md index c88789d5d55b1d4160c4ab672f0420f8c4945e60..b4681b8a34a4a1783392fcae2628ff59568b789e 100644 --- a/contrib/FCOS/README.md +++ b/contrib/FCOS/README.md @@ -2,126 +2,87 @@ ## 1 介绍 -本开发项目演示FCOS模型实现目标检测。本系统基于mxVision SDK进行开发,以昇腾Atlas310卡为主要的硬件平台,主要实现目标检测。待检测的图片中物体不能被遮挡太严重,并且物体要完全出现在图片中。图片亮度不能过低。输入一张图片,最后会输出图片中能检测到的物体。项目主要流程: +### 1.1 简介 -1.环境搭建; -2.模型转换; -3.生成后处理插件; -4.进行精度、性能对比。 +本开发项目演示FCOS模型实现目标检测。本项目使用的模型是FCOS目标检测模型这个模型是一个无anchor检测器。FCOS直接把预测特征图上的每个位置$(x,y)$当作训练样本,若这个位置在某个ground truth box的内部,则视为正样本,该位置的类别标签$c$对应这个box的类别,反之则视为负样本。这个网络的输出为目标框的左上角坐标、右下角坐标、类别和置信度。 -### 1.1支持的产品 - -本产品以昇腾310(推理)卡为硬件平台。 - -### 1.2支持的版本 - -该项目支持的SDK版本为5.0.0,CANN版本为7.0.0。 - -### 1.3软件方案介绍 - -基于MindXSDK的FCOS目标检测的业务流程为: - -1. 将待检测的图片放到相应的文件夹下。 -2. 首先使用mmcv库对图片进行前处理(改变图片大小、归一化、补边操作)。‘ -3. 将图片转换成为二进制的numpy数组,传入pipeline中。 -4. 放缩后的图片输入模型推理插件mxpi_tensorinfer进行处理; -5. 将经过模型推理输出时候的张量数据流输入到mxpi_objectpostprocessor中,对FCOS目标检测模型推理输出的张量进行后处理; -6. 处理完毕之后将数据传入mxpi_dataserialize0插件中,将stream结果组装成json字符串输出。 - -下表为系统方案各个子系统功能的描述: - -| 序号 | 子系统 | 功能描述 | -| ---- | ---------- | ---------------------------------------------------------------------------------------------------------------------- | -| 1 | 图片输入 | 传入图片,修改图片的大小和格式为符合模型要求的格式 | -| 2 | 图像前处理 | 对图片进行改变大小、补边、归一化等操作。 | -| 3 | 模型推理 | 将已经处理好的图片传入到mxpi_tensorinfer中,使用目标检测模型FCOS进行推理,得到推理的张量数据流 | -| 4 | 模型后处理 | 将模型推理得到的张量数据流传入mxpi_objectpostprocessor中进行张量后处理。对模型输出的目标框进行去重,排序和筛选等工作。 | -| 5 | 组装字符串 | stream结果组装成json字符串输出。 | - -### 1.4代码目录结构与说明 - -本项目名为FCOS目标检测,项目的目录如下所示: - -``` -|- models -| |- fcos.onnx //onnx模型 -| |_ Fcos_tf_bs.cfg -|- pipeline -| |_ FCOSdetection.pipeline -|- plugin -| |_FCOSPostprocess -| |- CMakeLists.txt -| |- FCOSDetectionPostProcess.cpp -| |- FCOSDetectionPostProcess.h -| |_ build.sh -|- image -| |- image1.png -| |_ image2.png -|- build.sh -|- evaluate.py -|- colorlist.txt -|_ main.py -``` - -### 1.5技术实现流程图 +本系统基于mxVision SDK进行开发,主要实现目标检测。待检测的图片中物体不能被遮挡太严重,并且物体要完全出现在图片中。图片亮度不能过低。输入一张图片,最后会输出图片中能检测到的物体信息、并输出可视化结果图片。 本项目实现对输入的图片进行目标检测,整体流程如下: ![avatar](./image/image1.png) -### 1.6特性以及适用场景 -本项目是根据COCO数据集进行训练,仅仅适合COCO官方数据集中的80类物体进行识别。在此这八十类物体不一一列出。 -## 2环境依赖 -推荐系统为ubuntu 18.04,环境软件和版本如下: -| 软件名称 | 版本 | 说明 | 获取方式 | -| ------------------- | ------ | ----------------------------- | ----------------------------------------------------------------- | -| MindX SDK | 5.0.0 | mxVision软件包 | [点击打开链接](https://www.hiascend.com/software/Mindx-sdk) | -| ubuntu | 18.04 | 操作系统 | 请上ubuntu官网获取 | -| Ascend-CANN-toolkit | 7.0.0 | Ascend-cann-toolkit开发套件包 | [点击打开链接](https://www.hiascend.com/software/cann/commercial) | -| mmdetection | 2.25.0 | 用于评估准确度 | 请上mmdetection官网 | +### 1.2 支持的产品 -在项目开始运行前需要设置环境变量: +本项目以昇腾x86_64 Atlas 300l (型号3010)和arm Atlas 300l (型号3000)为主要的硬件平台。 -``` -. /usr/local/Ascend/ascend-toolkit/set_env.sh -. ${SDK安装路径}/mxVision/set_env.sh -``` +### 1.3 支持的版本 -## 3 软件依赖 +| MxVision版本 | CANN版本 | Driver/Firmware版本 | +| --------- | ------------------ | -------------- | +| 5.0.0 | 7.0.0 | 23.0.0 | -项目运行过程中涉及到的第三方软件依赖如下表所示: +### 1.4 三方依赖 -| 软件名称 | 说明 | 使用教程 | -| ----------- | -------------------- | --------------------------------------------------------- | -| pycocotools | 用于实现代码测评 | [点击打开链接](https://cocodataset.org/) | -| mmdetection | 用于实现模型精度评估 | [点击打开链接](https://github.com/open-mmlab/mmdetection) | -| mmcv | 用于实现图片前处理 | [点击打开链接](https://github.com/open-mmlab/mmcv) | +本项目除了依赖昇腾Driver、Firmware、CANN和MxVision及其要求的配套软件外,还需额外依赖以下软件: -.安装python COCO测评工具,mmcv和mmdetection。执行命令: +| 软件名称 | 版本 | +|---------------|----------| +| opencv-python | 4.6.0.66 | +| numpy | 1.23.2 | +| mmcv | 1.7.0 | +| webcolors | 1.13 | + +### 1.5 代码目录结构说明 + +本项目名为FCOS目标检测,项目的目录如下所示: ``` -pip3 install pycocotools -pip3 install mmcv-full -pip3 install mmdet +├── colorlist.txt +├── image +│ ├── image1.png +│ └── image2.png +├── main.py +├── models +│ ├── coco.names +│ └── Fcos_tf_bs.cfg +├── pipeline +│ └── FCOSdetection.pipeline +├── plugin +│ └── FCOSPostprocess +│ ├── build.sh +│ ├── CMakeLists.txt +│ ├── FCOSDetectionPostProcess.cpp +│ └── FCOSDetectionPostProcess.h +└── README.md +``` + +## 2 设置环境变量 +在项目开始运行前需要设置环境变量: +```bash +. ${ascend-toolkit-path}/set_env.sh +. ${mxVision-path}/set_env.sh +# mxVision-path: mxVision安装路径 +# ascend-toolkit-path: CANN安装路径 ``` -## 4 模型转换 +## 3 准备模型 -本项目使用的模型是FCOS目标检测模型这个模型是一个无anchor检测器。FCOS直接把预测特征图上的每个位置$(x,y)$当作训练样本,若这个位置在某个ground truth box的内部,则视为正样本,该位置的类别标签$c$对应这个box的类别,反之则视为负样本。这个网络的输出为目标框的左上角坐标、右下角坐标、类别和置信度。本项目的onnx模型可以直接[下载](https://mindx.sdk.obs.cn-north-4.myhuaweicloud.com/mindxsdk-referenceapps%20/contrib/Fcos/ATC%20Fcos.zip)。下载后,里面自带的om模型是可以直接使用的,或者自行使用ATC工具将onnx模型转换成为om模型,模型转换工具的使用说明参考[链接](https://gitee.com/ascend/docs-openmind/blob/master/guide/mindx/sdk/tutorials/%E5%8F%82%E8%80%83%E8%B5%84%E6%96%99.md)。 +步骤1 下载模型相关文件 -模型转换步骤如下: +根据[链接](https://mindx.sdk.obs.cn-north-4.myhuaweicloud.com/mindxsdk-referenceapps%20/contrib/Fcos/ATC%20Fcos.zip)下载并解压,在解压后的model目录下得到fcos.onnx文件,并放在项目根目录的``models`` 目录下。 -1.从下载链接处下载onnx模型至FCOS/models文件夹下。 -模型转换语句如下: +步骤2 转换模型格式 +放在项目根目录的``models`` 目录下,执行如下命令: ``` atc --model=fcos.onnx --framework=5 --soc_version=Ascend310 --input_format=NCHW --input_shape="input:1,3,800,1333" --output=fcos_bs1 --precision_mode=allow_fp32_to_fp16 ``` -执行完该命令之后,会在models文件夹下生成.om模型,并且转换成功之后会在终端输出: +执行完该命令之后,会在models文件夹下生成fcos_bs1.om模型,并且转换成功之后会在终端输出: ``` ATC start working now, please wait for a moment. @@ -130,160 +91,32 @@ ATC run success, welcome to the next use. -## 5准备 - -### 步骤1 - -准备一张待检测图片,并上传到FCOS文件夹下。然后修改main.py文件里面的图片路径为待检测的图片路径。并且从https://github.com/pjreddie/darknet/blob/master/data/coco.names 里面下载coco.names文件,并且将这个文件存放到models文件夹下。并且修改main.py里IMAGENAME为图片的路径: -```python -IMAGENAME = '{image path}' // 120行 -``` -### 步骤2 - -进入FCOS/plugin/FCOSPostprocess目录,在该目录下运行下列命令: - -``` -bash build.sh -``` -这个后处理插件即可以使用。 +## 4 编译与运行 -## 6编译与运行 +**步骤1** 准备一张jpg图片放到项目目录下,然后修改main.py -在FCOS目录下执行命令: -``` -python3 main.py -``` +第**120**行 `IMAGENAME = '{image path}'`中的{image path}替换为实际的jpg图片路径。 -最后生成的结果会在FCOS文件夹目录下result.jpg图片中。 -## 7精度测试 +**步骤2** 编译 -1.下载COCO VAL 2017[数据集](http://images.cocodataset.org/zips/val2017.zip -)和[标注文件](http://images.cocodataset.org/annotations/annotations_trainval2017.zip -)。在FCOS目录下创建dataset目录,将数据集压缩文件和标注数据压缩文件都解压至 `FCOS/dataset` 目录下。再次创建一个文件夹名为binresult,在FCOS目录下。确保解压后的FCOS目录结构为: +进入在项目根目录的plugin/FCOSPostprocess目录,在该目录下运行下列命令: ``` -|- models -| |- fcos.onnx //onnx模型 -| |_ Fcos_tf_bs.cfg -|- pipeline -| |_ FCOSdetection.pipeline -|- plugin -| |_FCOSPostprocess -| |- CMakeLists.txt -| |- FCOSDetectionPostProcess.cpp -| |- FCOSDetectionPostProcess.h -| |_ build.sh -|- binresult -|- dataset -| |- annotations -| | |_ instances_val2017.json -| |_ val2017 -| |-000000581615.jpg -| |-000000581781.jpg -| |_other-images -|- image -| |- image1.png -| |_ image2.png -|- build.sh -|- colorlist.txt -|- evaluate.py -|_ main.py +bash build.sh ``` -2.再修改后处理插件cpp文件中的: -```cpp - //107行 - if (*(beginRes + CENTERPOINT) < THRESHOLD_) { - continue; - } - //123行 - MxBase::NmsSort(objectInfo, RATE); -``` -将上面的代码全部注释掉,再重新生成一次插件。 -3.执行命令: +**步骤3** 运行 -``` -python3 evaluate.py -``` +在项目根目录下执行以下命令: -命令执行完毕之后,会在binresult文件夹,生成模型输出的目标框、置信度等信息。 - -4.最后在终端输出COCO格式的测评结果,输出结果如下: - -![avatar](./image/image2.png) - -上图中第一行可以看到,这个模型在COCO VAL 2017数据集上,IOU阈值为0.50:0.05:0.95时的精确度为0.347。原模型的推理精度也为0.347这个数据与原模型的推理精度误差范围在0.01内。 - -## 8常见问题 -### 8.1 模型路径配置问题: -问题描述: -检测过程中用到的模型以及模型后处理插件需配置路径属性。 - -后处理插件以及模型推理插件配置例子: - -```json -// 模型推理插件 - "mxpi_tensorinfer0": { - "props": { - "dataSource": "mxpi_imageresize0", - "modelPath": "./models/fcos_bs1.om" - }, - "factory": "mxpi_tensorinfer", - "next": "mxpi_objectpostprocessor0" - }, -// 模型后处理插件 - "mxpi_objectpostprocessor0":{ - "props": { - "dataSource" : "mxpi_tensorinfer0", - "postProcessConfigPath": "./models/Fcos_tf_bs.cfg", - "postProcessLibPath": "libFCOSDetectionPostProcess.so" - }, - "factory": "mxpi_objectpostprocessor", - "next": "mxpi_dataserialize0" - }, -``` -### 8.2 精度测试脚本运行时, TypeError报错问题: -问题描述: -运行精度测试脚本过程中, 出现如下类似报错: ``` -********* -File "***/pycocotools/cocoeval.py", line 507 in setDetParams - self.iouThrs = np.linspace(.5, 0.95, np.round((0.95 - .5) / .05) + 1, endpoint=True) -******** -TypeError: 'numpy.float64' object cannot be interpreted as an integer +python3 main.py ``` -解决措施: -打开pycocotools库下的cocoeval.py文件, 将文件中的代码: -``` -self.iouThrs = np.linspace(.5, 0.95, np.round((0.95 - .5) / .05) + 1, endpoint=True) -self.recThrs = np.linspace(.0, 1.00, np.round((1.00 - .0) / .01) + 1, endpoint=True) -``` -修改为: -``` -self.iouThrs = np.linspace(.5, 0.95, 10, endpoint=True) -self.recThrs = np.linspace(.0, 1.00, 101, endpoint=True) -``` +**步骤4** 查看结果 -### 8.3 精度测试脚本运行时, NameError报错问题: -问题描述: -运行精度测试脚本过程中, 出现如下类似报错: -``` -********* -File "***/pycocotools/coco.py", line 308 in loadRes - if type(resFile) == str or type(resFile) == unicode: -NameError: name 'unicode' is not defined -``` +标准输出中会打印目标检测信息,项目根目录下result.jpg图片会保存可视化检测结果。 -解决措施: -打开pycocotools库下的coco.py文件, 将文件中的代码: -``` -if type(resFile) == str or type(resFile) == unicode: -``` -修改为: -``` -if type(resFile) == str: -``` \ No newline at end of file diff --git a/contrib/FCOS/build.sh b/contrib/FCOS/build.sh deleted file mode 100644 index 2f013a99a2680a4ee547ceb099a5aa8d33a0e598..0000000000000000000000000000000000000000 --- a/contrib/FCOS/build.sh +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright(C) 2022. Huawei Technologies Co.,Ltd. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -set -e -current_folder="$( cd "$(dirname "$0")" ;pwd -P )" - -SAMPLE_FOLDER=( -/plugin/FCOSPostprocess/ -) - -err_flag=0 -for sample in "${SAMPLE_FOLDER[@]}";do - cd "${current_folder}/${sample}" - bash build.sh || { - echo -e "Failed to build ${sample}" - err_flag=1 - } -done - -if [ ${err_flag} -eq 1]; then - exit 1 -fi -exit 0 \ No newline at end of file diff --git a/contrib/FCOS/evaluate.py b/contrib/FCOS/evaluate.py deleted file mode 100644 index 89edff607acb448ec367e5503694bed3e5749f57..0000000000000000000000000000000000000000 --- a/contrib/FCOS/evaluate.py +++ /dev/null @@ -1,206 +0,0 @@ -# !/usr/bin/env python -# coding=utf-8 - -# Copyright(C) 2021. Huawei Technologies Co.,Ltd. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -import sys -import os -import argparse -import json -import cv2 -import numpy as np -import time -import mmcv - -from pycocotools.coco import COCO -from pycocotools.cocoeval import COCOeval -import MxpiDataType_pb2 as MxpiDataType -from StreamManagerApi import StreamManagerApi, MxDataInput, InProtobufVector, StringVector, MxProtobufIn -from mmdet.core import bbox2result -from mmdet.core import encode_mask_results -from mmdet.datasets import CocoDataset - - -def resizeImage(img, size): - old_h = img.shape[0] - old_w = img.shape[1] - scale_ratio = min(size[0] / old_w, size[1] / old_h) - new_w = int(np.floor(old_w * scale_ratio)) - new_h = int(np.floor(old_h * scale_ratio)) - img = mmcv.imresize(img, (new_w, new_h), backend='cv2') - return img, scale_ratio - - -def preprocess(imagePath): - image = mmcv.imread(imagePath, backend='cv2') - image, SCALE = resizeImage(image, (1333, 800)) - h = image.shape[0] - w = image.shape[1] - mean = np.array([102.9801, 115.9465, 122.7717], dtype=np.float32) - std = np.array([1.0, 1.0, 1.0], dtype=np.float32) - norm_img_data = mmcv.imnormalize(image, mean, std, to_rgb=False) - pad_left = (1333 - w) // 2 - pad_top = (800 - h) // 2 - pad_right = 1333 - w - pad_left - pad_bottom = 800 - h - pad_top - image_for_infer = mmcv.impad(norm_img_data, - padding=(pad_left, pad_top, pad_right, - pad_bottom), - pad_val=0) - image_for_infer = image_for_infer.transpose(2, 0, 1) - return image_for_infer, [SCALE, pad_left, pad_top, pad_right, pad_bottom] - - -if __name__ == '__main__': - # init stream manager - stream_manager_api = StreamManagerApi() - ret = stream_manager_api.InitManager() - if ret != 0: - print("Failed to init Stream manager, ret=%s" % str(ret)) - exit() - - # create streams by pipeline config file - pipeline_path = './pipeline/FCOSdetection.pipeline' - print('pipeline path: ', pipeline_path) - with open(pipeline_path, "rb") as f: - pipeline_str = f.read() - ret = stream_manager_api.CreateMultipleStreams(pipeline_str) - if ret != 0: - print("Failed to create Stream, ret=%s" % str(ret)) - exit() - stream_name = b"detection" - in_plugin_id = 0 - - image_folder = './dataset/val2017' - annotation_file = './dataset/annotations/instances_val2017.json' - - coco_gt = COCO(annotation_file) - image_ids = coco_gt.getImgIds() - print('Test on coco2017 test-dev dataset, ', len(image_ids), - ' images in total.') - - coco_result = [] - - for image_idx, image_id in enumerate(image_ids): - print('image_idx = %d image_id = %d.' % - (image_idx, image_id)) # image_id is name of picture - image_info = coco_gt.loadImgs(image_id)[0] # 获取这张测试图片的信息 - image_path = os.path.join(image_folder, - image_info['file_name']) # 获取测试图片的路径 - print('Detect image: ', image_idx, ': ', image_info['file_name'], - ', image id: ', image_id) - if os.path.exists(image_path) != 1: - print("The test image does not exist. Exit.") - exit() - - tensorData, return_image = preprocess(image_path) - tensor = tensorData[None, :] - - visionList = MxpiDataType.MxpiVisionList() - visionVec = visionList.visionVec.add() - visionInfo = visionVec.visionInfo - - visionInfo.width = 1333 - visionInfo.height = 800 - visionInfo.widthAligned = 1333 - visionInfo.heightAligned = 800 - visionData = visionVec.visionData - visionData.dataStr = tensor.tobytes() - visionData.deviceId = 0 - visionData.memType = 0 - visionData.dataSize = len(tensor) - - # stream_name = b"detection" - KEYVALUE = b'appsrc0' - protobufVec = InProtobufVector() - protobuf = MxProtobufIn() - protobuf.key = KEYVALUE - protobuf.type = b"MxTools.MxpiVisionList" - protobuf.protobuf = visionList.SerializeToString() - protobufVec.push_back(protobuf) - unique_id = stream_manager_api.SendProtobuf(stream_name, in_plugin_id, - protobufVec) - - if unique_id < 0: - print("Failed to send data to stream.") - exit() - key_vec = StringVector() - key_vec.push_back(b"mxpi_objectpostprocessor0") - infer_result = stream_manager_api.GetProtobuf( - stream_name, 0, key_vec) # 获取本张图片的测试结果(目标框) - if infer_result.size() == 0: - print("infer_result is null") - continue - if infer_result[0].errorCode != 0: - print("infer_result error. errorCode=%d" % - (infer_result[0].errorCode)) - exit() - - objectList = MxpiDataType.MxpiObjectList() - objectList.ParseFromString(infer_result[0].messageBuf) - SCALE, pad_left, pad_top, pad_right, pad_bottom = return_image # 用来复原目标框 - bboxfileName = 'bboxres' + str(image_id) + '.bin' - classfileName = 'class' + str(image_id) + '.bin' - bboxresultList = [] - classresultList = [] - for obj in objectList.objectVec: - box = { - 'x0': max(int((obj.x0 - pad_left) / SCALE), 0), - 'x1': max(int((obj.x1 - pad_left) / SCALE), 0), - 'y0': max(int((obj.y0 - pad_top) / SCALE), 0), - 'y1': max(int((obj.y1 - pad_top) / SCALE), 0), - 'class': obj.classVec[0].classId, - 'confidence': obj.classVec[0].confidence - } - # box: x0, y0, w, h - bboxresultList.append(max(float((obj.x0 - pad_left) / SCALE), 0.0)) - bboxresultList.append(max(float((obj.y0 - pad_top) / SCALE), 0.0)) - bboxresultList.append(max(float((obj.x1 - pad_left) / SCALE), 0.0)) - bboxresultList.append(max(float((obj.y1 - pad_top) / SCALE), 0.0)) - bboxresultList.append(obj.classVec[0].confidence) - classresultList.append(obj.classVec[0].classId) - - bboxresultnumpy = np.array(bboxresultList, dtype=np.float32) - classresultnumpy = np.array(classresultList, dtype=np.int64) - bboxresultnumpy.tofile('./binresult/' + bboxfileName) - classresultnumpy.tofile('./binresult/' + classfileName) - - coco_dataset = CocoDataset( - ann_file='./dataset/annotations/instances_val2017.json', pipeline=[]) - results = [] - - for ids in coco_dataset.img_ids: - print('image ids = {}'.format(ids)) - bbox_results = [] - # read bbox information - BBOX_RES_PATH = './binresult/bboxres' + str(ids) + '.bin' - REBLES_RES_PATH = './binresult/class' + str(ids) + '.bin' - bboxes = np.fromfile(BBOX_RES_PATH, dtype=np.float32) - bboxes = np.reshape(bboxes, [100, 5]) - bboxes.tolist() - # read label information - labels = np.fromfile(REBLES_RES_PATH, dtype=np.int64) - labels = np.reshape(labels, [100, 1]) - labels.tolist() - bbox_results = [bbox2result(bboxes, labels[:, 0], 80)] - - result = bbox_results - results.extend(result) - print('Evaluating...') - eval_results = coco_dataset.evaluate(results, - metric=[ - 'bbox', - ], - classwise=True) - print(eval_results) \ No newline at end of file diff --git a/contrib/FCOS/image/image2.png b/contrib/FCOS/image/image2.png deleted file mode 100644 index b5c62be596f510d624766da680bc5af2e41aaa87..0000000000000000000000000000000000000000 Binary files a/contrib/FCOS/image/image2.png and /dev/null differ diff --git a/contrib/FCOS/models/coco.names b/contrib/FCOS/models/coco.names new file mode 100644 index 0000000000000000000000000000000000000000..5ec6eeea2f217dca9788d8a4f9ab032dd05e6beb --- /dev/null +++ b/contrib/FCOS/models/coco.names @@ -0,0 +1,80 @@ +person +bicycle +car +motorbike +aeroplane +bus +train +truck +boat +traffic light +fire hydrant +stop sign +parking meter +bench +bird +cat +dog +horse +sheep +cow +elephant +bear +zebra +giraffe +backpack +umbrella +handbag +tie +suitcase +frisbee +skis +snowboard +sports ball +kite +baseball bat +baseball glove +skateboard +surfboard +tennis racket +bottle +wine glass +cup +fork +knife +spoon +bowl +banana +apple +sandwich +orange +broccoli +carrot +hot dog +pizza +donut +cake +chair +sofa +pottedplant +bed +diningtable +toilet +tvmonitor +laptop +mouse +remote +keyboard +cell phone +microwave +oven +toaster +sink +refrigerator +book +clock +vase +scissors +teddy bear +hair drier +toothbrush diff --git a/contrib/FCOS/plugin/FCOSPostprocess/FCOSDetectionPostProcess.cpp b/contrib/FCOS/plugin/FCOSPostprocess/FCOSDetectionPostProcess.cpp index 479aa527153314c039198258cd9bb2cda436290f..6c174f69cc1cd311d856e912bb26659e68e99b09 100644 --- a/contrib/FCOS/plugin/FCOSPostprocess/FCOSDetectionPostProcess.cpp +++ b/contrib/FCOS/plugin/FCOSPostprocess/FCOSDetectionPostProcess.cpp @@ -99,7 +99,7 @@ APP_ERROR FCOSPostProcess::Process( } std::vector objectInfo; auto res0 = (float *)tensors[0].GetBuffer(); - auto classIdx = (__int64 *)tensors[1].GetBuffer(); + auto classIdx = (int64 *)tensors[1].GetBuffer(); auto shape1 = tensors[1].GetShape(); for (uint32_t i = 0; i < shape[1]; i++) { float *beginRes = res0 + i * 5;