Skip to content

Commit

Permalink
Set NRMSE and RRMSE print precision and adjust condition for PSNR metric
Browse files Browse the repository at this point in the history
  • Loading branch information
beleiuandrei committed Sep 16, 2024
1 parent e415906 commit 7dd1277
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/plugins/intel_npu/tools/single-image-test/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1183,7 +1183,8 @@ bool computeRRMSE(const ov::Tensor& output, const ov::Tensor& reference) {

double rrmseLoss = sqrt(error / sum);

std::cout << "RRMSE loss : " << rrmseLoss << " RRMSE threshold : " << FLAGS_rrmse_loss_threshold << std::endl;
std::cout << "RRMSE loss : " << std::fixed << std::setprecision(4) << rrmseLoss
<< " RRMSE threshold : " << FLAGS_rrmse_loss_threshold << std::endl;
return rrmseLoss <= FLAGS_rrmse_loss_threshold;
}

Expand Down Expand Up @@ -1250,7 +1251,8 @@ bool computeNRMSE(const ov::Tensor& output, const ov::Tensor& reference) {
double nrmseLoss =
sqrt(error / size) / std::max(0.001f, std::max(maxOutput - minOutput, maxReference - minReference));

std::cout << "NRMSE loss : " << nrmseLoss << " NRMSE threshold : " << FLAGS_nrmse_loss_threshold << std::endl;
std::cout << "NRMSE loss : " << std::fixed << std::setprecision(4) << nrmseLoss
<< " NRMSE threshold : " << FLAGS_nrmse_loss_threshold << std::endl;
return nrmseLoss <= FLAGS_nrmse_loss_threshold;
}

Expand Down Expand Up @@ -1302,7 +1304,7 @@ bool testPSNR(const TensorMap& outputs, const TensorMap& references, const int d

auto result = utils::runPSNRMetric(actOutput, refOutput, dstHeight, dstWidth, scaleBorder, normalizedImage);

if (std::fabs(result - FLAGS_psnr_reference) > FLAGS_psnr_tolerance) {
if (FLAGS_psnr_reference - result > FLAGS_psnr_tolerance) {
std::cout << "Absolute difference between actual value " << result << " and reference value "
<< FLAGS_psnr_reference << " larger then tolerance " << FLAGS_psnr_tolerance << std::endl;
return false;
Expand Down Expand Up @@ -1378,7 +1380,6 @@ void setupOVCore(ov::Core& core) {

if (FLAGS_device == "CPU") {
core.set_property(flagDevice, {{"LP_TRANSFORMS_MODE", "NO"}});
core.set_property(flagDevice, {{"DYNAMIC_QUANTIZATION_GROUP_SIZE", "0"}});
}

if (FLAGS_pc) {
Expand Down

0 comments on commit 7dd1277

Please sign in to comment.