Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

dmatveev
Copy link
Contributor

@dmatveev dmatveev commented Apr 23, 2023

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 another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the 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

- Existing tests pass with the ONNX models mentioned in tests.
Ort::AllocatedStringPtr name_p = pos == INPUT
? this_session.GetInputNameAllocated(i, allocator)
: this_session.GetOutputNameAllocated(i, allocator);
tensor_info.back().name = std::string(name_p.get());
Copy link
Contributor

Choose a reason for hiding this comment

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

@dmatveev, please, check that copy is created properly, because AllocatedStringPtr name_p will die in this scope.

Try run demos or onnx tests. I did not see onnx check (mb I am blind).

Copy link
Contributor

Choose a reason for hiding this comment

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

Existing tests pass with the ONNX models mentioned in tests.
Ok. Then all works.

Copy link

@asutic asutic Apr 25, 2023

Choose a reason for hiding this comment

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

@dmatveev Did the G-API ONNX classification test pass on your end (requires model downloading, see https://github.com/opencv/opencv/blob/4.x/modules/gapi/misc/python/test/test_gapi_infer_onnx.py#L21)? The model I have keeps returning garbage and inference results don't differ at all while I process my video sample. The behavior is the same on the CPU and GPU.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mpashchenkov thanks for review, std::string copies its char* argument (not moves) so its ok for name_p to be destroyed right after.

@asutic I will have a look on that, thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

G-API ONNX doesn't support GPU. Or did I miss something?

Copy link
Contributor

Choose a reason for hiding this comment

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

@dmatveev,
A crutch for the longevity of names:
Keep ptrs in class state ->

std::vector<const char*> inputNodeNames;
std::vector<Ort::AllocatedStringPtr> inputNodePtrs;

just in case *

@mpashchenkov
Copy link
Contributor

@dmatveev, https://github.com/opencv/opencv_extra/blob/4.x/testdata/gapi/onnx/download_onnx_models.py

Script can be updated for current modes or (if works) link can be posted on the WIKI.

Copy link

@asutic asutic left a comment

Choose a reason for hiding this comment

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

A small classification test shows mismatch in results between ONNX RT and G-API.

Copy link

@asutic asutic left a comment

Choose a reason for hiding this comment

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

Works properly after setting the input image shape to match the input shape of the model.

Copy link
Contributor

@TolyaTalamanov TolyaTalamanov left a comment

Choose a reason for hiding this comment

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

LGTM :+1

@asmorkalov asmorkalov merged commit 9161e40 into opencv:4.x Apr 28, 2023
@dmatveev
Copy link
Contributor Author

@dmatveev, https://github.com/opencv/opencv_extra/blob/4.x/testdata/gapi/onnx/download_onnx_models.py

Script can be updated for current modes or (if works) link can be posted on the WIKI.

Thanks @mpashchenkov I missed this! I crafted wiki with manual commands to download models instead :) https://github.com/opencv/opencv/wiki/Using-G-API-with-MS-ONNX-Runtime

@asmorkalov asmorkalov mentioned this pull request May 31, 2023
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