2 * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef __INFERENCE_ENGINE_OUTPUTMETADATA_H__
18 #define __INFERENCE_ENGINE_OUTPUTMETADATA_H__
25 #include "inference_engine_error.h"
26 #include "inference_engine_private_type.h"
27 #include "inference_engine_type.h"
30 #include "OutputMetadataTypes.h"
31 #include <json-glib/json-glib.h>
34 * @file OutputMetadata.h
35 * @brief This file contains the metadata class definition which
36 * provides metadata of a model.
39 namespace InferenceEngineInterface
46 std::vector<int> dims;
48 std::vector<int> GetValidIndexAll() const;
49 void SetValidIndex(int index);
58 DeQuantization(double s, double z) : scale(s), zeropoint(z) {};
59 ~DeQuantization() = default;
61 double GetScale() { return scale; }
62 double GetZeroPoint() { return zeropoint; }
71 inference_score_type_e type;
73 std::shared_ptr<DeQuantization> deQuantization;
75 std::map<std::string, inference_score_type_e> supportedScoreTypes;
79 ~ScoreInfo() = default;
81 std::string GetName() { return name; }
82 DimInfo GetDimInfo() { return dimInfo; }
83 double GetThresHold() { return threshold; }
84 inference_score_type_e GetType() { return type; }
85 int GetTopNumber() { return topNumber; }
86 std::shared_ptr<DeQuantization> GetDeQuant() { return deQuantization; }
88 int ParseScore(JsonObject *root);
96 inference_box_type_e type;
97 std::vector<int> order;
98 inference_box_coordinate_type_e coordinate;
99 inference_box_decoding_type_e decodingType;
101 std::map<std::string, inference_box_type_e> supportedBoxTypes;
102 std::map<std::string, inference_box_coordinate_type_e> supportedBoxCoordinateTypes;
103 std::map<std::string, inference_box_decoding_type_e> supportedBoxDecodingTypes;
107 ~BoxInfo() = default;
109 std::string GetName() { return name; }
110 DimInfo GetDimInfo() { return dimInfo; }
111 inference_box_type_e GetType() { return type; }
112 inference_box_decoding_type_e GetDecodingType() { return decodingType; }
113 std::vector<int> GetOrder() { return order; }
114 int GetCoordinate() { return coordinate; }
116 int ParseBox(JsonObject *root);
124 inference_box_decoding_type_e decodingType;
129 std::string GetName() { return name; }
130 DimInfo GetDimInfo() { return dimInfo; }
132 int ParseLabel(JsonObject *root);
144 std::string GetName() { return name; }
145 DimInfo GetDimInfo() { return dimInfo; }
147 int ParseNumber(JsonObject *root);
160 inference_tensor_shape_type_e shapeType;
162 HeatMapInfo() = default;
163 ~HeatMapInfo() = default;
166 DecodeInfo() = default;
167 ~DecodeInfo() = default;
172 inference_landmark_type_e type;
174 inference_landmark_coorindate_type_e coordinate;
175 inference_landmark_decoding_type_e decodingType;
176 DecodeInfo decodingInfo;
178 std::map<std::string, inference_landmark_type_e> supportedLandmarkTypes;
179 std::map<std::string, inference_landmark_coorindate_type_e> supportedLandmarkCoordinateTypes;
180 std::map<std::string, inference_landmark_decoding_type_e> supportedLandmarkDecodingTypes;
184 ~Landmark() = default;
185 std::string GetName() { return name; }
186 DimInfo GetDimInfo() { return dimInfo; }
187 inference_landmark_type_e GetType();
189 inference_landmark_coorindate_type_e GetCoordinate();
190 inference_landmark_decoding_type_e GetDecodingType();
191 DecodeInfo& GetDecodingInfo();
193 int ParseLandmark(JsonObject *root);
203 OffsetVec() = default;
204 ~OffsetVec() = default;
205 std::string GetName() { return name; }
206 DimInfo GetDimInfo() { return dimInfo; }
207 int GetShapeType() { return shapeType; }
209 int ParseOffset(JsonObject *root);
217 inference_displacement_type_e type;
219 std::map<std::string, inference_displacement_type_e> supportedDispTypes;
222 ~DispVec() = default;
223 std::string GetName() { return name; }
224 DimInfo GetDimInfo() { return dimInfo; }
225 inference_displacement_type_e GetType() { return type; }
226 int GetShapeType() { return shapeType; }
228 int ParseDisplacement(JsonObject *root);
234 std::vector<std::pair<int, int>> edges;
238 int ParseEdge(JsonObject *root);
239 std::vector<std::pair<int, int>>& GetEdgesAll();
252 std::vector<DispVec> dispVecs;
255 int ParseScore(JsonObject *root);
256 int ParseBox(JsonObject *root);
257 int ParseLabel(JsonObject *root);
258 int ParseNumber(JsonObject *root);
259 int ParseLandmark(JsonObject *root);
260 int ParseLandmarkDecodeInfo(JsonObject *root);
261 int ParseOffset(JsonObject *root);
262 int ParseDisplacement(JsonObject *root);
263 int ParseEdgeMap(JsonObject *root);
266 static std::map<std::string, inference_tensor_shape_type_e> supportedTensorShapes;
268 * @brief Creates an OutputMetadata class instance.
275 * @brief Destroys an OutputMetadata class instance including
280 ~OutputMetadata() = default;
282 /** @brief Parses an OutputMetadata
286 int Parse(JsonObject *root);
289 ScoreInfo& GetScore();
293 Landmark& GetLandmark();
294 OffsetVec& GetOffset();
295 std::vector<DispVec>& GetDispVecAll();
297 template <typename T>
298 static T GetSupportedType(JsonObject* root, std::string typeName,
299 std::map<std::string, T>& supportedTypes);
305 #endif /* __INFERENCE_ENGINE_OUTPUTMETADATA_H__ */