diff --git a/docs/cn/faq/rknpu2/build.md b/docs/cn/faq/rknpu2/build.md index c99bcb17f..7389d2396 100644 --- a/docs/cn/faq/rknpu2/build.md +++ b/docs/cn/faq/rknpu2/build.md @@ -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 diff --git a/examples/vision/detection/rkyolo/cpp/CMakeLists.txt b/examples/vision/detection/rkyolo/cpp/CMakeLists.txt index 524b94fea..c29281d84 100644 --- a/examples/vision/detection/rkyolo/cpp/CMakeLists.txt +++ b/examples/vision/detection/rkyolo/cpp/CMakeLists.txt @@ -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}) diff --git a/examples/vision/detection/rkyolo/cpp/README_CN.md b/examples/vision/detection/rkyolo/cpp/README_CN.md index 924e34984..7d2827173 100644 --- a/examples/vision/detection/rkyolo/cpp/README_CN.md +++ b/examples/vision/detection/rkyolo/cpp/README_CN.md @@ -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 ``` diff --git a/fastdeploy/vision/detection/contrib/rknpu2/postprocessor.cc b/fastdeploy/vision/detection/contrib/rknpu2/postprocessor.cc index 581cac2e8..7aae742ea 100755 --- a/fastdeploy/vision/detection/contrib/rknpu2/postprocessor.cc +++ b/fastdeploy/vision/detection/contrib/rknpu2/postprocessor.cc @@ -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) { diff --git a/fastdeploy/vision/detection/contrib/rknpu2/postprocessor.h b/fastdeploy/vision/detection/contrib/rknpu2/postprocessor.h index b65479415..eea3fe521 100755 --- a/fastdeploy/vision/detection/contrib/rknpu2/postprocessor.h +++ b/fastdeploy/vision/detection/contrib/rknpu2/postprocessor.h @@ -55,26 +55,30 @@ 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> pad_hw_values) { pad_hw_values_ = pad_hw_values; } - // Set scale - void SetScale(std::vector scale) { - scale_ = scale; + /// Set scale + void SetScale(std::vector scale) { scale_ = scale; } + + /// Set Anchor + void SetAnchor(std::vector anchors, int anchor_per_branch) { + anchors_ = anchors; + anchor_per_branch_ = anchor_per_branch; } - // Set Anchor - void SetAnchor(std::vector 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: @@ -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 &boxes, - std::vector &boxScores, - std::vector &classId, - float threshold); + int ProcessFP16(float* input, int* anchor, int grid_h, int grid_w, int stride, + std::vector& boxes, std::vector& boxScores, + std::vector& classId, float threshold); // Model int QuickSortIndiceInverse(std::vector& input, int left, int right, std::vector& indices);