1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 08:13:04 +04:00

Added TF resize_bilinear behaviour alignment

Fixes OpenCV issue #18721
This commit is contained in:
Anastasia Murzova
2020-12-03 01:48:18 +03:00
parent e8348e5f64
commit a82c50eac2
3 changed files with 53 additions and 5 deletions
+47 -4
View File
@@ -81,12 +81,12 @@ class Test_TensorFlow_layers : public DNNTestLayer
{
public:
void runTensorFlowNet(const std::string& prefix, bool hasText = false,
double l1 = 0.0, double lInf = 0.0, bool memoryLoad = false)
double l1 = 0.0, double lInf = 0.0, bool memoryLoad = false, const std::string& groupPrefix = "")
{
std::string netPath = path(prefix + "_net.pb");
std::string netConfig = (hasText ? path(prefix + "_net.pbtxt") : "");
std::string netPath = path(prefix + groupPrefix + "_net.pb");
std::string netConfig = (hasText ? path(prefix + groupPrefix + "_net.pbtxt") : "");
std::string inpPath = path(prefix + "_in.npy");
std::string outPath = path(prefix + "_out.npy");
std::string outPath = path(prefix + groupPrefix + "_out.npy");
cv::Mat input = blobFromNPY(inpPath);
cv::Mat ref = blobFromNPY(outPath);
@@ -975,10 +975,53 @@ TEST_P(Test_TensorFlow_layers, keras_mobilenet_head)
runTensorFlowNet("keras_learning_phase");
}
// TF case: align_corners=False, half_pixel_centers=False
TEST_P(Test_TensorFlow_layers, resize_bilinear)
{
runTensorFlowNet("resize_bilinear");
}
// TF case: align_corners=True, half_pixel_centers=False
TEST_P(Test_TensorFlow_layers, resize_bilinear_align_corners)
{
runTensorFlowNet("resize_bilinear",
false, 0.0, 0.0, false, // default parameters
"_align_corners");
}
// TF case: align_corners=False, half_pixel_centers=True
TEST_P(Test_TensorFlow_layers, resize_bilinear_half_pixel)
{
if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
runTensorFlowNet("resize_bilinear", false, 0.0, 0.0, false, "_half_pixel");
}
// TF case: align_corners=False, half_pixel_centers=False
TEST_P(Test_TensorFlow_layers, resize_bilinear_factor)
{
runTensorFlowNet("resize_bilinear_factor");
}
// TF case: align_corners=False, half_pixel_centers=True
TEST_P(Test_TensorFlow_layers, resize_bilinear_factor_half_pixel)
{
if (backend == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH)
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_NGRAPH);
runTensorFlowNet("resize_bilinear_factor", false, 0.0, 0.0, false, "_half_pixel");
}
// TF case: align_corners=True, half_pixel_centers=False
TEST_P(Test_TensorFlow_layers, resize_bilinear_factor_align_corners)
{
runTensorFlowNet("resize_bilinear_factor", false, 0.0, 0.0, false, "_align_corners");
}
// TF case: align_corners=False, half_pixel_centers=False
TEST_P(Test_TensorFlow_layers, resize_bilinear_down)
{
runTensorFlowNet("resize_bilinear_down");
}