Skip to content

Add ExpandDims layer of tf_importer.cpp#20702

Merged
alalek merged 8 commits intoopencv:masterfrom
zihaomu:tf_expand_dim_layer
Oct 4, 2021
Merged

Add ExpandDims layer of tf_importer.cpp#20702
alalek merged 8 commits intoopencv:masterfrom
zihaomu:tf_expand_dim_layer

Conversation

@zihaomu
Copy link
Copy Markdown
Member

@zihaomu zihaomu commented Sep 14, 2021

The ExpandDims layer was implemented by "Reshape layer."
The following code will generate the ExpandDims layer:

expand_dim = tf.expand_dims(input, -1)
# or
expand_dim = tf.expand_dims(input, 2)

Related test data could be found at PR in opencv_extra.

There are still some unresolved issues here:

    1. Currently, this code can only handle when the dimension input layer dimension is 4., since the different Datalayout between OpenCV and Tensorflow.(Solved.)
    1. Since the implementation uses the dstNet.getLayerShapes() function. This implementation can not handle this model.

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • 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
opencv_extra=tf_expand_dim_layer

@zihaomu
Copy link
Copy Markdown
Member Author

zihaomu commented Sep 17, 2021

jenkins cn please retry a build

1 similar comment
@fengyuentau
Copy link
Copy Markdown
Member

jenkins cn please retry a build

Copy link
Copy Markdown
Member

@rogday rogday 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 for contribution! Can you clarify, under which conditions this implementation of ExpandDims will work? My understanding is that the network should specify shapes and they shouldn't be dynamic, is that correct? Also, could you rebase extra, so that it can be tested on CI?

@zihaomu zihaomu changed the base branch from master to next September 27, 2021 09:36
@zihaomu zihaomu changed the base branch from next to master September 27, 2021 09:37
Copy link
Copy Markdown
Member

@rogday rogday 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 with a few comments. 👍

Copy link
Copy Markdown
Member

@rogday rogday left a comment

Choose a reason for hiding this comment

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

Please, add a space between ifs and fors and opening parentheses. Otherwise looks good, thank you! 👍

@alalek alalek merged commit 9085b93 into opencv:master Oct 4, 2021
@rogday rogday mentioned this pull request Oct 12, 2021
4 tasks
@alalek alalek mentioned this pull request Oct 15, 2021
a-sajjad72 pushed a commit to a-sajjad72/opencv that referenced this pull request Mar 30, 2023
Add ExpandDims layer of tf_importer.cpp

* Add ExpandDims to tf_importer.

* add -1 expand test case.

* Support different dimensions of input.

* Compatible with 5-dimensional NDHWC data

* Code align

* support 3-dim input.

* 3-dim bug fixed.

* fixing error of code format.
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.

4 participants