diff --git a/modules/ANSFR/ANSFRCommon.cpp b/modules/ANSFR/ANSFRCommon.cpp index fc95b49..99739a8 100644 --- a/modules/ANSFR/ANSFRCommon.cpp +++ b/modules/ANSFR/ANSFRCommon.cpp @@ -646,29 +646,21 @@ namespace ANSCENTER { if (face.isEmotionsEnabled()) { const auto& [emotionName, emotionConfidence] = face.getMainEmotion(); std::ostringstream emotionStr; + // The v1.4 ONNX classifier's classes (emotionsrecognition.names: + // Angry, Fear, Happy, Neutral, Sad) are reported VERBATIM. Only + // the legacy OpenVINO model's lowercase classes keep the + // historical display remap so v1.1 output is unchanged. std::string adjustedEmotionName = emotionName; - if (emotionName == "Sad" || emotionName == "sad") + if (emotionName == "sad") adjustedEmotionName = "Attentive"; - else if (emotionName == "Happy" || emotionName == "happy") + else if (emotionName == "happy") adjustedEmotionName = "Happy"; - else if (emotionName == "Neutral" || emotionName == "neutral") + else if (emotionName == "neutral") adjustedEmotionName = "Neutral"; - else if (emotionName == "Angry" || emotionName == "angry") + else if (emotionName == "anger") adjustedEmotionName = "Attentive"; - else if (emotionName == "Surprised" || emotionName == "surprised") + else if (emotionName == "surprise") adjustedEmotionName = "Attentive"; - else if (emotionName == "Surprise" || emotionName == "surprise") - adjustedEmotionName = "Attentive"; - else if (emotionName == "Disgusted" || emotionName == "disgusted") - adjustedEmotionName = "Attentive"; - else if (emotionName == "Fearful" || emotionName == "fearful") - adjustedEmotionName = "Attentive"; - else if (emotionName == "Fear" || emotionName == "fear") - adjustedEmotionName = "Attentive"; - else if (emotionName == "Anger" || emotionName == "anger") - adjustedEmotionName = "Attentive"; - else - adjustedEmotionName = "Neutral"; emotionStr << adjustedEmotionName << " (" << static_cast(emotionConfidence * 100) << "%)"; detectedNode.put("Emotion", emotionStr.str()); diff --git a/tests/ANSFR-UnitTest/ANSFR-UnitTest.cpp b/tests/ANSFR-UnitTest/ANSFR-UnitTest.cpp index d95e72c..bda8e9c 100644 --- a/tests/ANSFR-UnitTest/ANSFR-UnitTest.cpp +++ b/tests/ANSFR-UnitTest/ANSFR-UnitTest.cpp @@ -2184,8 +2184,12 @@ int TestOutputFormatParity() V14Check(attrKeys(oldFirst) == attrKeys(newFirst), "attribute keys identical", failures); - // 3. Value vocabularies must match on every face of both packs - auto checkVocab = [&](const boost::property_tree::ptree& pt, const char* label) { + // 3. Value vocabularies must match on every face of both packs. + // Gender/Age vocabularies are shared; the Emotion vocabulary is + // per-pack: v1.1's legacy display names vs v1.4's verbatim class + // names from emotionsrecognition.names. + auto checkVocab = [&](const boost::property_tree::ptree& pt, const char* label, + const std::vector& emotionVocab) { for (const auto& child : pt.get_child("results")) { auto ept = parse(child.second.get("extra_info")); for (const auto& attr : ept.get_child("attributes")) { @@ -2196,16 +2200,19 @@ int TestOutputFormatParity() std::string(label) + " Gender in {Male, Female}: " + gender, failures); V14Check(age == "Kids" || age == "Young Adults" || age == "Adults" || age == "Elders", std::string(label) + " Age in bucket set: " + age, failures); - const bool emotionOk = - (emotion.rfind("Happy", 0) == 0 || emotion.rfind("Neutral", 0) == 0 || - emotion.rfind("Attentive", 0) == 0) && emotion.find("%)") != std::string::npos; + bool emotionOk = emotion.find("%)") != std::string::npos; + if (emotionOk) { + emotionOk = false; + for (const auto& name : emotionVocab) + if (emotion.rfind(name, 0) == 0) { emotionOk = true; break; } + } V14Check(emotionOk, std::string(label) + " Emotion label/format: " + emotion, failures); } } }; - checkVocab(oldPt, "v1.1"); - checkVocab(newPt, "v1.4"); + checkVocab(oldPt, "v1.1", { "Happy", "Neutral", "Attentive" }); + checkVocab(newPt, "v1.4", { "Angry", "Fear", "Happy", "Neutral", "Sad" }); // 4. Both packs must recognize the enrolled user (same matching semantics) V14Check(oldJson.find("ParityUser") != std::string::npos, "v1.1 recognizes enrolled user", failures);