Skip to content

[G-API] Wrap cv::gapi::infer<Generic> into python#18491

Merged
alalek merged 23 commits intoopencv:masterfrom
TolyaTalamanov:at/wrap-inference
Oct 26, 2020
Merged

[G-API] Wrap cv::gapi::infer<Generic> into python#18491
alalek merged 23 commits intoopencv:masterfrom
TolyaTalamanov:at/wrap-inference

Conversation

@TolyaTalamanov
Copy link
Copy Markdown
Contributor

@TolyaTalamanov TolyaTalamanov commented Oct 2, 2020

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

API example

img = cv.imread('img.png')
g_in = cv.GMat()
inputs = cv.GInferInputs()
inputs.setInput('data', g_in)

outputs = cv.gapi.infer('age-gender', inputs)

age_g = outputs.at('age_conv3')
gender_g = outputs.at('prob')

comp = cv.GComputation(cv.GIn(g_in), cv.GOut(age_g, gender_g))
pp = cv.gapi.ie.params('age-gender', '*.bin', '*.xml', 'CPU')

age, gender = comp.apply(cv.gin(img), args=cv.compile_args(cv.gapi.network(pp)))                                                                                                                                                                                                                                                                                                                                                                                                                                              

Buildbot configuration

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

force_builders=ARMv7,Custom
Xbuild_image:Custom=centos:7
Xbuildworker:Custom=linux-1
Xbuild_gapi_standalone:Custom=ade-0.1.1f

Xbuild_image:Custom=ubuntu-openvino-2020.4.0:16.04
build_image:Custom=ubuntu-openvino-2021.1.0:20.04
test_modules:Custom=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=*

Xbuild_image:Custom Mac=openvino-2020.4.0
build_image:Custom Mac=openvino-2021.1.0

build_image:Linux AVX2=ubuntu:20.04

@alalek
Copy link
Copy Markdown
Member

alalek commented Oct 14, 2020

Please rebase and fix warning from MSVS2019

@TolyaTalamanov
Copy link
Copy Markdown
Contributor Author

@dmatveev @alalek

@TolyaTalamanov
Copy link
Copy Markdown
Contributor Author

@alalek Windows build are green

@TolyaTalamanov
Copy link
Copy Markdown
Contributor Author

@alalek

ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4503)
# FIXME: Unreachable code in Params::backend() (ie.hpp)
# https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-4-c4702?view=vs-2019
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4702)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ie.hpp

Disabling warnings here would not help users when they start building own applications with G-API public headers.
These settings are private for gapi module only.

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.

It seems I was able to fix that warning in another header... maybe solution like that would work here too.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@TolyaTalamanov Mentioned commit with workaround: 8637b7a

@TolyaTalamanov
Copy link
Copy Markdown
Contributor Author

@alalek

@@ -133,31 +133,35 @@ struct InOutInfo
* @{
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@{

Why do we have this here?

/cc @dmatveev

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.

Likely a copy-paste issue, cc: @TolyaTalamanov

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 👍

@alalek alalek merged commit 93c3775 into opencv:master Oct 26, 2020
@alalek alalek mentioned this pull request Nov 27, 2020
a-sajjad72 pushed a commit to a-sajjad72/opencv that referenced this pull request Mar 30, 2023
[G-API] Wrap cv::gapi::infer<Generic> into python

* Introduce generic infer

* Move Generic to infer.hpp

* Removew num_outs

* Fix windows warnings

* Fix comments to review

* Fix doxygen

* Add comment

* Fix comments to review

* Wrap inference to python

* Add default ctor to Params

* Add test

* Fix clang build

* Implement GInferInputs/GInferOutputs as Pimpl

* Add checkIEtarget to infer test

* Fix path

* Supress warning

* Use getAvailableDevices insted of checkIETarget

* Move PyParams to bindings_ie

* Add namespace

* Update CMakeLists.txt
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