mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-06 09:07:10 +08:00
Add RKYOLOv5 RKYOLOX RKYOLOV7 (#709)
* 更正代码格式 * 更正代码格式 * 修复语法错误 * fix rk error * update * update * update * update * update * update * update Co-authored-by: Jason <jiangjiajun@baidu.com>
This commit is contained in:
105
fastdeploy/vision/detection/contrib/rknpu2/postprocessor.h
Executable file
105
fastdeploy/vision/detection/contrib/rknpu2/postprocessor.h
Executable file
@@ -0,0 +1,105 @@
|
||||
// Copyright (c) 2022 PaddlePaddle Authors. 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.
|
||||
|
||||
#pragma once
|
||||
#include "fastdeploy/vision/common/processors/transform.h"
|
||||
#include "fastdeploy/vision/common/result.h"
|
||||
#include "fastdeploy/vision/detection/contrib/rknpu2/utils.h"
|
||||
#include <array>
|
||||
namespace fastdeploy {
|
||||
namespace vision {
|
||||
namespace detection {
|
||||
/*! @brief Postprocessor object for YOLOv5 serials model.
|
||||
*/
|
||||
class FASTDEPLOY_DECL RKYOLOPostprocessor {
|
||||
public:
|
||||
/** \brief Create a postprocessor instance for YOLOv5 serials model
|
||||
*/
|
||||
RKYOLOPostprocessor();
|
||||
|
||||
/** \brief Process the result of runtime and fill to DetectionResult structure
|
||||
*
|
||||
* \param[in] tensors The inference result from runtime
|
||||
* \param[in] result The output result of detection
|
||||
* \param[in] ims_info The shape info list, record input_shape and output_shape
|
||||
* \return true if the postprocess successed, otherwise false
|
||||
*/
|
||||
bool Run(const std::vector<FDTensor>& tensors,
|
||||
std::vector<DetectionResult>* results);
|
||||
|
||||
/// Set nms_threshold, default 0.45
|
||||
void SetNMSThreshold(const float& nms_threshold) {
|
||||
nms_threshold_ = nms_threshold;
|
||||
}
|
||||
|
||||
/// Set conf_threshold, default 0.25
|
||||
void SetConfThreshold(const float& conf_threshold) {
|
||||
conf_threshold_ = conf_threshold;
|
||||
}
|
||||
|
||||
/// Get conf_threshold, default 0.25
|
||||
float GetConfThreshold() const { return conf_threshold_; }
|
||||
|
||||
/// Get nms_threshold, default 0.45
|
||||
float GetNMSThreshold() const { return nms_threshold_; }
|
||||
|
||||
// Set model_type
|
||||
void SetModelType(ModelType model_type);
|
||||
|
||||
// Set height and weight
|
||||
void SetHeightAndWeight(int& height, int& width) {
|
||||
height_ = height;
|
||||
width_ = width;
|
||||
}
|
||||
|
||||
// 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; }
|
||||
|
||||
private:
|
||||
ModelType model_type_ = ModelType::UNKNOWN;
|
||||
std::vector<int> anchors_ = {10, 13, 16, 30, 33, 23, 30, 61, 62,
|
||||
45, 59, 119, 116, 90, 156, 198, 373, 326};
|
||||
int strides_[3] = {8, 16, 32};
|
||||
int height_ = 0;
|
||||
int width_ = 0;
|
||||
int anchor_per_branch_ = 0;
|
||||
|
||||
// Process Int8 Model
|
||||
int ProcessInt8(int8_t* 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, int32_t zp, float scale);
|
||||
|
||||
// Model
|
||||
int QuickSortIndiceInverse(std::vector<float>& input, int left, int right,
|
||||
std::vector<int>& indices);
|
||||
|
||||
// post_process values
|
||||
std::vector<std::vector<int>> pad_hw_values_;
|
||||
std::vector<float> scale_;
|
||||
float nms_threshold_ = 0.45;
|
||||
float conf_threshold_ = 0.25;
|
||||
int prob_box_size = 85;
|
||||
int obj_class_num = 80;
|
||||
int obj_num_bbox_max_size = 200;
|
||||
};
|
||||
|
||||
} // namespace detection
|
||||
} // namespace vision
|
||||
} // namespace fastdeploy
|
Reference in New Issue
Block a user