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_RKNPU2_BACKEND=ON \
|
||||
-DENABLE_VISION=ON \
|
||||
-DRKNN2_TARGET_SOC=RK3588 \
|
||||
-DENABLE_FLYCV=ON \
|
||||
-DRKNN2_TARGET_SOC=RK356X \
|
||||
-DCMAKE_INSTALL_PREFIX=${PWD}/fastdeploy-0.0.0
|
||||
make -j8
|
||||
make install
|
||||
|
@@ -4,34 +4,9 @@ project(rknpu2_test)
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
|
||||
# 指定下载解压后的fastdeploy库路径
|
||||
set(FASTDEPLOY_INSTALL_DIR "thirdpartys/fastdeploy-0.0.3")
|
||||
|
||||
include(${FASTDEPLOY_INSTALL_DIR}/FastDeployConfig.cmake)
|
||||
include_directories(${FastDeploy_INCLUDE_DIRS})
|
||||
|
||||
option(FASTDEPLOY_INSTALL_DIR "Path of downloaded fastdeploy sdk.")
|
||||
include(${FASTDEPLOY_INSTALL_DIR}/FastDeploy.cmake)
|
||||
# 添加FastDeploy依赖头文件
|
||||
include_directories(${FASTDEPLOY_INCS})
|
||||
add_executable(infer_rkyolo infer_rkyolo.cc)
|
||||
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)
|
||||
target_link_libraries(infer_rkyolo ${FASTDEPLOY_LIBS})
|
||||
|
@@ -10,58 +10,12 @@
|
||||
|
||||
以上步骤请参考[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
|
||||
wget https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/000000014439.jpg
|
||||
cp 000000014439.jpg ./images
|
||||
```
|
||||
|
||||
### 编译example
|
||||
|
||||
```bash
|
||||
cd build
|
||||
cmake ..
|
||||
cmake .. -DFASTDEPLOY_INSTALL_DIR=${PWD}/fastdeploy-linux-x64-x.x.x
|
||||
make -j8
|
||||
make install
|
||||
```
|
||||
|
||||
## 运行例程
|
||||
|
||||
```bash
|
||||
cd ./build/install
|
||||
./infer_picodet model/ images/000000014439.jpg
|
||||
./infer_rkyolo /path/to/model 000000014439.jpg
|
||||
```
|
||||
|
||||
|
||||
|
@@ -141,7 +141,6 @@ int RKYOLOPostprocessor::ProcessFP16(float* input, int* anchor, int grid_h,
|
||||
} else {
|
||||
limit_score = box_conf_f32 * class_prob_f32;
|
||||
}
|
||||
// printf("limit score: %f", limit_score);
|
||||
if (limit_score > conf_threshold_) {
|
||||
float box_x, box_y, box_w, box_h;
|
||||
if (anchor_per_branch_ == 1) {
|
||||
|
@@ -55,28 +55,32 @@ class FASTDEPLOY_DECL RKYOLOPostprocessor {
|
||||
/// Get nms_threshold, default 0.45
|
||||
float GetNMSThreshold() const { return nms_threshold_; }
|
||||
|
||||
// Set height and weight
|
||||
/// Set height and weight
|
||||
void SetHeightAndWeight(int& height, int& width) {
|
||||
height_ = height;
|
||||
width_ = width;
|
||||
}
|
||||
|
||||
// Set pad_hw_values
|
||||
/// Set pad_hw_values
|
||||
void SetPadHWValues(std::vector<std::vector<int>> pad_hw_values) {
|
||||
pad_hw_values_ = pad_hw_values;
|
||||
}
|
||||
|
||||
// Set scale
|
||||
void SetScale(std::vector<float> scale) {
|
||||
scale_ = scale;
|
||||
}
|
||||
/// Set scale
|
||||
void SetScale(std::vector<float> scale) { scale_ = scale; }
|
||||
|
||||
// Set Anchor
|
||||
/// Set Anchor
|
||||
void SetAnchor(std::vector<int> anchors, int anchor_per_branch) {
|
||||
anchors_ = anchors;
|
||||
anchor_per_branch_ = anchor_per_branch;
|
||||
}
|
||||
|
||||
/// Set the number of class
|
||||
void SetClassNum(int num) {
|
||||
obj_class_num_ = num;
|
||||
prob_box_size_ = obj_class_num_ + 5;
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<int> anchors_ = {10, 13, 16, 30, 33, 23, 30, 61, 62,
|
||||
45, 59, 119, 116, 90, 156, 198, 373, 326};
|
||||
@@ -85,12 +89,9 @@ class FASTDEPLOY_DECL RKYOLOPostprocessor {
|
||||
int width_ = 0;
|
||||
int anchor_per_branch_ = 0;
|
||||
|
||||
int ProcessFP16(float *input, int *anchor, int grid_h,
|
||||
int grid_w, int stride,
|
||||
std::vector<float> &boxes,
|
||||
std::vector<float> &boxScores,
|
||||
std::vector<int> &classId,
|
||||
float threshold);
|
||||
int ProcessFP16(float* input, int* anchor, int grid_h, int grid_w, int stride,
|
||||
std::vector<float>& boxes, std::vector<float>& boxScores,
|
||||
std::vector<int>& classId, float threshold);
|
||||
// Model
|
||||
int QuickSortIndiceInverse(std::vector<float>& input, int left, int right,
|
||||
std::vector<int>& indices);
|
||||
|
Reference in New Issue
Block a user