From 95aec835e6ee59099581212796e82d3f2957e5f7 Mon Sep 17 00:00:00 2001 From: sweetsky0901 Date: Thu, 28 Dec 2017 16:10:28 +0800 Subject: [PATCH] modify fun name --- paddle/operators/detection_output_op.h | 18 +++--- paddle/operators/math/detection_util.h | 80 +++++++++++++------------- 2 files changed, 49 insertions(+), 49 deletions(-) diff --git a/paddle/operators/detection_output_op.h b/paddle/operators/detection_output_op.h index c0a4e6a3a23..cd6417087a0 100644 --- a/paddle/operators/detection_output_op.h +++ b/paddle/operators/detection_output_op.h @@ -119,22 +119,22 @@ class DetectionOutputKernel : public framework::OpKernel { size_t prior_offset = i * 8; size_t loc_pred_offset = n * num_priors * 4 + i * 4; std::vector> prior_bbox_vec; - math::get_bbox_from_priorData(priorbox_data + prior_offset, 1, - prior_bbox_vec); + math::GetBBoxFromPriorData(priorbox_data + prior_offset, 1, + prior_bbox_vec); std::vector> prior_bbox_var; - math::get_bbox_var_from_prior_data(priorbox_data + prior_offset, 1, - prior_bbox_var); + math::GetBBoxVarFromPriorData(priorbox_data + prior_offset, 1, + prior_bbox_var); std::vector loc_pred_data; for (size_t j = 0; j < 4; ++j) loc_pred_data.push_back(*(loc_data + loc_pred_offset + j)); - math::BBox bbox = math::decode_bbox_with_var( + math::BBox bbox = math::DecodeBBoxWithVar( prior_bbox_vec[0], prior_bbox_var[0], loc_pred_data); decoded_bboxes.push_back(bbox); } all_decoded_bboxes.push_back(decoded_bboxes); } std::vector>> all_indices; - int num_kept = math::get_detection_indices( + int num_kept = math::GetDetectionIndices( conf_data, num_priors, num_classes, background_label_id, batch_size, confidence_threshold, nms_top_k, nms_threshold, top_k, all_decoded_bboxes, &all_indices); @@ -154,9 +154,9 @@ class DetectionOutputKernel : public framework::OpKernel { out_cpu.mutable_data(out->dims(), platform::CPUPlace()); out_data = out_cpu.data(); } - math::get_detection_output(conf_data, num_kept, num_priors, num_classes, - batch_size, all_indices, all_decoded_bboxes, - out_data); + math::GetDetectionOutput(conf_data, num_kept, num_priors, num_classes, + batch_size, all_indices, all_decoded_bboxes, + out_data); if (platform::is_gpu_place(context.GetPlace())) { framework::CopyFrom(out_cpu, platform::CUDAPlace(), context.device_context(), out); diff --git a/paddle/operators/math/detection_util.h b/paddle/operators/math/detection_util.h index d1ae0e63438..e3a3ef2badc 100644 --- a/paddle/operators/math/detection_util.h +++ b/paddle/operators/math/detection_util.h @@ -51,31 +51,31 @@ struct BBox { // KNCHW ==> NHWC // template template -void get_bbox_from_priorData(const T* prior_data, const size_t num_bboxes, - std::vector>& bbox_vec); +void GetBBoxFromPriorData(const T* prior_data, const size_t num_bboxes, + std::vector>& bbox_vec); template -void get_bbox_var_from_prior_data(const T* prior_data, const size_t num, - std::vector>& var_vec); +void GetBBoxVarFromPriorData(const T* prior_data, const size_t num, + std::vector>& var_vec); template -BBox decode_bbox_with_var(BBox& prior_bbox, - const std::vector& prior_bbox_var, - const std::vector& loc_pred_data); +BBox DecodeBBoxWithVar(BBox& prior_bbox, + const std::vector& prior_bbox_var, + const std::vector& loc_pred_data); template -bool sort_score_pair_descend(const std::pair& pair1, - const std::pair& pair2); +bool SortScorePairDescend(const std::pair& pair1, + const std::pair& pair2); template -bool sort_score_pair_descend(const std::pair>& pair1, - const std::pair>& pair2); +bool SortScorePairDescend(const std::pair>& pair1, + const std::pair>& pair2); template T jaccard_overlap(const BBox& bbox1, const BBox& bbox2); template -void apply_nms_fast(const std::vector>& bboxes, - const T* conf_score_data, size_t class_idx, size_t top_k, - T conf_threshold, T nms_threshold, size_t num_priors, - size_t num_classes, std::vector* indices); +void ApplyNmsFast(const std::vector>& bboxes, const T* conf_score_data, + size_t class_idx, size_t top_k, T conf_threshold, + T nms_threshold, size_t num_priors, size_t num_classes, + std::vector* indices); template -int get_detection_indices( +int GetDetectionIndices( const T* conf_data, const size_t num_priors, const size_t num_classes, const size_t background_label_id, const size_t batch_size, const T conf_threshold, const size_t nms_top_k, const T nms_threshold, @@ -83,16 +83,16 @@ int get_detection_indices( const std::vector>>& all_decoded_bboxes, std::vector>>* all_detection_indices); template -BBox clipBBox(const BBox& bbox); +BBox ClipBBox(const BBox& bbox); template -void get_detection_output( +void GetDetectionOutput( const T* conf_data, const size_t num_kept, const size_t num_priors, const size_t num_classes, const size_t batch_size, const std::vector>>& all_indices, const std::vector>>& all_decoded_bboxes, T* out_data); template -void get_bbox_from_priorData(const T* prior_data, const size_t num_bboxes, - std::vector>& bbox_vec) { +void GetBBoxFromPriorData(const T* prior_data, const size_t num_bboxes, + std::vector>& bbox_vec) { size_t out_offset = bbox_vec.size(); bbox_vec.resize(bbox_vec.size() + num_bboxes); for (size_t i = 0; i < num_bboxes; ++i) { @@ -105,8 +105,8 @@ void get_bbox_from_priorData(const T* prior_data, const size_t num_bboxes, } } template -void get_bbox_var_from_prior_data(const T* prior_data, const size_t num, - std::vector>& var_vec) { +void GetBBoxVarFromPriorData(const T* prior_data, const size_t num, + std::vector>& var_vec) { size_t out_offset = var_vec.size(); var_vec.resize(var_vec.size() + num); for (size_t i = 0; i < num; ++i) { @@ -119,9 +119,9 @@ void get_bbox_var_from_prior_data(const T* prior_data, const size_t num, } } template -BBox decode_bbox_with_var(BBox& prior_bbox, - const std::vector& prior_bbox_var, - const std::vector& loc_pred_data) { +BBox DecodeBBoxWithVar(BBox& prior_bbox, + const std::vector& prior_bbox_var, + const std::vector& loc_pred_data) { T prior_bbox_width = prior_bbox.get_width(); T prior_bbox_height = prior_bbox.get_height(); T prior_bbox_center_x = prior_bbox.get_center_x(); @@ -147,8 +147,8 @@ BBox decode_bbox_with_var(BBox& prior_bbox, return decoded_bbox; } template -bool sort_score_pair_descend(const std::pair& pair1, - const std::pair& pair2) { +bool SortScorePairDescend(const std::pair& pair1, + const std::pair& pair2) { return pair1.first > pair2.first; } template @@ -174,10 +174,10 @@ T jaccard_overlap(const BBox& bbox1, const BBox& bbox2) { } template -void apply_nms_fast(const std::vector>& bboxes, - const T* conf_score_data, size_t class_idx, size_t top_k, - T conf_threshold, T nms_threshold, size_t num_priors, - size_t num_classes, std::vector* indices) { +void ApplyNmsFast(const std::vector>& bboxes, const T* conf_score_data, + size_t class_idx, size_t top_k, T conf_threshold, + T nms_threshold, size_t num_priors, size_t num_classes, + std::vector* indices) { std::vector> scores; for (size_t i = 0; i < num_priors; ++i) { size_t conf_offset = i * num_classes + class_idx; @@ -185,7 +185,7 @@ void apply_nms_fast(const std::vector>& bboxes, scores.push_back(std::make_pair(conf_score_data[conf_offset], i)); } std::stable_sort(scores.begin(), scores.end(), - sort_score_pair_descend); + SortScorePairDescend); if (top_k > 0 && top_k < scores.size()) scores.resize(top_k); while (scores.size() > 0) { const size_t idx = scores.front().second; @@ -204,7 +204,7 @@ void apply_nms_fast(const std::vector>& bboxes, } } template -int get_detection_indices( +int GetDetectionIndices( const T* conf_data, const size_t num_priors, const size_t num_classes, const size_t background_label_id, const size_t batch_size, const T conf_threshold, const size_t nms_top_k, const T nms_threshold, @@ -219,9 +219,9 @@ int get_detection_indices( size_t conf_offset = n * num_priors * num_classes; for (size_t c = 0; c < num_classes; ++c) { if (c == background_label_id) continue; - apply_nms_fast(decoded_bboxes, conf_data + conf_offset, c, nms_top_k, - conf_threshold, nms_threshold, num_priors, num_classes, - &(indices[c])); + ApplyNmsFast(decoded_bboxes, conf_data + conf_offset, c, nms_top_k, + conf_threshold, nms_threshold, num_priors, num_classes, + &(indices[c])); num_detected += indices[c].size(); } if (top_k > 0 && num_detected > top_k) { @@ -237,7 +237,7 @@ int get_detection_indices( } } std::sort(score_index_pairs.begin(), score_index_pairs.end(), - sort_score_pair_descend>); + SortScorePairDescend>); score_index_pairs.resize(top_k); std::map> new_indices; for (size_t i = 0; i < score_index_pairs.size(); ++i) { @@ -255,7 +255,7 @@ int get_detection_indices( return total_keep_num; } template -BBox clipBBox(const BBox& bbox) { +BBox ClipBBox(const BBox& bbox) { T one = static_cast(1.0); T zero = static_cast(0.0); BBox clipped_bbox; @@ -266,7 +266,7 @@ BBox clipBBox(const BBox& bbox) { return clipped_bbox; } template -void get_detection_output( +void GetDetectionOutput( const T* conf_data, const size_t num_kept, const size_t num_priors, const size_t num_classes, const size_t batch_size, const std::vector>>& all_indices, @@ -285,7 +285,7 @@ void get_detection_output( out_data[count * 7] = n; out_data[count * 7 + 1] = label; out_data[count * 7 + 2] = (conf_data + conf_offset)[label]; - BBox clipped_bbox = clipBBox(decoded_bboxes[idx]); + BBox clipped_bbox = ClipBBox(decoded_bboxes[idx]); out_data[count * 7 + 3] = clipped_bbox.x_min; out_data[count * 7 + 4] = clipped_bbox.y_min; out_data[count * 7 + 5] = clipped_bbox.x_max; -- GitLab