Skip to content

[G-API] Python ROI generic inference#19318

Merged
alalek merged 2 commits intoopencv:masterfrom
TolyaTalamanov:at/python-generic-infer
Mar 25, 2021
Merged

[G-API] Python ROI generic inference#19318
alalek merged 2 commits intoopencv:masterfrom
TolyaTalamanov:at/python-generic-infer

Conversation

@TolyaTalamanov
Copy link
Copy Markdown
Contributor

@TolyaTalamanov TolyaTalamanov commented Jan 13, 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
Copy link
Copy Markdown
Contributor Author

@dmatveev @smirnov-alexey Could you take a look ?

@smirnov-alexey
Copy link
Copy Markdown
Contributor

@TolyaTalamanov seems like it comes atop of a bunch of other PRs. Can't you separate the changes here?

@TolyaTalamanov TolyaTalamanov force-pushed the at/python-generic-infer branch from bed239e to a5031b9 Compare March 12, 2021 09:17
@TolyaTalamanov TolyaTalamanov force-pushed the at/python-generic-infer branch 3 times, most recently from 86e057f to 48bb099 Compare March 19, 2021 13:37
@TolyaTalamanov TolyaTalamanov force-pushed the at/python-generic-infer branch from 48bb099 to 244eea6 Compare March 19, 2021 13:40
@TolyaTalamanov
Copy link
Copy Markdown
Contributor Author

@smirnov-alexey Could you have a look, please ?

@TolyaTalamanov
Copy link
Copy Markdown
Contributor Author

@AsyaPronina @smirnov-alexey Could you have a look, please ?



def make_roi(self, img, roi):
return img[roi[1]:roi[1] + roi[3], roi[0]:roi[0] + roi[2], ...]
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.

How does this work?

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.

roi - is a tuple (x,y,h,w)

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.

(x,y,h,w)

Probably it is (x,y,w,h)

Clear code (to avoid unclear error messages):

x, y, w, h = roi
return img[y:y+h, x:x+w, ...]

if not cv.dnn.DNN_TARGET_CPU in cv.dnn.getAvailableTargets(cv.dnn.DNN_BACKEND_INFERENCE_ENGINE):
return

root_path = '/omz_intel_models/intel/age-gender-recognition-retail-0013/FP32/age-gender-recognition-retail-0013'
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.

Don't we have some policy regarding our tests, that if we don't find models/data, we don't run the tests? Won't those tests start failing later with new paths?

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 we don't care about it in these tests.

reinterpret_cast<pyopencv_gapi_wip_IStreamSource_t*>(item)->v;
return source;
}
else
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.

I would keep the else here, but it's up to you

@TolyaTalamanov
Copy link
Copy Markdown
Contributor Author

TolyaTalamanov commented Mar 22, 2021

@TolyaTalamanov seems like it comes atop of a bunch of other PRs. Can't you separate the changes here?

This bunch of PRs already in master, there is only actual separate changes

public:
GAPI_WRAP GInferListInputs();
GAPI_WRAP void setInput(const std::string& name, const cv::GArray<cv::GMat>& value);
GAPI_WRAP void setInput(const std::string& name, const cv::GArray<cv::Rect>& value);
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.

where's the implementation?

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.

I only see .hpp files in this MR

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.

There is no implementation, this file isn't compiled at all.

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.

It's just a trigger for bindings generator

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.

But why do we need it then? How it works? Can you please comment it in the code so then strangers like me wouldn't ask those questions again and again?

@dmatveev dmatveev self-assigned this Mar 25, 2021
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.

Please put the comment to the python wrapper thing somewhere later.

@TolyaTalamanov
Copy link
Copy Markdown
Contributor Author

@alalek Can it be merged ?

if not cv.dnn.DNN_TARGET_CPU in cv.dnn.getAvailableTargets(cv.dnn.DNN_BACKEND_INFERENCE_ENGINE):
return

root_path = '/omz_intel_models/intel/age-gender-recognition-retail-0013/FP32/age-gender-recognition-retail-0013'
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.

Remove leading slash /



def make_roi(self, img, roi):
return img[roi[1]:roi[1] + roi[3], roi[0]:roi[0] + roi[2], ...]
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.

(x,y,h,w)

Probably it is (x,y,w,h)

Clear code (to avoid unclear error messages):

x, y, w, h = roi
return img[y:y+h, x:x+w, ...]

('fluid' , cv.gapi.core.fluid.kernels())
# ('plaidml', cv.gapi.core.plaidml.kernels())
]
]
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.

Perhaps whole block should be reformatted

@alalek alalek merged commit 0753408 into opencv:master Mar 25, 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
…-infer

[G-API] Python ROI generic inference

* Python generic infer overloads

* Move wrappers to appropriate file
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