mirror of
https://github.com/deepinsight/insightface.git
synced 2026-05-16 05:27:56 +00:00
Update inspireface to 1.2.0
This commit is contained in:
56
cpp-package/inspireface/cpp/test/settings/check.h
Normal file
56
cpp-package/inspireface/cpp/test/settings/check.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* Created by Jingyu Yan
|
||||
* @date 2025-03-14
|
||||
*/
|
||||
#pragma once
|
||||
#ifndef INSPIREFACE_TEST_CHECK_
|
||||
#define INSPIREFACE_TEST_CHECK_
|
||||
|
||||
#include <cstdint> // for uint8_t
|
||||
#include <limits> // for std::numeric_limits
|
||||
#include <sstream>
|
||||
|
||||
#define REQUIRE_EQ_IMAGE(a, b, h, w, c) \
|
||||
do { \
|
||||
double eps = 0.01; \
|
||||
double mse = CalculateImageMSE(a, b, h, w, c); \
|
||||
REQUIRE(mse <= eps); \
|
||||
if (mse > eps) { \
|
||||
std::stringstream ss; \
|
||||
ss << "Image comparison failed! MSE: " << mse << " (threshold: " << eps << "), dimensions: " << h << "x" << w << "x" << c; \
|
||||
INFO(ss.str()); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define REQUIRE_EQ_IMAGE_WITH_EPS(a, b, h, w, c, eps) \
|
||||
do { \
|
||||
double mse = CalculateImageMSE(a, b, h, w, c); \
|
||||
REQUIRE(mse <= eps); \
|
||||
if (mse > eps) { \
|
||||
std::stringstream ss; \
|
||||
ss << "Image comparison failed! MSE: " << mse << " (threshold: " << eps << "), dimensions: " << h << "x" << w << "x" << c; \
|
||||
INFO(ss.str()); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
inline double CalculateImageMSE(const uint8_t* a, const uint8_t* b, int h, int w, int c) {
|
||||
if (a == nullptr || b == nullptr || h <= 0 || w <= 0 || c <= 0) {
|
||||
return std::numeric_limits<double>::infinity();
|
||||
}
|
||||
|
||||
double sum_squared_diff = 0.0;
|
||||
size_t total_pixels = static_cast<size_t>(h) * w * c;
|
||||
const double normalize_factor = 255.0;
|
||||
|
||||
for (size_t i = 0; i < total_pixels; ++i) {
|
||||
double a_normalized = static_cast<double>(a[i]) / normalize_factor;
|
||||
double b_normalized = static_cast<double>(b[i]) / normalize_factor;
|
||||
|
||||
double diff = a_normalized - b_normalized;
|
||||
sum_squared_diff += diff * diff;
|
||||
}
|
||||
|
||||
return sum_squared_diff / total_pixels;
|
||||
}
|
||||
|
||||
#endif // INSPIREFACE_TEST_CHECK_
|
||||
@@ -1,6 +1,7 @@
|
||||
//
|
||||
// Created by Tunm-Air13 on 2024/4/7.
|
||||
//
|
||||
/**
|
||||
* Created by Jingyu Yan
|
||||
* @date 2024-10-01
|
||||
*/
|
||||
#pragma once
|
||||
#ifndef INSPIREFACE_ENVIRO_H
|
||||
#define INSPIREFACE_ENVIRO_H
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
//
|
||||
// Created by Tunm-Air13 on 2023/5/24.
|
||||
//
|
||||
/**
|
||||
* Created by Jingyu Yan
|
||||
* @date 2024-10-01
|
||||
*/
|
||||
|
||||
#include "test_settings.h"
|
||||
|
||||
|
||||
std::string getTestDataDir() {
|
||||
return Enviro::getInstance().getTestResDir();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
//
|
||||
// Created by Tunm-Air13 on 2023/5/24.
|
||||
//
|
||||
/**
|
||||
* Created by Jingyu Yan
|
||||
* @date 2024-10-01
|
||||
*/
|
||||
#pragma once
|
||||
#ifndef BIGGUYSMAIN_TEST_SETTINGS_H
|
||||
#define BIGGUYSMAIN_TEST_SETTINGS_H
|
||||
@@ -8,6 +9,8 @@
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <iostream>
|
||||
#include "enviro.h"
|
||||
#include "check.h"
|
||||
#include "inspireface/middleware/system.h"
|
||||
|
||||
// Define the test model file
|
||||
#define TEST_MODEL_FILE Enviro::getInstance().getPackName()
|
||||
@@ -41,6 +44,8 @@ using namespace Catch::Detail;
|
||||
#define TEST_PRINT_OUTPUT(open) TestMessageBroadcast test_msg_broadcast_##open(open)
|
||||
// Set the log output level
|
||||
#define LOG_OUTPUT_LEVEL(level) LogLevelBroadcast log_level_broadcast_##level(level);
|
||||
// Print test error message
|
||||
#define TEST_ERROR_PRINT(...) SPDLOG_LOGGER_CALL(spdlog::get("TEST"), spdlog::level::err, __VA_ARGS__)
|
||||
|
||||
// Get the test data directory
|
||||
#define GET_DIR getTestDataDir()
|
||||
|
||||
Reference in New Issue
Block a user