From: Kwanghoon Son Date: Fri, 26 Aug 2022 02:00:57 +0000 (-0400) Subject: Apply code lint and update copyright year X-Git-Tag: submit/tizen/20220921.082242~17 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fa6bfdb69365fb4285322eccc86aec19516e24d0;p=platform%2Fcore%2Fapi%2Fmediavision.git Apply code lint and update copyright year Change-Id: I53fd18c3c5b3961b8c7e8fb903199e4150bf03e3 Signed-off-by: Kwanghoon Son --- diff --git a/mv_machine_learning/inference/include/ScoreInfo.h b/mv_machine_learning/inference/include/ScoreInfo.h index 2004002..096a120 100644 --- a/mv_machine_learning/inference/include/ScoreInfo.h +++ b/mv_machine_learning/inference/include/ScoreInfo.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2021 - 2022 Samsung Electronics Co., Ltd 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. @@ -30,103 +30,130 @@ namespace mediavision { namespace inference { - struct DeQuantization +struct DeQuantization +{ + double scale; + double zeropoint; + + DeQuantization(double s, double z) : scale(s), zeropoint(z) + {} +}; + +class ScoreInfo +{ +private: + std::string name; + DimInfo dimInfo; + double threshold; + int topNumber; + inference_score_type_e type; + std::shared_ptr deQuantization; + std::map supportedScoreTypes; + +public: + ScoreInfo() + : name() + , dimInfo() + , threshold(0.0) + , topNumber(1) + , type(INFERENCE_SCORE_TYPE_NORMAL) + , deQuantization(nullptr) { - double scale; - double zeropoint; + // Score type + supportedScoreTypes.insert({ "NORMAL", INFERENCE_SCORE_TYPE_NORMAL }); + supportedScoreTypes.insert({ "SIGMOID", INFERENCE_SCORE_TYPE_SIGMOID }); + } - DeQuantization(double s, double z) : scale(s), zeropoint(z) { } - }; + ~ScoreInfo() = default; - class ScoreInfo + std::string GetName() { - private: - std::string name; - DimInfo dimInfo; - double threshold; - int topNumber; - inference_score_type_e type; - std::shared_ptr deQuantization; - std::map supportedScoreTypes; - - public: - ScoreInfo() : - name(), - dimInfo(), - threshold(0.0), - topNumber(1), - type(INFERENCE_SCORE_TYPE_NORMAL), - deQuantization(nullptr) - { - // Score type - supportedScoreTypes.insert({"NORMAL", INFERENCE_SCORE_TYPE_NORMAL}); - supportedScoreTypes.insert({"SIGMOID", INFERENCE_SCORE_TYPE_SIGMOID}); - } + return name; + } + DimInfo GetDimInfo() + { + return dimInfo; + } + double GetThresHold() + { + return threshold; + } + inference_score_type_e GetType() + { + return type; + } + int GetTopNumber() + { + return topNumber; + } + std::shared_ptr GetDeQuant() + { + return deQuantization; + } + double GetDeQuantScale() + { + return deQuantization->scale; + } + double GetDeQuantZeroPoint() + { + return deQuantization->zeropoint; + } - ~ScoreInfo() = default; - - std::string GetName() { return name; } - DimInfo GetDimInfo() { return dimInfo; } - double GetThresHold() { return threshold; } - inference_score_type_e GetType() { return type; } - int GetTopNumber() { return topNumber; } - std::shared_ptr GetDeQuant() { return deQuantization; } - double GetDeQuantScale() { return deQuantization->scale; } - double GetDeQuantZeroPoint() { return deQuantization->zeropoint; } - - int ParseScore(JsonObject *root) - { - LOGI("ENTER"); - - JsonArray * rootArray = json_object_get_array_member(root, "score"); - unsigned int elements = json_array_get_length(rootArray); - - for (unsigned int elem = 0; elem < elements; ++elem) { - JsonNode *pNode = json_array_get_element(rootArray, elem); - JsonObject *pObject = json_node_get_object(pNode); - - name = json_object_get_string_member(pObject,"name"); - LOGI("layer: %s", name.c_str()); - - JsonArray * array = json_object_get_array_member(pObject, "index"); - unsigned int elements2 = json_array_get_length(array); - LOGI("range dim: size[%u]", elements2); - for (unsigned int elem2 = 0; elem2 < elements2; ++elem2) { - if (static_cast(json_array_get_int_element(array, elem2)) == 1) - dimInfo.SetValidIndex(elem2); - } - if (json_object_has_member(pObject, "top_number")) - topNumber = static_cast( - json_object_get_int_member(pObject, "top_number")); - LOGI("top number: %d", topNumber); - - if (json_object_has_member(pObject, "threshold")) - threshold = static_cast( - json_object_get_double_member(pObject, "threshold")); - LOGI("threshold: %1.3f", threshold); - - try { - type = GetSupportedType(pObject, "score_type", supportedScoreTypes); - } catch (const std::exception& e) { - LOGE("Invalid %s", e.what()); - return MEDIA_VISION_ERROR_INVALID_OPERATION; - } - - if (json_object_has_member(pObject, "dequantization")) { - array = json_object_get_array_member(pObject, "dequantization"); - JsonNode *node = json_array_get_element(array, 0); - JsonObject *object = json_node_get_object(node); - - deQuantization = std::make_shared( + int ParseScore(JsonObject *root) + { + LOGI("ENTER"); + + JsonArray *rootArray = json_object_get_array_member(root, "score"); + unsigned int elements = json_array_get_length(rootArray); + + for (unsigned int elem = 0; elem < elements; ++elem) { + JsonNode *pNode = json_array_get_element(rootArray, elem); + JsonObject *pObject = json_node_get_object(pNode); + + name = json_object_get_string_member(pObject, "name"); + LOGI("layer: %s", name.c_str()); + + JsonArray *array = json_object_get_array_member(pObject, "index"); + unsigned int elements2 = json_array_get_length(array); + LOGI("range dim: size[%u]", elements2); + for (unsigned int elem2 = 0; elem2 < elements2; ++elem2) { + if (static_cast( + json_array_get_int_element(array, elem2)) == 1) + dimInfo.SetValidIndex(elem2); + } + if (json_object_has_member(pObject, "top_number")) + topNumber = static_cast( + json_object_get_int_member(pObject, "top_number")); + LOGI("top number: %d", topNumber); + + if (json_object_has_member(pObject, "threshold")) + threshold = static_cast( + json_object_get_double_member(pObject, "threshold")); + LOGI("threshold: %1.3f", threshold); + + try { + type = GetSupportedType(pObject, "score_type", + supportedScoreTypes); + } catch (const std::exception &e) { + LOGE("Invalid %s", e.what()); + return MEDIA_VISION_ERROR_INVALID_OPERATION; + } + + if (json_object_has_member(pObject, "dequantization")) { + array = json_object_get_array_member(pObject, "dequantization"); + JsonNode *node = json_array_get_element(array, 0); + JsonObject *object = json_node_get_object(node); + + deQuantization = std::make_shared( json_object_get_double_member(object, "scale"), json_object_get_double_member(object, "zeropoint")); - } } - - LOGI("LEAVE"); - return MEDIA_VISION_ERROR_NONE; } - }; + + LOGI("LEAVE"); + return MEDIA_VISION_ERROR_NONE; + } +}; } /* Inference */ } /* MediaVision */