CARVIEW |
Navigation Menu
-
-
Notifications
You must be signed in to change notification settings - Fork 56.2k
[G-API] Pipeline modeling tool - support local infer node config #22518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[G-API] Pipeline modeling tool - support local infer node config #22518
Conversation
@smirnov-alexey @dmatveev Hi folks! Could you have a look? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
@@ -371,7 +380,10 @@ int main(int argc, char* argv[]) { | |||
builder.addDummy(call_params, read<DummyParams>(node_fn)); | |||
} else if (node_type == "Infer") { | |||
auto infer_params = read<InferParams>(node_fn); | |||
infer_params.config = config; | |||
RETHROW_WITH_MSG_IF_FAILED( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally, macros are evil /=
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll remove this macro and leave just try-catch
there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
infer_params.config = config; | ||
RETHROW_WITH_MSG_IF_FAILED( | ||
utils::intersectMapWith(infer_params.config, gconfig), | ||
"Failed to combine global and local configs for Infer node: " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why it could fail? How user could deal with it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If user provides global and local configs that have intersection app fails with: Met dublicated key
which is not descriptive. It would be great to see something like: Failed to merge global & local configs for model <model.xml>
, but utils::intersectMapWith
knows nothing about modes & configs it just merges map
's
std::stringstream ss; \ | ||
ss << msg << "\n caused by: " << e.what(); \ | ||
throw std::logic_error(ss.str()); \ | ||
} \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason to do this? Maybe @sivanov-work have more to say here? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Answered above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed ugly macro
if (it != target.end()) { | ||
throw std::logic_error("Met already existing key: " + item.first); | ||
} | ||
target.insert(item); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In set theory, intersection is something different from this, isn't it?
Don't you just merge two maps into one with handling the "overwrites"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, good point!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
for (auto&& item : second) { | ||
auto it = target.find(item.first); | ||
if (it != target.end()) { | ||
throw std::logic_error("Met already existing key: " + item.first); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Error: key X already exists in Y" is better IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but X & Y are nameless.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
X is the value of your item.first
.
Y is the map you're merging into.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This Y
doesn't have a name. Done
* Rename intersectMapWith -> mergeMapWith * Remove macro * Add r-value ref
Is everybody OK to merge it? |
@@ -91,6 +93,17 @@ typename duration_t::rep timestamp() { | |||
return duration_cast<duration_t>(now.time_since_epoch()).count(); | |||
} | |||
|
|||
template <typename K, typename V> | |||
void mergeMapWith(std::map<K, V>& target, const std::map<K, V>& second) { | |||
for (auto&& item : second) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/build/precommit_linux64/4.x/opencv/modules/gapi/samples/pipeline_modeling_tool.cpp:196:5: error: invalid initialization of non-const reference of type 'cv::FileNode&' from an rvalue of type 'cv::FileNode
Reverted back
@alalek @asmorkalov Can it be merged? |
6a5f68c
to
4521d66
Compare
|
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.
Overview
The motivation of this PR is the following:
config
config
in.yml
config file once is more convenient if it isn't supposed to be changed according user scenario.The logic is following:
Infer
node locally via.yml
config file.local
config might be combined withglobal
(in case it's specified via--load_config
) until they have key conflicts.