wz fix evaluation

This commit is contained in:
吴镇
2022-11-23 09:30:39 +08:00
parent ed9dd2a56b
commit be99bba040
25 changed files with 84 additions and 2 deletions

View File

@@ -5,6 +5,7 @@
#include <boost/filesystem.hpp>
#include <fstream>
#include <iostream>
#include "MxBase/DeviceManager/DeviceManager.h"
#include "MxBase/Log/Log.h"

View File

@@ -49,12 +49,17 @@
|- FCOSPostprocess
| |- FCOSDetectionPostProcess.cpp
| |_ FCOSDetectionPostProcess.h
|- imageforTest
| |- 000000000785.jpg
| |- 000000000872.jpg
| |_ other images
|- build.sh
|- CMakeLists.txt
|- main.py
|- binresult
|- evaluate.py
|_ README.md
|- README.md
|_ test.sh
```
### 1.5 技术实现流程图
@@ -120,7 +125,52 @@ ATC run success, welcome to the next use.
## 5 精度测试
本项目和 https://gitee.com/ascend/mindxsdk-referenceapps/tree/master/contrib/FCOS 地址处的项目的模型和后处理过程一样。详细的精度测试参考地址处的项目。
本项目和 https://gitee.com/ascend/mindxsdk-referenceapps/tree/master/contrib/FCOS 地址处的项目的模型和后处理过程一样。详细的精度测试参考地址处的项目。在本项目由于其后处理插件以及模型和上面地址处的是一致的这里就不单独进行精度测试。仅仅利用imageforTest内的照片跑出来的结果来与地址处的项目进行对比。这里旨在说明两个项目的代码运行结果是基本一致的。
在进行精度比对之前,首先需要修改几处代码。
首先在FCOSDetection.cpp文件里面的301行下面加上代码
```cpp
std::string resPath = imagePath;
for (uint32_t i = 0; i<resPath.size(); i++) {
if (resPath.at(i) == '.') {
resPath.replace(i, 4, ".txt");
break;
}
}
std::ofstream outfile;
outfile.open(resPath, std::ios::out);
```
在这之后,在同一个函数里面的
```cpp
cv::rectangle(imgBgr,
cv::Rect(newX0, newY0, newX1 - newX0, newY1 - newY0), green,
thickness);
```
代码下面加入以下代码:
```cpp
outfile << labelMap_[((int)resultInfo[j].classId)];
outfile << "\n";
outfile << newX0;
outfile << " ";
outfile << newY0;
outfile << " ";
outfile << newX1 - newX0;
outfile << " ";
outfile << newY1 - newY0;
outfile << "\n";
```
在加入完毕以上代码之后就在终端输入命令:
```
bash test.sh
```
即可在imageforTest文件夹下面看到以txt文件存放的结果。每个txt文件对应于一张图片。
![avatar](./image/image4.png)
在每个txt文件中其中的内容如下
![avatar](./image/image5.png)
在每个txt文件中都存放了对应图片的所有检测到的物体类别及其目标框$(x_0,y_0,w,h)$。但是这个项目和上述地址处的项目的同一张图片的txt文件里面的每一个目标框结果存放顺序不同不影响结果。经过多次对比发现本项目的结果和上述地址处的项目最终结果生成的目标框的位置基本一样、类别也一致。
## 6 常见问题
### 6.1 类别标签问题

BIN
FCOS/image/image4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
FCOS/image/image5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 234 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 310 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 181 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 KiB

31
FCOS/test.sh Normal file
View File

@@ -0,0 +1,31 @@
#!/bin/bash
# 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.
function getdir(){
for element in `ls $1`
do
dir_or_file=$1"/"$element
if [ -d $dir_or_file ]
then
getdir $dir_or_file
else
echo $dir_or_file
./mxBase_sample $dir_or_file
fi
done
}
root_dir="./imageforTest"
getdir $root_dir