mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-05 16:48:03 +08:00
[Bug Fix] fixed labels setting of YOLOv5 (#1213)
修复自己训练的yolov5无法指定label个数的错误
This commit is contained in:
@@ -47,8 +47,7 @@ cmake .. -DCMAKE_C_COMPILER=/home/zbc/opt/gcc-linaro-6.3.1-2017.05-x86_64_aarch
|
|||||||
-DENABLE_ORT_BACKEND=OFF \
|
-DENABLE_ORT_BACKEND=OFF \
|
||||||
-DENABLE_RKNPU2_BACKEND=ON \
|
-DENABLE_RKNPU2_BACKEND=ON \
|
||||||
-DENABLE_VISION=ON \
|
-DENABLE_VISION=ON \
|
||||||
-DRKNN2_TARGET_SOC=RK3588 \
|
-DRKNN2_TARGET_SOC=RK356X \
|
||||||
-DENABLE_FLYCV=ON \
|
|
||||||
-DCMAKE_INSTALL_PREFIX=${PWD}/fastdeploy-0.0.0
|
-DCMAKE_INSTALL_PREFIX=${PWD}/fastdeploy-0.0.0
|
||||||
make -j8
|
make -j8
|
||||||
make install
|
make install
|
||||||
|
@@ -4,34 +4,9 @@ project(rknpu2_test)
|
|||||||
set(CMAKE_CXX_STANDARD 14)
|
set(CMAKE_CXX_STANDARD 14)
|
||||||
|
|
||||||
# 指定下载解压后的fastdeploy库路径
|
# 指定下载解压后的fastdeploy库路径
|
||||||
set(FASTDEPLOY_INSTALL_DIR "thirdpartys/fastdeploy-0.0.3")
|
option(FASTDEPLOY_INSTALL_DIR "Path of downloaded fastdeploy sdk.")
|
||||||
|
include(${FASTDEPLOY_INSTALL_DIR}/FastDeploy.cmake)
|
||||||
include(${FASTDEPLOY_INSTALL_DIR}/FastDeployConfig.cmake)
|
# 添加FastDeploy依赖头文件
|
||||||
include_directories(${FastDeploy_INCLUDE_DIRS})
|
include_directories(${FASTDEPLOY_INCS})
|
||||||
|
|
||||||
add_executable(infer_rkyolo infer_rkyolo.cc)
|
add_executable(infer_rkyolo infer_rkyolo.cc)
|
||||||
target_link_libraries(infer_rkyolo ${FastDeploy_LIBS})
|
target_link_libraries(infer_rkyolo ${FASTDEPLOY_LIBS})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/build/install)
|
|
||||||
|
|
||||||
install(TARGETS infer_rkyolo DESTINATION ./)
|
|
||||||
|
|
||||||
install(DIRECTORY model DESTINATION ./)
|
|
||||||
install(DIRECTORY images DESTINATION ./)
|
|
||||||
|
|
||||||
file(GLOB FASTDEPLOY_LIBS ${FASTDEPLOY_INSTALL_DIR}/lib/*)
|
|
||||||
message("${FASTDEPLOY_LIBS}")
|
|
||||||
install(PROGRAMS ${FASTDEPLOY_LIBS} DESTINATION lib)
|
|
||||||
|
|
||||||
file(GLOB ONNXRUNTIME_LIBS ${FASTDEPLOY_INSTALL_DIR}/third_libs/install/onnxruntime/lib/*)
|
|
||||||
install(PROGRAMS ${ONNXRUNTIME_LIBS} DESTINATION lib)
|
|
||||||
|
|
||||||
install(DIRECTORY ${FASTDEPLOY_INSTALL_DIR}/third_libs/install/opencv/lib DESTINATION ./)
|
|
||||||
|
|
||||||
file(GLOB PADDLETOONNX_LIBS ${FASTDEPLOY_INSTALL_DIR}/third_libs/install/paddle2onnx/lib/*)
|
|
||||||
install(PROGRAMS ${PADDLETOONNX_LIBS} DESTINATION lib)
|
|
||||||
|
|
||||||
file(GLOB RKNPU2_LIBS ${FASTDEPLOY_INSTALL_DIR}/third_libs/install/rknpu2_runtime/${RKNN2_TARGET_SOC}/lib/*)
|
|
||||||
install(PROGRAMS ${RKNPU2_LIBS} DESTINATION lib)
|
|
||||||
|
@@ -10,58 +10,12 @@
|
|||||||
|
|
||||||
以上步骤请参考[RK2代NPU部署库编译](../../../../../docs/cn/build_and_install/rknpu2.md)实现
|
以上步骤请参考[RK2代NPU部署库编译](../../../../../docs/cn/build_and_install/rknpu2.md)实现
|
||||||
|
|
||||||
## 生成基本目录文件
|
|
||||||
|
|
||||||
该例程由以下几个部分组成
|
|
||||||
```text
|
|
||||||
.
|
|
||||||
├── CMakeLists.txt
|
|
||||||
├── build # 编译文件夹
|
|
||||||
├── image # 存放图片的文件夹
|
|
||||||
├── infer_rkyolo.cc
|
|
||||||
├── model # 存放模型文件的文件夹
|
|
||||||
└── thirdpartys # 存放sdk的文件夹
|
|
||||||
```
|
|
||||||
|
|
||||||
首先需要先生成目录结构
|
|
||||||
```bash
|
|
||||||
mkdir build
|
|
||||||
mkdir images
|
|
||||||
mkdir model
|
|
||||||
mkdir thirdpartys
|
|
||||||
```
|
|
||||||
|
|
||||||
## 编译
|
|
||||||
|
|
||||||
### 编译并拷贝SDK到thirdpartys文件夹
|
|
||||||
|
|
||||||
请参考[RK2代NPU部署库编译](../../../../../docs/cn/build_and_install/rknpu2.md)仓库编译SDK,编译完成后,将在build目录下生成
|
|
||||||
fastdeploy-0.0.3目录,请移动它至thirdpartys目录下.
|
|
||||||
|
|
||||||
### 拷贝模型文件,以及配置文件至model文件夹
|
|
||||||
在Paddle动态图模型 -> Paddle静态图模型 -> ONNX模型的过程中,将生成ONNX文件以及对应的yaml配置文件,请将配置文件存放到model文件夹内。
|
|
||||||
转换为RKNN后的模型文件也需要拷贝至model。
|
|
||||||
|
|
||||||
### 准备测试图片至image文件夹
|
|
||||||
```bash
|
```bash
|
||||||
wget https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/000000014439.jpg
|
wget https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/000000014439.jpg
|
||||||
cp 000000014439.jpg ./images
|
|
||||||
```
|
|
||||||
|
|
||||||
### 编译example
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cd build
|
cd build
|
||||||
cmake ..
|
cmake .. -DFASTDEPLOY_INSTALL_DIR=${PWD}/fastdeploy-linux-x64-x.x.x
|
||||||
make -j8
|
make -j8
|
||||||
make install
|
./infer_rkyolo /path/to/model 000000014439.jpg
|
||||||
```
|
|
||||||
|
|
||||||
## 运行例程
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cd ./build/install
|
|
||||||
./infer_picodet model/ images/000000014439.jpg
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
@@ -141,7 +141,6 @@ int RKYOLOPostprocessor::ProcessFP16(float* input, int* anchor, int grid_h,
|
|||||||
} else {
|
} else {
|
||||||
limit_score = box_conf_f32 * class_prob_f32;
|
limit_score = box_conf_f32 * class_prob_f32;
|
||||||
}
|
}
|
||||||
// printf("limit score: %f", limit_score);
|
|
||||||
if (limit_score > conf_threshold_) {
|
if (limit_score > conf_threshold_) {
|
||||||
float box_x, box_y, box_w, box_h;
|
float box_x, box_y, box_w, box_h;
|
||||||
if (anchor_per_branch_ == 1) {
|
if (anchor_per_branch_ == 1) {
|
||||||
|
@@ -55,26 +55,30 @@ class FASTDEPLOY_DECL RKYOLOPostprocessor {
|
|||||||
/// Get nms_threshold, default 0.45
|
/// Get nms_threshold, default 0.45
|
||||||
float GetNMSThreshold() const { return nms_threshold_; }
|
float GetNMSThreshold() const { return nms_threshold_; }
|
||||||
|
|
||||||
// Set height and weight
|
/// Set height and weight
|
||||||
void SetHeightAndWeight(int& height, int& width) {
|
void SetHeightAndWeight(int& height, int& width) {
|
||||||
height_ = height;
|
height_ = height;
|
||||||
width_ = width;
|
width_ = width;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set pad_hw_values
|
/// Set pad_hw_values
|
||||||
void SetPadHWValues(std::vector<std::vector<int>> pad_hw_values) {
|
void SetPadHWValues(std::vector<std::vector<int>> pad_hw_values) {
|
||||||
pad_hw_values_ = pad_hw_values;
|
pad_hw_values_ = pad_hw_values;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set scale
|
/// Set scale
|
||||||
void SetScale(std::vector<float> scale) {
|
void SetScale(std::vector<float> scale) { scale_ = scale; }
|
||||||
scale_ = scale;
|
|
||||||
|
/// Set Anchor
|
||||||
|
void SetAnchor(std::vector<int> anchors, int anchor_per_branch) {
|
||||||
|
anchors_ = anchors;
|
||||||
|
anchor_per_branch_ = anchor_per_branch;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Anchor
|
/// Set the number of class
|
||||||
void SetAnchor(std::vector<int> anchors, int anchor_per_branch) {
|
void SetClassNum(int num) {
|
||||||
anchors_ = anchors;
|
obj_class_num_ = num;
|
||||||
anchor_per_branch_ = anchor_per_branch;
|
prob_box_size_ = obj_class_num_ + 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -85,12 +89,9 @@ class FASTDEPLOY_DECL RKYOLOPostprocessor {
|
|||||||
int width_ = 0;
|
int width_ = 0;
|
||||||
int anchor_per_branch_ = 0;
|
int anchor_per_branch_ = 0;
|
||||||
|
|
||||||
int ProcessFP16(float *input, int *anchor, int grid_h,
|
int ProcessFP16(float* input, int* anchor, int grid_h, int grid_w, int stride,
|
||||||
int grid_w, int stride,
|
std::vector<float>& boxes, std::vector<float>& boxScores,
|
||||||
std::vector<float> &boxes,
|
std::vector<int>& classId, float threshold);
|
||||||
std::vector<float> &boxScores,
|
|
||||||
std::vector<int> &classId,
|
|
||||||
float threshold);
|
|
||||||
// Model
|
// Model
|
||||||
int QuickSortIndiceInverse(std::vector<float>& input, int left, int right,
|
int QuickSortIndiceInverse(std::vector<float>& input, int left, int right,
|
||||||
std::vector<int>& indices);
|
std::vector<int>& indices);
|
||||||
|
Reference in New Issue
Block a user