CARVIEW |
Navigation Menu
-
-
Notifications
You must be signed in to change notification settings - Fork 56.2k
G-API-NG/API: Introduced inference API and IE-based backend #15090
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
Conversation
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.
19 new FIXMEs introduced, needs to be reduced
@alalek thanks for the magic script :) |
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.
Added few-more self-comments
69a70f4
to
ba6c699
Compare
@dkurt @AsyaPronina @rgarnov @andrey-golubev can you please 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.
Overall looks good, I'd suggest to make minor changes in some places
@@ -61,13 +61,15 @@ namespace detail | |||
|
|||
} // namespace detail | |||
|
|||
// Note: descr_of(std::vector<..>) returns a GArrayDesc, while | |||
// descrs_of(std::vector<..>) returns an array of Meta args! |
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.
Sounds confusing. May be descr_of
and metas_of
/meta_args_of
are better?
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.
Please check if IE is not using it and I will delete it at all.
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.
It is used in IE
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.
OK, will rename to metas_of
if any new change to this PR will be requested.
960697a
to
08949dd
Compare
@andrey-golubev addressed the majority if your comments, thanks a lot for such a torough review! @alalek builds seem to be green (except ABI change which was intentional - to fix a problem), I believe this can be merged when time permits and things become safe to merge (post-4.1.1) |
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 to me
@alalek do we wait for anything else to merge? |
|
||
const std::string path = "Retail/object_attributes/age_gender/dldt/age-gender-recognition-retail-0013"; | ||
const auto topology_path = findDataFile(path + ".xml"); | ||
const auto weights_path = findDataFile(path + ".bin"); |
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.
Please use false
with second parameter for findDataFile()
(for files which are not from opencv_extra
)
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, thanks!
- Very quick-n-dirty implementation - OpenCV's own DNN module is not used - No tests so far
- Added tests on multi-dimensional own::Mat - Added tests on GMatDesc with dimensions - Documentation on infer.hpp - Fixed more warnings + added a ROI list test - Fix descr_of clash for vector<Mat> & standalone mode - Fix build issue with gcc-4.8x - Addressed review comments
- Pass `false` to findDataFile() - Add deprecation warning suppression macros for IE
014d18b
to
d405ad1
Compare
@alalek anything else? |
๐พ ๐พ ๐พ ๐พ ๐พ ๐พ ๐พ ๐พ ๐พ ๐พ ๐พ ๐พ ๐พ ๐พ ๐พ ๐พ ๐พ ๐พ ๐พ THanks! |
โฆnce-api * G-API-NG/API: Introduced inference API and IE-based backend - Very quick-n-dirty implementation - OpenCV's own DNN module is not used - No tests so far * G-API-NG/IE: Refined IE backend, added more tests * G-API-NG/IE: Fixed various CI warnings & build issues + tests - Added tests on multi-dimensional own::Mat - Added tests on GMatDesc with dimensions - Documentation on infer.hpp - Fixed more warnings + added a ROI list test - Fix descr_of clash for vector<Mat> & standalone mode - Fix build issue with gcc-4.8x - Addressed review comments * G-API-NG/IE: Addressed review comments - Pass `false` to findDataFile() - Add deprecation warning suppression macros for IE
Inference in G-API
This PR introduces basic inference support to G-API.
Changes overview
Core G-API
own::Mat
has been extended with N-dimensions support. Continuesmimicing to
cv::Mat
in this behavior. Added tests.GMatDesc
now also supports dimensions in addition to a regular 2Dsize. A new constructor has been added to.
cv::descr_of()
overload for vector of Mats has been renamed tocv::descrs_of()
(and I am still wondering if we actually need thisfunction). A vector of Mats now is a valid host form for
GArray<GMat>
.kernels have empty tags (and are identified solely by kernel ID).
callbacks (see below).
On backend-specific
outMeta
In our regular interface, an
outMeta
(defining formats operations'sof outputs given the inputs) is defined with the operation itself --
so it describes API contract and not a particular implementation.
Sometimes an operation can't fully describe its meta when it is
defined, and so backends can put their own methods to the graph once
there's a clarity.
Example: when we define a network as API entry, we're not certain
about its input/output formats (data type, dimensions, etc) until we
actually load the network. This loading happens on graph compilation
stage, not on the graph construction stage, and is defined by the
underlying engines which do the actual work.
New entities
Inference API
Inference API is represented by just two files:
include/opencv2/gapi/infer.hpp
src/api/ginfer.cpp
Header file is the most importand one, it defines two generic
operations:
Infer
andInferList
, and an API to express networks weuse (
G_API_NET()
macro).Once a user declares his network, it can be used to construct graphs.
Network's name (a macro parameter) is used as an operation tag (see
above) to distinguish between different infer calls in graph (note -
the operation itself is always the same).
Similar to kernels, scoring engines are specified in the form of
backend-specific network parameters which are then passed to G-API
as compilation arguments (as a Network package).
Since every inference backend's parameters may differ, but network
parameters are also tightly coupled with networks itselves,
backend-specific parameters are usually derivatives from the network
APIs. Networks (as types) are specified as template arguments to
universal backend-specific parameter structures so knowledge about
network and its backend combines in a single object.
A code is worth a thousand words so please review a test in this PR.
Inference backend (DLDT)
The above API is (as usual) just an interface which can be implemented
(multiple times). This PR introduces a basic DLDT/IE-based
implementation of the inference interface.
This backend implements the two universal inference kernels (
Infer
and
InferList
) and provies a configuration API (seegapi/infer/ie.hpp
). It already supports automatic preprocessing withCrop/Scale/CSC pipeline out-of-the-box. And yes, in this case G-API is
working from within a G-API. :)
Tests
So far tested with a DLDT Age/Gender model only. Model is taken from
DNN module's own test suite.