Skip to content

ONNX diagnostic tool corrections#19693

Merged
alalek merged 5 commits intoopencv:masterfrom
LupusSanctus:onnx_diagnostic
Mar 29, 2021
Merged

ONNX diagnostic tool corrections#19693
alalek merged 5 commits intoopencv:masterfrom
LupusSanctus:onnx_diagnostic

Conversation

@LupusSanctus
Copy link
Copy Markdown

@LupusSanctus LupusSanctus commented Mar 8, 2021

Relates to: PR #19420

  • 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

@LupusSanctus LupusSanctus changed the title WIP: ONNX diagnostic tool corrections ONNX diagnostic tool corrections Mar 9, 2021

CV_Assert(!model.empty());

setDiagnosticsRun(true);
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's not good to alter DNN behaviour by setting a global variable. It would be better to have an overloaded variant of readNet() that will pass the corresponding flags to the importers w/o affecting global state.

Copy link
Copy Markdown
Member

@alalek alalek Mar 12, 2021

Choose a reason for hiding this comment

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

I prefer adding global variable instead of exploding of public API.
API parameters should cover regular usage and don't confuse users.

It is some kind of logging utilities. Even in functional world nobody brings logger instance parameter into each function.


This approach allows to keep this patch small.

//! Unregisters registered layer with specified type name. Thread-safe.
static void unregisterLayer(const String &type);

static const std::map<String, int>& getRegisteredLayers() { return registeredTypes; }
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.

std::map<String, int>

Why do we need std::map here?
Can we use simple std::vector<std::string> here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Removed this map, reused already existing LayerFactory_Impl map (moved it into private header), it has the same content.

static void unregisterLayer(const String &type);

//! Get the types of layers which were registered.
static const std::map<String, int>& getRegisteredLayers();
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.

std::map<String, int>

Why do we need std::map in public API? Use std::vector instead.

String

Use std::string in new API.


If you need to optimize access with O(log(N)) instead O(N), then build std::set / hash_map / etc internally. Do not expose that to public API.


std::set does not work with OpenCV bindings, so it should be avoided in public API.

Copy link
Copy Markdown
Author

@LupusSanctus LupusSanctus Mar 23, 2021

Choose a reason for hiding this comment

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

@alalek, corrected, reused already existing LayerFactory_Impl.


private:
LayerFactory();
static std::map<String, int>& _getRegisteredLayers();
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 that from public headers.
All "private" members should be eliminated from public header, see https://github.com/opencv/opencv/wiki/Coding_Style_Guide

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Corrected, added layer_reg.private.hpp.

@LupusSanctus LupusSanctus force-pushed the onnx_diagnostic branch 5 times, most recently from d81f111 to 4144e70 Compare March 26, 2021 17:11
@LupusSanctus
Copy link
Copy Markdown
Author

@alalek, corrected code, required tests passed.

@asmorkalov asmorkalov self-requested a review March 29, 2021 14:44
@alalek
Copy link
Copy Markdown
Member

alalek commented Mar 29, 2021

Please update changelog highlights too: https://github.com/opencv/opencv/wiki/ChangeLog#version452

@alalek alalek merged commit e08de11 into opencv:master Mar 29, 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
ONNX diagnostic tool

* Final

* Add forgotten Normalize layer to the set of supported types

* ONNX diagnostic tool corrections

* Fixed CI test warnings

* Added code minor corrections

Co-authored-by: Sergey Slashchinin <sergei.slashchinin@xperience.ai>
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