Skip to content

Aligned TF Reshape layer behaviour#19641

Merged
opencv-pushbot merged 1 commit intoopencv:3.4from
LupusSanctus:am/tf_reshape
Mar 6, 2021
Merged

Aligned TF Reshape layer behaviour#19641
opencv-pushbot merged 1 commit intoopencv:3.4from
LupusSanctus:am/tf_reshape

Conversation

@LupusSanctus
Copy link
Copy Markdown

@LupusSanctus LupusSanctus commented Feb 28, 2021

Merge with extra: opencv/opencv_extra#857

Fixes #19489: tf.keras.layers.Reshape layer interpreted incorrectly by readNetFromTensorflow() in dnn.

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake
force_builders=Custom,Custom Win,Custom Mac
build_image:Custom=ubuntu-openvino-2021.1.0:20.04
build_image:Custom Win=openvino-2021.1.0
build_image:Custom Mac=openvino-2021.1.0

test_modules:Custom=dnn,python2,python3,java
test_modules:Custom Win=dnn,python2,python3,java
test_modules:Custom Mac=dnn,python2,python3,java

buildworker:Custom=linux-1
# disabled due high memory usage: test_opencl:Custom=ON
test_opencl:Custom=OFF
test_bigdata:Custom=1
test_filter:Custom=*

Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Please rebase patch on 3.4 branch (+extra).

@LupusSanctus LupusSanctus changed the base branch from master to 3.4 March 4, 2021 22:08
Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Thank you 👍

@opencv-pushbot opencv-pushbot merged commit dc24663 into opencv:3.4 Mar 6, 2021
@alalek alalek mentioned this pull request Mar 6, 2021
@alalek alalek mentioned this pull request Apr 9, 2021
@rogday
Copy link
Copy Markdown
Member

rogday commented Aug 4, 2021

Hi, @LupusSanctus! I am investigating #20433 and wondering if you could clarify a few things.
Can you elaborate on why this condition is using hasAllOnes()?

if (newShapeSize == 4 && hasAllOnes(newShape, 0, 2))

Also there is a converter node that gets added if another condition is met, but the name of this node is different from the original, so other layers won't connect to it. It seems to be used only if reshape is the last layer of the network, is this behavior expected?

if (...)
{
    int order[] = {0, 3, 1, 2};  // Transform back to OpenCV's NCHW.
    addPermuteLayer(order, name + "/nchw", inpId);
    inpLayout = DATA_LAYOUT_NCHW;
}

Thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reshape layer of keras (tensorflow) is interpreted incorrectly by readNetFromTensorflow() in dnn

4 participants