Skip to content

[G-API] Support generic infer overloads#19310

Merged
alalek merged 10 commits intoopencv:masterfrom
TolyaTalamanov:at/generic-infer-overloads
Mar 19, 2021
Merged

[G-API] Support generic infer overloads#19310
alalek merged 10 commits intoopencv:masterfrom
TolyaTalamanov:at/generic-infer-overloads

Conversation

@TolyaTalamanov
Copy link
Copy Markdown
Contributor

@TolyaTalamanov TolyaTalamanov commented Jan 12, 2021

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

Build configuration

Xforce_builders_only=linux,docs
force_builders=Custom,Custom Win,Custom Mac
build_gapi_standalone:Linux x64=ade-0.1.1f
build_gapi_standalone:Win64=ade-0.1.1f
build_gapi_standalone:Mac=ade-0.1.1f
build_gapi_standalone:Linux x64 Debug=ade-0.1.1f

Xbuild_image:Custom=centos:7
Xbuildworker:Custom=linux-1
build_gapi_standalone:Custom=ade-0.1.1f

build_image:Custom=ubuntu-openvino-2021.1.0:20.04
build_image:Custom Win=openvino-2021.1.0
build_image:Custom Mac=openvino-2021.2.0

test_modules:Custom=gapi,python2,python3,java
test_modules:Custom Win=gapi,python2,python3,java
test_modules:Custom Mac=gapi,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=*

@TolyaTalamanov TolyaTalamanov force-pushed the at/generic-infer-overloads branch from e4f78c9 to c431b14 Compare January 12, 2021 07:32
* @brief G-API object used to collect network outputs
*/
struct GAPI_EXPORTS_W_SIMPLE GInferOutputs
using GInferOutputs = GInferOutputsTyped<cv::GMat>;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

How to document these properly ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@dkurt Could you have a look, please ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@TolyaTalamanov TolyaTalamanov force-pushed the at/generic-infer-overloads branch from 7e57e54 to 3bc1793 Compare January 13, 2021 09:38
@TolyaTalamanov
Copy link
Copy Markdown
Contributor Author

@dmatveev Could you take a look ?

@TolyaTalamanov TolyaTalamanov force-pushed the at/generic-infer-overloads branch from bd2af91 to 9d160db Compare January 18, 2021 13:30
Copy link
Copy Markdown
Contributor

@smirnov-alexey smirnov-alexey 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, didn't dive too deep though

@TolyaTalamanov TolyaTalamanov force-pushed the at/generic-infer-overloads branch from 3044e8a to caf0284 Compare March 2, 2021 11:42
@TolyaTalamanov TolyaTalamanov force-pushed the at/generic-infer-overloads branch from caf0284 to d51d653 Compare March 2, 2021 14:14
@TolyaTalamanov TolyaTalamanov requested a review from rgarnov March 2, 2021 14:16
@TolyaTalamanov
Copy link
Copy Markdown
Contributor Author

@rgarnov Have a look, please

@TolyaTalamanov
Copy link
Copy Markdown
Contributor Author

@AsyaPronina Have a look, please

@TolyaTalamanov
Copy link
Copy Markdown
Contributor Author

@rgarnov @AsyaPronina Have a look, please

Copy link
Copy Markdown
Contributor

@rgarnov rgarnov 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

@TolyaTalamanov
Copy link
Copy Markdown
Contributor Author

@dmatveev Could you have a look ?

Copy link
Copy Markdown
Contributor

@dmatveev dmatveev 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

{
}

OutT at(const std::string& name)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is this method const? should it look like const?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, because it perform insert in map ?

std::vector<std::string> out_names;
};

template <typename OutT>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

BTW what's the reason to have it generic?

Inference only produces Blobs which are GMat.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh, looking at the code below, it seems I've got it.

Please make sure this type is under detail:: so end-users wouldn't think of using it directly.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ok I see it is under detail:: already

}
private:
template<typename T>
struct Priv
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just wondering, do you really need a distinct T here in the nested type or it could refer to OutT directly (I believe it could)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point, done

Comment on lines +1190 to +1191
cv::GInferInputs inputs;
inputs["data"] = in;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

BTW can it be constructed like this?

auto inputs = cv::GInferInputs {
   {"data", in},
   ...
};

? This can be done separately, of course.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I believe there is no difficulty to do this

@dmatveev dmatveev self-assigned this Mar 18, 2021
@TolyaTalamanov
Copy link
Copy Markdown
Contributor Author

@alalek Can it be merged ?

@TolyaTalamanov TolyaTalamanov force-pushed the at/generic-infer-overloads branch from f70bfd8 to a5bcd84 Compare March 19, 2021 10:15
@alalek alalek merged commit 50a264d into opencv:master Mar 19, 2021
@alalek alalek mentioned this pull request Apr 9, 2021
a-sajjad72 pushed a commit to a-sajjad72/opencv that referenced this pull request Mar 30, 2023
…overloads

[G-API] Support generic infer overloads

* Overloads for generic infer

* Fix build

* Refactoring

* Fix docs

* Put extra stuff to detail namespace

* Add doc for usings

* Remove uneccessary template in Priv
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.

5 participants