1 /** 2 * Copyright 2020 Huawei Technologies Co., Ltd 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 #ifndef MINDSPORE_CORE_OPS_DETECTION_POST_PROCESS_H_ 17 #define MINDSPORE_CORE_OPS_DETECTION_POST_PROCESS_H_ 18 19 #include <map> 20 #include <vector> 21 #include <string> 22 #include <memory> 23 #include "ops/primitive_c.h" 24 #include "abstract/abstract_value.h" 25 #include "utils/check_convert_utils.h" 26 27 namespace mindspore { 28 namespace ops { 29 constexpr auto kNameDetectionPostProcess = "DetectionPostProcess"; 30 class MS_CORE_API DetectionPostProcess : public PrimitiveC { 31 public: DetectionPostProcess()32 DetectionPostProcess() : PrimitiveC(kNameDetectionPostProcess) {} 33 ~DetectionPostProcess() = default; 34 MS_DECLARE_PARENT(DetectionPostProcess, PrimitiveC); 35 void Init(const int64_t inputSize, const std::vector<float> &scale, const float NmsIouThreshold, 36 const float NmsScoreThreshold, const int64_t MaxDetections, const int64_t DetectionsPerClass, 37 const int64_t MaxClassesPerDetection, const int64_t NumClasses, const bool UseRegularNms, 38 const bool OutQuantized, const Format &format = NCHW); 39 // scale:(h,w,x,y) 40 void set_input_size(const int64_t inputSize); 41 void set_scale(const std::vector<float> &scale); 42 void set_nms_iou_threshold(const float NmsIouThreshold); 43 void set_nms_score_threshold(const float NmsScoreThreshold); 44 void set_max_detections(const int64_t MaxDetections); 45 void set_detections_per_class(const int64_t DetectionsPerClass); 46 void set_max_classes_per_detection(const int64_t MaxClassesPerDetection); 47 void set_num_classes(const int64_t NumClasses); 48 void set_use_regular_nms(const bool UseRegularNms); 49 void set_out_quantized(const bool OutQuantized); 50 void set_format(const Format &format); 51 52 int64_t get_input_size() const; 53 std::vector<float> get_scale() const; 54 float get_nms_iou_threshold() const; 55 float get_nms_score_threshold() const; 56 int64_t get_max_detections() const; 57 int64_t get_detections_per_class() const; 58 int64_t get_max_classes_per_detection() const; 59 int64_t get_num_classes() const; 60 61 bool get_use_regular_nms() const; 62 bool get_out_quantized() const; 63 Format get_format() const; 64 }; 65 AbstractBasePtr DetectionPostProcessInfer(const abstract::AnalysisEnginePtr &, const PrimitivePtr &primitive, 66 const std::vector<AbstractBasePtr> &input_args); 67 using PrimDetectionPostProcessPtr = std::shared_ptr<DetectionPostProcess>; 68 } // namespace ops 69 } // namespace mindspore 70 71 #endif // MINDSPORE_CORE_OPS_DETECTION_POST_PROCESS_H_ 72