diff --git a/3rdparty/carotene/src/resize.cpp b/3rdparty/carotene/src/resize.cpp index 49205573cd..aa5b756c75 100644 --- a/3rdparty/carotene/src/resize.cpp +++ b/3rdparty/carotene/src/resize.cpp @@ -758,7 +758,7 @@ inline void resizeAreaRounding(const Size2D &ssize, const Size2D &dsize, } else if (channels == 3) { - if ((wr == 2.0f) && (wr == 2.0f)) + if ((wr == 2.0f) && (hr == 2.0f)) { #ifndef __ANDROID__ size_t roiw16 = dsize.width >= 15 ? (dsize.width - 15) * 3 : 0; diff --git a/cmake/OpenCVFindLibsGrfmt.cmake b/cmake/OpenCVFindLibsGrfmt.cmake index 2e4e4afa9d..23a6ca6959 100644 --- a/cmake/OpenCVFindLibsGrfmt.cmake +++ b/cmake/OpenCVFindLibsGrfmt.cmake @@ -7,9 +7,17 @@ if(BUILD_ZLIB) ocv_clear_vars(ZLIB_FOUND) else() ocv_clear_internal_cache_vars(ZLIB_LIBRARY ZLIB_INCLUDE_DIR) + if(ANDROID) + set(_zlib_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + set(CMAKE_FIND_LIBRARY_SUFFIXES .so) + endif() find_package(ZLIB "${MIN_VER_ZLIB}") + if(ANDROID) + set(CMAKE_FIND_LIBRARY_SUFFIXES ${_zlib_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) + unset(_zlib_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES) + endif() if(ZLIB_FOUND AND ANDROID) - if(ZLIB_LIBRARIES MATCHES "/usr/(lib|lib32|lib64)/libz.so$") + if(ZLIB_LIBRARIES MATCHES "/usr/lib.*/libz.so$") set(ZLIB_LIBRARIES z) endif() endif() diff --git a/cmake/OpenCVUtils.cmake b/cmake/OpenCVUtils.cmake index a6ea60365a..f42ad0b231 100644 --- a/cmake/OpenCVUtils.cmake +++ b/cmake/OpenCVUtils.cmake @@ -564,7 +564,11 @@ macro(ocv_check_flag_support lang flag varname base_options) elseif("_${lang}_" MATCHES "_C_") set(_lang C) elseif("_${lang}_" MATCHES "_OBJCXX_") - set(_lang OBJCXX) + if(DEFINED CMAKE_OBJCXX_COMPILER) # CMake 3.16+ and enable_language(OBJCXX) call are required + set(_lang OBJCXX) + else() + set(_lang CXX) + endif() else() set(_lang ${lang}) endif() diff --git a/doc/py_tutorials/py_setup/py_setup_in_ubuntu/py_setup_in_ubuntu.markdown b/doc/py_tutorials/py_setup/py_setup_in_ubuntu/py_setup_in_ubuntu.markdown index f88ffe6793..8b99c5df92 100644 --- a/doc/py_tutorials/py_setup/py_setup_in_ubuntu/py_setup_in_ubuntu.markdown +++ b/doc/py_tutorials/py_setup/py_setup_in_ubuntu/py_setup_in_ubuntu.markdown @@ -22,10 +22,10 @@ Installing OpenCV-Python from Pre-built Binaries This method serves best when using just for programming and developing OpenCV applications. -Install package [python-opencv](https://packages.ubuntu.com/trusty/python-opencv) with following command in terminal (as root user). +Install package [python3-opencv](https://packages.ubuntu.com/focal/python3-opencv) with following command in terminal (as root user). ``` -$ sudo apt-get install python-opencv +$ sudo apt-get install python3-opencv ``` Open Python IDLE (or IPython) and type following codes in Python terminal. diff --git a/doc/tutorials/imgproc/pyramids/pyramids.markdown b/doc/tutorials/imgproc/pyramids/pyramids.markdown index adbd086cf0..82ef81e369 100644 --- a/doc/tutorials/imgproc/pyramids/pyramids.markdown +++ b/doc/tutorials/imgproc/pyramids/pyramids.markdown @@ -170,7 +170,7 @@ Our program exits if the user presses **ESC**. Besides, it has two options: We use the function **pyrDown()** with three arguments (similarly to **pyrUp()**): - *src*: The current and destination image (to be shown on screen, supposedly half the input image) - - *Size( tmp.cols/2, tmp.rows/2 )* : The destination size. Since we are upsampling, + - *Size( tmp.cols/2, tmp.rows/2 )* : The destination size. Since we are downsampling, **pyrDown()** expects half the size the input image (in this case *src*). @add_toggle_cpp diff --git a/modules/calib3d/src/calibinit.cpp b/modules/calib3d/src/calibinit.cpp index f9e0224542..320b9ae85d 100644 --- a/modules/calib3d/src/calibinit.cpp +++ b/modules/calib3d/src/calibinit.cpp @@ -2266,7 +2266,7 @@ bool findCirclesGrid( InputArray _image, Size patternSize, } } - if (!H.empty()) // undone rectification + if (!centers.empty() && !H.empty()) // undone rectification { Mat orgPointsMat; transform(centers, orgPointsMat, H.inv()); diff --git a/modules/calib3d/test/test_chesscorners.cpp b/modules/calib3d/test/test_chesscorners.cpp index 822796fcfb..b4d0628c87 100644 --- a/modules/calib3d/test/test_chesscorners.cpp +++ b/modules/calib3d/test/test_chesscorners.cpp @@ -710,5 +710,45 @@ TEST(Calib3d_AsymmetricCirclesPatternDetector, regression_18713) } } +TEST(Calib3d_AsymmetricCirclesPatternDetector, regression_19498) +{ + float pts_[121][2] = { + { 84.7462f, 404.504f }, { 49.1586f, 404.092f }, { 12.3362f, 403.434f }, { 102.542f, 386.214f }, { 67.6042f, 385.475f }, + { 31.4982f, 384.569f }, { 141.231f, 377.856f }, { 332.834f, 370.745f }, { 85.7663f, 367.261f }, { 50.346f, 366.051f }, + { 13.7726f, 364.663f }, { 371.746f, 362.011f }, { 68.8543f, 347.883f }, { 32.9334f, 346.263f }, { 331.926f, 343.291f }, + { 351.535f, 338.112f }, { 51.7951f, 328.247f }, { 15.4613f, 326.095f }, { 311.719f, 319.578f }, { 330.947f, 313.708f }, + { 256.706f, 307.584f }, { 34.6834f, 308.167f }, { 291.085f, 295.429f }, { 17.4316f, 287.824f }, { 252.928f, 277.92f }, + { 270.19f, 270.93f }, { 288.473f, 263.484f }, { 216.401f, 260.94f }, { 232.195f, 253.656f }, { 266.757f, 237.708f }, + { 211.323f, 229.005f }, { 227.592f, 220.498f }, { 154.749f, 188.52f }, { 222.52f, 184.906f }, { 133.85f, 163.968f }, + { 200.024f, 158.05f }, { 147.485f, 153.643f }, { 161.967f, 142.633f }, { 177.396f, 131.059f }, { 125.909f, 128.116f }, + { 139.817f, 116.333f }, { 91.8639f, 114.454f }, { 104.343f, 102.542f }, { 117.635f, 89.9116f }, { 70.9465f, 89.4619f }, + { 82.8524f, 76.7862f }, { 131.738f, 76.4741f }, { 95.5012f, 63.3351f }, { 109.034f, 49.0424f }, { 314.886f, 374.711f }, + { 351.735f, 366.489f }, { 279.113f, 357.05f }, { 313.371f, 348.131f }, { 260.123f, 335.271f }, { 276.346f, 330.325f }, + { 293.588f, 325.133f }, { 240.86f, 313.143f }, { 273.436f, 301.667f }, { 206.762f, 296.574f }, { 309.877f, 288.796f }, + { 187.46f, 274.319f }, { 201.521f, 267.804f }, { 248.973f, 245.918f }, { 181.644f, 244.655f }, { 196.025f, 237.045f }, + { 148.41f, 229.131f }, { 161.604f, 221.215f }, { 175.455f, 212.873f }, { 244.748f, 211.459f }, { 128.661f, 206.109f }, + { 190.217f, 204.108f }, { 141.346f, 197.568f }, { 205.876f, 194.781f }, { 168.937f, 178.948f }, { 121.006f, 173.714f }, + { 183.998f, 168.806f }, { 88.9095f, 159.731f }, { 100.559f, 149.867f }, { 58.553f, 146.47f }, { 112.849f, 139.302f }, + { 80.0968f, 125.74f }, { 39.24f, 123.671f }, { 154.582f, 103.85f }, { 59.7699f, 101.49f }, { 266.334f, 385.387f }, + { 234.053f, 368.718f }, { 263.347f, 361.184f }, { 244.763f, 339.958f }, { 198.16f, 328.214f }, { 211.675f, 323.407f }, + { 225.905f, 318.426f }, { 192.98f, 302.119f }, { 221.267f, 290.693f }, { 161.437f, 286.46f }, { 236.656f, 284.476f }, + { 168.023f, 251.799f }, { 105.385f, 221.988f }, { 116.724f, 214.25f }, { 97.2959f, 191.81f }, { 108.89f, 183.05f }, + { 77.9896f, 169.242f }, { 48.6763f, 156.088f }, { 68.9635f, 136.415f }, { 29.8484f, 133.886f }, { 49.1966f, 112.826f }, + { 113.059f, 29.003f }, { 251.698f, 388.562f }, { 281.689f, 381.929f }, { 297.875f, 378.518f }, { 248.376f, 365.025f }, + { 295.791f, 352.763f }, { 216.176f, 348.586f }, { 230.143f, 344.443f }, { 179.89f, 307.457f }, { 174.083f, 280.51f }, + { 142.867f, 265.085f }, { 155.127f, 258.692f }, { 124.187f, 243.661f }, { 136.01f, 236.553f }, { 86.4651f, 200.13f }, + { 67.5711f, 178.221f } + }; + + Mat candidates(121, 1, CV_32FC2, (void*)pts_); + Size patternSize(13, 8); + + std::vector< Point2f > result; + bool res = false; + + EXPECT_NO_THROW(res = findCirclesGrid(candidates, patternSize, result, CALIB_CB_SYMMETRIC_GRID, Ptr()/*blobDetector=NULL*/)); + EXPECT_FALSE(res); +} + }} // namespace /* End of file. */ diff --git a/modules/core/include/opencv2/core.hpp b/modules/core/include/opencv2/core.hpp index 6ba209b397..48023844a9 100644 --- a/modules/core/include/opencv2/core.hpp +++ b/modules/core/include/opencv2/core.hpp @@ -50,7 +50,6 @@ #endif #include "opencv2/core/cvdef.h" -#include "opencv2/core/version.hpp" #include "opencv2/core/base.hpp" #include "opencv2/core/cvstd.hpp" #include "opencv2/core/traits.hpp" diff --git a/modules/core/include/opencv2/core/cvdef.h b/modules/core/include/opencv2/core/cvdef.h index d001ebc76c..cb12f19f90 100644 --- a/modules/core/include/opencv2/core/cvdef.h +++ b/modules/core/include/opencv2/core/cvdef.h @@ -45,6 +45,8 @@ #ifndef OPENCV_CORE_CVDEF_H #define OPENCV_CORE_CVDEF_H +#include "opencv2/core/version.hpp" + //! @addtogroup core_utils //! @{ diff --git a/modules/core/include/opencv2/core/simd_intrinsics.hpp b/modules/core/include/opencv2/core/simd_intrinsics.hpp index c50923f0ef..8fe7ee6b60 100644 --- a/modules/core/include/opencv2/core/simd_intrinsics.hpp +++ b/modules/core/include/opencv2/core/simd_intrinsics.hpp @@ -40,7 +40,6 @@ Notes: #endif #include "opencv2/core/cvdef.h" -#include "opencv2/core/version.hpp" #ifdef OPENCV_SIMD_CONFIG_HEADER #include CVAUX_STR(OPENCV_SIMD_CONFIG_HEADER) diff --git a/modules/core/src/hal_internal.cpp b/modules/core/src/hal_internal.cpp index 60f96c0164..483281d1f7 100644 --- a/modules/core/src/hal_internal.cpp +++ b/modules/core/src/hal_internal.cpp @@ -42,6 +42,7 @@ // //M*/ +#include "precomp.hpp" #include "hal_internal.hpp" #ifdef HAVE_LAPACK diff --git a/modules/core/src/hal_internal.hpp b/modules/core/src/hal_internal.hpp index 129a710145..c7a0d46de4 100644 --- a/modules/core/src/hal_internal.hpp +++ b/modules/core/src/hal_internal.hpp @@ -45,8 +45,6 @@ #ifndef OPENCV_CORE_HAL_INTERNAL_HPP #define OPENCV_CORE_HAL_INTERNAL_HPP -#include "precomp.hpp" - #ifdef HAVE_LAPACK int lapack_LU32f(float* a, size_t a_step, int m, float* b, size_t b_step, int n, int* info); diff --git a/modules/core/src/intel_gpu_gemm.inl.hpp b/modules/core/src/intel_gpu_gemm.inl.hpp index 729b43f604..fbd567b949 100644 --- a/modules/core/src/intel_gpu_gemm.inl.hpp +++ b/modules/core/src/intel_gpu_gemm.inl.hpp @@ -25,7 +25,6 @@ #ifdef HAVE_OPENCL #include -#include "precomp.hpp" #include "opencl_kernels_core.hpp" #include "opencv2/core/opencl/runtime/opencl_clamdblas.hpp" #include "opencv2/core/opencl/runtime/opencl_core.hpp" diff --git a/modules/core/src/matrix_c.cpp b/modules/core/src/matrix_c.cpp index 1c3e58857c..2fead4100c 100644 --- a/modules/core/src/matrix_c.cpp +++ b/modules/core/src/matrix_c.cpp @@ -1,6 +1,10 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html + +#include "precomp.hpp" #include "opencv2/core/mat.hpp" #include "opencv2/core/types_c.h" -#include "precomp.hpp" // glue diff --git a/modules/core/src/matrix_iterator.cpp b/modules/core/src/matrix_iterator.cpp index aaa7f4aa01..ce7c191cbe 100644 --- a/modules/core/src/matrix_iterator.cpp +++ b/modules/core/src/matrix_iterator.cpp @@ -2,9 +2,8 @@ // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html - -#include "opencv2/core/mat.hpp" #include "precomp.hpp" +#include "opencv2/core/mat.hpp" namespace cv { diff --git a/modules/core/src/matrix_operations.cpp b/modules/core/src/matrix_operations.cpp index ac94ecee7d..b7068f195a 100644 --- a/modules/core/src/matrix_operations.cpp +++ b/modules/core/src/matrix_operations.cpp @@ -2,11 +2,10 @@ // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html - +#include "precomp.hpp" #include "opencv2/core/mat.hpp" #include "opencv2/core/types_c.h" #include "opencl_kernels_core.hpp" -#include "precomp.hpp" #undef HAVE_IPP #undef CV_IPP_RUN_FAST diff --git a/modules/core/src/matrix_sparse.cpp b/modules/core/src/matrix_sparse.cpp index 05d16d706e..21e7e91151 100644 --- a/modules/core/src/matrix_sparse.cpp +++ b/modules/core/src/matrix_sparse.cpp @@ -2,10 +2,9 @@ // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html - +#include "precomp.hpp" #include "opencv2/core/mat.hpp" #include "opencv2/core/types_c.h" -#include "precomp.hpp" namespace cv { diff --git a/modules/core/src/matrix_wrap.cpp b/modules/core/src/matrix_wrap.cpp index 68a674f6f1..b8afe61d6b 100644 --- a/modules/core/src/matrix_wrap.cpp +++ b/modules/core/src/matrix_wrap.cpp @@ -2,9 +2,8 @@ // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html - -#include "opencv2/core/mat.hpp" #include "precomp.hpp" +#include "opencv2/core/mat.hpp" namespace cv { diff --git a/modules/dnn/src/darknet/darknet_io.cpp b/modules/dnn/src/darknet/darknet_io.cpp index f6d71fd6d4..e3c978a8c0 100644 --- a/modules/dnn/src/darknet/darknet_io.cpp +++ b/modules/dnn/src/darknet/darknet_io.cpp @@ -241,6 +241,10 @@ namespace cv { { activation_param.type = "Sigmoid"; } + else if (type == "tanh") + { + activation_param.type = "TanH"; + } else { CV_Error(cv::Error::StsParseError, "Unsupported activation: " + type); diff --git a/modules/dnn/src/layers/proposal_layer.cpp b/modules/dnn/src/layers/proposal_layer.cpp index 4658e7b41f..62c4c7295f 100644 --- a/modules/dnn/src/layers/proposal_layer.cpp +++ b/modules/dnn/src/layers/proposal_layer.cpp @@ -54,11 +54,11 @@ public: for (int i = 0; i < ratios.size(); ++i) { float ratio = ratios.get(i); + float width = std::floor(baseSize / sqrt(ratio) + 0.5f); + float height = std::floor(width * ratio + 0.5f); for (int j = 0; j < scales.size(); ++j) { float scale = scales.get(j); - float width = std::floor(baseSize / sqrt(ratio) + 0.5f); - float height = std::floor(width * ratio + 0.5f); widths.push_back(scale * width); heights.push_back(scale * height); } diff --git a/modules/dnn/test/test_darknet_importer.cpp b/modules/dnn/test/test_darknet_importer.cpp index ca880fd7c2..c6a5ab1c3e 100644 --- a/modules/dnn/test/test_darknet_importer.cpp +++ b/modules/dnn/test/test_darknet_importer.cpp @@ -735,6 +735,11 @@ TEST_P(Test_Darknet_layers, mish) testDarknetLayer("mish", true); } +TEST_P(Test_Darknet_layers, tanh) +{ + testDarknetLayer("tanh"); +} + TEST_P(Test_Darknet_layers, avgpool_softmax) { testDarknetLayer("avgpool_softmax"); diff --git a/modules/highgui/CMakeLists.txt b/modules/highgui/CMakeLists.txt index d7a3c220d1..7a546616a4 100644 --- a/modules/highgui/CMakeLists.txt +++ b/modules/highgui/CMakeLists.txt @@ -148,7 +148,7 @@ ocv_create_module(${HIGHGUI_LIBRARIES}) macro(ocv_highgui_configure_target) if(APPLE) - add_apple_compiler_options(the_module) + add_apple_compiler_options(${the_module}) endif() if(MSVC) diff --git a/modules/imgcodecs/CMakeLists.txt b/modules/imgcodecs/CMakeLists.txt index 7280778686..24f89e6e38 100644 --- a/modules/imgcodecs/CMakeLists.txt +++ b/modules/imgcodecs/CMakeLists.txt @@ -149,7 +149,7 @@ ocv_create_module(${GRFMT_LIBS} ${IMGCODECS_LIBRARIES}) macro(ocv_imgcodecs_configure_target) if(APPLE) - add_apple_compiler_options(the_module) + add_apple_compiler_options(${the_module}) endif() if(MSVC) @@ -167,4 +167,8 @@ ocv_add_accuracy_tests() if(TARGET opencv_test_imgcodecs AND HAVE_JASPER AND "$ENV{OPENCV_IO_ENABLE_JASPER}") ocv_target_compile_definitions(opencv_test_imgcodecs PRIVATE OPENCV_IMGCODECS_ENABLE_JASPER_TESTS=1) endif() +if(TARGET opencv_test_imgcodecs AND HAVE_PNG AND NOT (PNG_VERSION VERSION_LESS "1.6.31")) + # details: https://github.com/glennrp/libpng/commit/68cb0aaee3de6371b81a4613476d9b33e43e95b1 + ocv_target_compile_definitions(opencv_test_imgcodecs PRIVATE OPENCV_IMGCODECS_PNG_WITH_EXIF=1) +endif() ocv_add_perf_tests() diff --git a/modules/imgcodecs/test/test_png.cpp b/modules/imgcodecs/test/test_png.cpp index 74920ee9ae..f71fabc7e4 100644 --- a/modules/imgcodecs/test/test_png.cpp +++ b/modules/imgcodecs/test/test_png.cpp @@ -7,12 +7,6 @@ namespace opencv_test { namespace { #ifdef HAVE_PNG -#ifdef HAVE_LIBPNG_PNG_H -#include -#else -#include -#endif - TEST(Imgcodecs_Png, write_big) { const string root = cvtest::TS::ptr()->get_data_path(); @@ -99,7 +93,6 @@ TEST(Imgcodecs_Png, read_color_palette_with_alpha) EXPECT_EQ(img.at(0, 1), Vec3b(0, 0, 255)); } -#ifdef PNG_eXIf_SUPPORTED /** * Test for check whether reading exif orientation tag was processed successfully or not * The test info is the set of 8 images named testExifRotate_{1 to 8}.png @@ -144,7 +137,11 @@ TEST(Imgcodecs_Png, read_color_palette_with_alpha) typedef testing::TestWithParam Imgcodecs_PNG_Exif; // Solution to issue 16579: PNG read doesn't support Exif orientation data +#ifdef OPENCV_IMGCODECS_PNG_WITH_EXIF TEST_P(Imgcodecs_PNG_Exif, exif_orientation) +#else +TEST_P(Imgcodecs_PNG_Exif, DISABLED_exif_orientation) +#endif { const string root = cvtest::TS::ptr()->get_data_path(); const string filename = root + GetParam(); @@ -188,7 +185,6 @@ const string exif_files[] = INSTANTIATE_TEST_CASE_P(ExifFiles, Imgcodecs_PNG_Exif, testing::ValuesIn(exif_files)); -#endif // PNG_eXIf_SUPPORTED #endif // HAVE_PNG diff --git a/modules/video/src/lkpyramid.cpp b/modules/video/src/lkpyramid.cpp index 29307053f3..8467035dbf 100644 --- a/modules/video/src/lkpyramid.cpp +++ b/modules/video/src/lkpyramid.cpp @@ -865,6 +865,8 @@ namespace OutputArray status, OutputArray err = cv::noArray()) CV_OVERRIDE; + virtual String getDefaultName() const CV_OVERRIDE { return "SparseOpticalFlow.SparsePyrLKOpticalFlow"; } + private: #ifdef HAVE_OPENCL bool checkParam() @@ -934,7 +936,8 @@ namespace { if (!lkSparse_run(prevPyr[level], nextPyr[level], prevPts, nextPts, status, err, - prevPts.cols, level)) + static_cast(prevPts.total()), + level)) return false; } return true; diff --git a/modules/video/src/optflowgf.cpp b/modules/video/src/optflowgf.cpp index 83ad47fc0e..2b164b62d3 100644 --- a/modules/video/src/optflowgf.cpp +++ b/modules/video/src/optflowgf.cpp @@ -618,6 +618,8 @@ public: virtual void calc(InputArray I0, InputArray I1, InputOutputArray flow) CV_OVERRIDE; + virtual String getDefaultName() const CV_OVERRIDE { return "DenseOpticalFlow.FarnebackOpticalFlow"; } + private: int numLevels_; double pyrScale_; diff --git a/samples/cpp/tutorial_code/calib3d/camera_calibration/camera_calibration.cpp b/samples/cpp/tutorial_code/calib3d/camera_calibration/camera_calibration.cpp index 2d8b1ddac4..07ffbd5f19 100644 --- a/samples/cpp/tutorial_code/calib3d/camera_calibration/camera_calibration.cpp +++ b/samples/cpp/tutorial_code/calib3d/camera_calibration/camera_calibration.cpp @@ -444,7 +444,7 @@ int main(int argc, char* argv[]) // -----------------------Show the undistorted image for the image list ------------------------ //! [show_results] - if( s.inputType == Settings::IMAGE_LIST && s.showUndistorsed ) + if( s.inputType == Settings::IMAGE_LIST && s.showUndistorsed && !cameraMatrix.empty()) { Mat view, rview, map1, map2; diff --git a/samples/dnn/tf_text_graph_common.py b/samples/dnn/tf_text_graph_common.py index ea24898873..c82053b4fb 100644 --- a/samples/dnn/tf_text_graph_common.py +++ b/samples/dnn/tf_text_graph_common.py @@ -270,7 +270,11 @@ def removeIdentity(graph_def): identities = {} for node in graph_def.node: if node.op == 'Identity' or node.op == 'IdentityN': - identities[node.name] = node.input[0] + inp = node.input[0] + if inp in identities: + identities[node.name] = identities[inp] + else: + identities[node.name] = inp graph_def.node.remove(node) for node in graph_def.node: