Conversation
OrestChura
left a comment
There was a problem hiding this comment.
I have some comments, but overall seems solid
| || ade::util::any_of(out_tensor_info, is_dyn); | ||
| if (is_dynamic && !params.custom_post_proc) { | ||
| if (is_dynamic | ||
| && !params.custom_post_proc) { |
There was a problem hiding this comment.
so, why this change? Is it necessary?
There was a problem hiding this comment.
The idea of the author.
There was a problem hiding this comment.
Mb for the debug, to produce errors on different lines (?)
There was a problem hiding this comment.
you could leave formatting for this if as-is.
dmatveev
left a comment
There was a problem hiding this comment.
The main question is -- why altering the IE version?
| # For now, check the old name ORT_INSTALL_DIR | ||
| if(ORT_INSTALL_DIR AND NOT ONNXRT_ROOT_DIR) | ||
| set(ONNXRT_ROOT_DIR ORT_INSTALL_DIR) | ||
| set(ONNXRT_ROOT_DIR ${ORT_INSTALL_DIR}) |
There was a problem hiding this comment.
Isn't this merged already?
There was a problem hiding this comment.
I caught it in this branch. It is merged.
There was a problem hiding this comment.
But then there should be no such change
| || ade::util::any_of(out_tensor_info, is_dyn); | ||
| if (is_dynamic && !params.custom_post_proc) { | ||
| if (is_dynamic | ||
| && !params.custom_post_proc) { |
There was a problem hiding this comment.
you could leave formatting for this if as-is.
|
@mpashchenkov note you don't have IE builds in your MR script -- I'd add those to check if IE is still valid. You can combine it with a rebase to turn 16 commits into one. |
|
Please squash commits and rebase as 1 commit. |
| if (params.num_out == 1u && params.output_names.empty()) { | ||
| params.output_names = { out_tensor_info.front().name }; | ||
| } | ||
|
|
| }; | ||
|
|
||
| namespace { | ||
| std::string pdims(const std::vector<int64_t> &dims) { |
There was a problem hiding this comment.
namespace {
Again, use "static" instead.
Subscribe and check all ongoing notifications/discussions about G-API PRs / Issues.
It is really annoying to repeat the same things.
P.S. "Why" answer you may find in corresponding discussion.
There was a problem hiding this comment.
Wait, that's the backend's code, and we use anonymous namespaces as a more "modern" replacement to static there a lot.
I remember there were problems in tests but what's wrong with the module code?
There was a problem hiding this comment.
It is not related to anonymous types in templates.
It is mostly to have better names in debugger.
Anonymous namespace is still necessary for internal types (but avoid using them in tests due to templates issues)
| if (!initialized) | ||
| { | ||
| // Since G-API has no own test data (yet), it is taken from the common space | ||
| const char* testDataPath = getenv("OPENCV_TEST_DATA_PATH"); |
There was a problem hiding this comment.
OPENCV_TEST_DATA_PATH
Again, it points to opencv_extra/testdata only.
It can't be used for extra locations with:
- DNN's large models (
OPENCV_DNN_TEST_DATA_PATH) - ONNX models from LFS ( ??? , on CI
OPENCV_DNN_TEST_DATA_PATHis reused as fallback)
They are dedicated locations, so they should have own variables with fallbacks.
This function has zero effect (OPENCV_TEST_DATA_PATH is added by ts module).
I believe it is time to grab all these initTestDataPath() calls and put them into test_main.cpp. See example here.
/cc @dmatveev
There was a problem hiding this comment.
Good point, thanks! I believe this code is a copy-paste from some other module where we were stealing DL models from DNN or so.
If the existing tests' lookups for test data (not models) continue working without this, it makes sense to remove this block.
Also, a good point on unifying overall initTestDataPath once and for everybody. @mpashchenkov can you please open a ticket on that? With the mentioned example in. Thanks!
There was a problem hiding this comment.
Ticket created.
There was a problem hiding this comment.
@alalek
Why does the function have zero effect?
What is the correct way to call findDataFile function?
It doesn't work without initTestDataPath.
It is same in ts module, but how to use it correctly?
My way:
- export OPENCV_TEST_DATA_PATH = /path_to/opencv_extra/testdata/
- call
initTestDataPath(useless step, as I understand it) - call
findDataFile
There was a problem hiding this comment.
@alalek, can you give advice about this?
There was a problem hiding this comment.
There is no "gapi" test data in opencv_extra, so no need to pass its prefix:
-CV_TEST_MAIN("gapi")
+CV_TEST_MAIN("")|
|
||
| TEST_F(ONNXYoloV3MultInput, InferConstInput) | ||
| { | ||
| useModel("/object_detection_segmentation/yolov3/model/yolov3-10"); |
| } | ||
| }; | ||
|
|
||
| class ONNXYoloV3MultInput : public ONNXWithRemap { |
There was a problem hiding this comment.
ONNXYoloV3MultInput
ONNXYoloV3MultiInput ?
| useModel("/object_detection_segmentation/yolov3/model/yolov3-10"); | ||
| // Tensor with incorrect image size | ||
| // is used for check case when InputLayers and constInput have same names | ||
| cv::Mat bad_shape; |
There was a problem hiding this comment.
Is it a bad arg test? Which check should fail?
There was a problem hiding this comment.
This test checks use of data from const input when input names are incorrectly set. If input names contain names from const input, then calculation will be performed according to data given by .ConstInput() function.
| const auto out_size = std::min(out_onnx.at(i).total(), out_gapi.at(i).total()); | ||
| for (size_t d_idx = 0; d_idx < out_size; ++d_idx) { |
There was a problem hiding this comment.
These checks are not reliable.
If out_gapi.at(i).total() is zero then no checks are performed at all.
There was a problem hiding this comment.
Added assert for zero size check.
| } | ||
|
|
||
| // FIXME: taken from the DNN module | ||
| void normAssert(const cv::InputArray& ref, const cv::InputArray& test, |
There was a problem hiding this comment.
const cv::InputArray&
InputArray is already a const reference.
| if (optr[size] <= 0) { | ||
| std::cout << optr[size] << std::endl; | ||
| } |
There was a problem hiding this comment.
Message is unclear, so it can't help with investigation of test failures.
| virtual void SetUp() { | ||
| const int yolo_in_h = 416; | ||
| const int yolo_in_w = 416; | ||
| cv::Mat yolov3_input, shape, prep_mat;; |
Please do not create NEW milestones! |
Sorry, that was a typo. It was supposed to be 4.5.1 |
| in_names_without_const.clear(); | ||
| std::copy_if(params.input_names.begin(), params.input_names.end(), | ||
| std::back_inserter(in_names_without_const), | ||
| [&](std::string& name) { |
There was a problem hiding this comment.
I believe it can be const std::string&
| in_tensor_info[idx], | ||
| c_in_pair.second.first)); | ||
| // Puts const input names in sequence for Run | ||
| // Ort can match input tensors to CNN inputs by names |
There was a problem hiding this comment.
Renamed to ONNXRuntime.
| const T* const inptr = in.ptr<T>(); | ||
| T* const optr = out.ptr<T>(); | ||
| const size_t size = std::min(out.total(), in.total()); | ||
| for (size_t i = 0; i < size; ++i) { |
| } | ||
| } | ||
|
|
||
| void remapSsdPorts(const std::unordered_map<std::string, cv::Mat> &onnx, |
662297c to
6a6e301
Compare
6a6e301 to
183eef0
Compare
|
@alalek anything else remaining here w.r.t tests? |
G-API: ONNX. Const input * Added const input for ONNX backend * Returned initMatrixRandu, added some comments, rebase
Added support of const input for onnx backend.
How it works:
ORT API infer is
Runmethod:We should call
Run()with order of input layers' names. We can put names in different order. If we want to use const input than we call constInput(name, cv::Mat):After that name will be added in order of input names and input tensor for Mat's data is created:
And we call Run with new input names and appropriate tensors, where names:
{in_layer_name1, const_input_name_for_layer2}and tensors:{tensor_for_layer1, tensor_for_layer2_with_data_from_C_I).Tests:
Test contains infer for YoloV3. YoloV3's input is resized image (416x416) and tensor with real size.
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.
Custom build: