From e077c005dfabbdb785139e7c9321c579481f1e04 Mon Sep 17 00:00:00 2001 From: Zheng-Bicheng <58363586+Zheng-Bicheng@users.noreply.github.com> Date: Wed, 8 Feb 2023 19:46:11 +0800 Subject: [PATCH] [Bug Fix] Update RKYOLO code format (#1254) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 更新rkyolo细节 * 更新rkyolov5 format --- .../detection/contrib/rknpu2/postprocessor.h | 12 +++++------ .../vision/detection/contrib/rknpu2/utils.cc | 20 ------------------- .../vision/detection/contrib/rknpu2/utils.h | 7 +------ 3 files changed, 7 insertions(+), 32 deletions(-) diff --git a/fastdeploy/vision/detection/contrib/rknpu2/postprocessor.h b/fastdeploy/vision/detection/contrib/rknpu2/postprocessor.h index eea3fe521..a6b6f0cc9 100755 --- a/fastdeploy/vision/detection/contrib/rknpu2/postprocessor.h +++ b/fastdeploy/vision/detection/contrib/rknpu2/postprocessor.h @@ -40,12 +40,12 @@ class FASTDEPLOY_DECL RKYOLOPostprocessor { std::vector* results); /// Set nms_threshold, default 0.45 - void SetNMSThreshold(const float& nms_threshold) { + void SetNMSThreshold(float nms_threshold) { nms_threshold_ = nms_threshold; } /// Set conf_threshold, default 0.25 - void SetConfThreshold(const float& conf_threshold) { + void SetConfThreshold(float conf_threshold) { conf_threshold_ = conf_threshold; } @@ -56,21 +56,21 @@ class FASTDEPLOY_DECL RKYOLOPostprocessor { float GetNMSThreshold() const { return nms_threshold_; } /// Set height and weight - void SetHeightAndWeight(int& height, int& width) { + void SetHeightAndWeight(int height,int width) { height_ = height; width_ = width; } /// Set pad_hw_values - void SetPadHWValues(std::vector> pad_hw_values) { + void SetPadHWValues(const std::vector>& pad_hw_values) { pad_hw_values_ = pad_hw_values; } /// Set scale - void SetScale(std::vector scale) { scale_ = scale; } + void SetScale(const std::vector& scale) { scale_ = scale; } /// Set Anchor - void SetAnchor(std::vector anchors, int anchor_per_branch) { + void SetAnchor(const std::vector& anchors, int anchor_per_branch) { anchors_ = anchors; anchor_per_branch_ = anchor_per_branch; } diff --git a/fastdeploy/vision/detection/contrib/rknpu2/utils.cc b/fastdeploy/vision/detection/contrib/rknpu2/utils.cc index 4271def4a..f86a37b12 100644 --- a/fastdeploy/vision/detection/contrib/rknpu2/utils.cc +++ b/fastdeploy/vision/detection/contrib/rknpu2/utils.cc @@ -18,26 +18,6 @@ namespace detection { float Clamp(float val, int min, int max) { return val > min ? (val < max ? val : max) : min; } - -float Sigmoid(float x) { return 1.0 / (1.0 + expf(-x)); } - -float UnSigmoid(float y) { return -1.0 * logf((1.0 / y) - 1.0); } - -inline int32_t __clip(float val, float min, float max) { - float f = val <= min ? min : (val >= max ? max : val); - return f; -} - -int8_t QntF32ToAffine(float f32, int32_t zp, float scale) { - float dst_val = (f32 / scale) + zp; - int8_t res = (int8_t)__clip(dst_val, -128, 127); - return res; -} - -float DeqntAffineToF32(int8_t qnt, int32_t zp, float scale) { - return ((float)qnt - (float)zp) * scale; -} - static float CalculateOverlap(float xmin0, float ymin0, float xmax0, float ymax0, float xmin1, float ymin1, float xmax1, float ymax1) { diff --git a/fastdeploy/vision/detection/contrib/rknpu2/utils.h b/fastdeploy/vision/detection/contrib/rknpu2/utils.h index 1fa533082..f556bb245 100644 --- a/fastdeploy/vision/detection/contrib/rknpu2/utils.h +++ b/fastdeploy/vision/detection/contrib/rknpu2/utils.h @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. #pragma once -#include +#include #include #include @@ -20,11 +20,6 @@ namespace fastdeploy { namespace vision { namespace detection { float Clamp(float val, int min, int max); -float Sigmoid(float x); -float UnSigmoid(float y); -inline static int32_t __clip(float val, float min, float max); -int8_t QntF32ToAffine(float f32, int32_t zp, float scale); -float DeqntAffineToF32(int8_t qnt, int32_t zp, float scale); int NMS(int valid_count, std::vector& output_locations, std::vector& class_id, std::vector& order, float threshold, bool class_agnostic);