plugin  0.1.0
detection_model_retinaface.h
1 /*
2 // Copyright (C) 2020-2024 Intel Corporation
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 
17 #pragma once
18 #include <map>
19 #include <memory>
20 #include <string>
21 #include <vector>
22 
23 #include <utils/nms.hpp>
24 
25 #include "models/detection_model.h"
26 
27 namespace ov {
28 class Model;
29 } // namespace ov
30 struct InferenceResult;
31 struct ResultBase;
32 
34 public:
35  static const int LANDMARKS_NUM = 5;
36  static const int INIT_VECTOR_SIZE = 200;
44  ModelRetinaFace(const std::string& model_name,
45  float confidenceThreshold,
46  bool useAutoResize,
47  float boxIOUThreshold,
48  const std::string& layout = "");
49  std::unique_ptr<ResultBase> postprocess(InferenceResult& infResult) override;
50 
51 protected:
52  struct AnchorCfgLine {
53  int stride;
54  std::vector<int> scales;
55  int baseSize;
56  std::vector<int> ratios;
57  };
58 
59  bool shouldDetectMasks;
60  bool shouldDetectLandmarks;
61  const float boxIOUThreshold;
62  const float maskThreshold;
63  float landmarkStd;
64 
65  enum OutputType { OUT_BOXES, OUT_SCORES, OUT_LANDMARKS, OUT_MASKSCORES, OUT_MAX };
66 
67  std::vector<std::string> separateOutputsNames[OUT_MAX];
68  const std::vector<AnchorCfgLine> anchorCfg;
69  std::map<int, std::vector<Anchor>> anchorsFpn;
70  std::vector<std::vector<Anchor>> anchors;
71 
72  void generateAnchorsFpn();
73  void prepareInputsOutputs(std::shared_ptr<ov::Model>& model) override;
74 };
Definition: detection_model.h:25
Definition: detection_model_retinaface.h:33
ModelRetinaFace(const std::string &model_name, float confidenceThreshold, bool useAutoResize, float boxIOUThreshold, const std::string &layout="")
Definition: detection_model_retinaface.cpp:34
Definition: results.h:53
Definition: detection_model_retinaface.h:52
Definition: results.h:29