Skip to content

Added a helper function that will list all available Intel devices#16184

Closed
JulienMaille wants to merge 2 commits intoopencv:masterfrom
JulienMaille:master
Closed

Added a helper function that will list all available Intel devices#16184
JulienMaille wants to merge 2 commits intoopencv:masterfrom
JulienMaille:master

Conversation

@JulienMaille
Copy link
Copy Markdown
Contributor

compatible with OpenVino inference engine (cpu, gpus, movidius, etc.)

This pullrequest changes

new cv::dnn::listInferenceEngineDevices() which is a wrapper on InferenceEngine::Core::GetAvailableDevices()

…mpatible with OpenVino inference engine (cpu, gpus, movidius, etc.)
@dkurt
Copy link
Copy Markdown
Member

dkurt commented Dec 17, 2019

Thanks!

Can this method test the devices? I mean which lists it will show in the following scenarios:

  • When there is a device but there is no plugin available (i.e. CPU with renamed MKLDNNPlugin)
  • When there is a plugin but there is no device (i.e. MYRIAD)
  • When there is a device and plugin but it's unavailable (i.e. with MYRIAD which is used by different process)
  • When there is no plugin and there is no device (i.e. ARM CPU as in case of Raspberry Pi).

@JulienMaille
Copy link
Copy Markdown
Contributor Author

JulienMaille commented Dec 17, 2019

Thanks!

Can this method test the devices? I mean which lists it will show in the following scenarios:

  • When there is a device but there is no plugin available (i.e. CPU with renamed MKLDNNPlugin)
  • this is handled by OpenVino: no plugin means it won't show up in the list of available devices
  • When there is a plugin but there is no device (i.e. MYRIAD)
  • this is handled by OpenVino: no device means it won't show up in the list of available devices
  • When there is a device and plugin but it's unavailable (i.e. with MYRIAD which is used by different process)
  • I believe this is not handled but I'm unable to reproduce this right now
  • When there is no plugin and there is no device (i.e. ARM CPU as in case of Raspberry Pi).
  • handled as well, no plugin -> not in the list

@dkurt
Copy link
Copy Markdown
Member

dkurt commented Dec 21, 2019

Can this or similar method determine Myriad 2 or Myriad X?

Can you also experiment replacing checkIETarget from dnn.cpp using this new function? Thanks!

@dkurt dkurt closed this Dec 21, 2019
@dkurt dkurt reopened this Dec 21, 2019
@JulienMaille
Copy link
Copy Markdown
Contributor Author

JulienMaille commented Dec 21, 2019

Well I did not know I could call cv::dnn::getAvailableBackends() to do this
In op_inf_engine.cpp there's a isMyriadX() function

@dkurt
Copy link
Copy Markdown
Member

dkurt commented Dec 26, 2019

@Nefast, May I ask you if getAvailableTargets(DNN_BACKEND_INFERENCE_ENGINE) can match your expectations? This way we could add a wrapper to it instead.

If yes, you can modify modify this PR in the following way: (it'll also require to reopen PR with 3.4 branch as a target, we will port the changes to master branch after that).

diff --git a/modules/dnn/include/opencv2/dnn/dnn.hpp b/modules/dnn/include/opencv2/dnn/dnn.hpp
index 94e2ada..c5d3975 100644
--- a/modules/dnn/include/opencv2/dnn/dnn.hpp
+++ b/modules/dnn/include/opencv2/dnn/dnn.hpp
@@ -94,7 +94,7 @@ CV__DNN_EXPERIMENTAL_NS_BEGIN
      */
     enum Target
     {
-        DNN_TARGET_CPU,
+        DNN_TARGET_CPU = 0,
         DNN_TARGET_OPENCL,
         DNN_TARGET_OPENCL_FP16,
         DNN_TARGET_MYRIAD,
@@ -102,7 +102,7 @@ CV__DNN_EXPERIMENTAL_NS_BEGIN
     };
 
     CV_EXPORTS std::vector< std::pair<Backend, Target> > getAvailableBackends();
-    CV_EXPORTS std::vector<Target> getAvailableTargets(Backend be);
+    CV_EXPORTS_W std::vector<Target> getAvailableTargets(Backend be);
 
     /** @brief This class provides all data needed to initialize layer.
      *
diff --git a/modules/dnn/misc/python/pyopencv_dnn.hpp b/modules/dnn/misc/python/pyopencv_dnn.hpp
index 34aeacb..69c1424 100644
--- a/modules/dnn/misc/python/pyopencv_dnn.hpp
+++ b/modules/dnn/misc/python/pyopencv_dnn.hpp
@@ -71,6 +71,12 @@ PyObject* pyopencv_from(const dnn::LayerParams& lp)
     return dict;
 }
 
+template<>
+PyObject* pyopencv_from(const std::vector<dnn::Target> &t)
+{
+    return pyopencv_from(std::vector<int>(t.begin(), t.end()));
+}
+
 class pycvLayer CV_FINAL : public dnn::Layer
 {
 public:

@JulienMaille
Copy link
Copy Markdown
Contributor Author

@dkurt Do you mean I should replace calls to bool checkIETarget(Target target) https://github.com/opencv/opencv/blob/master/modules/dnn/src/dnn.cpp#L110 with my solution?
Now that you showed me that I can use getAvailableTargets(), my PR doesn't make sense anymore

@dkurt
Copy link
Copy Markdown
Member

dkurt commented Dec 30, 2019

@Nefast, You still can help us adding a wrapper for getAvailableTargets because for now it's C++ only. So you can do it in this PR (or it's even better to reopen it to 3.4 branch with a different branch name):

git checkout 3.4
git checkout -b branch_name

@JulienMaille
Copy link
Copy Markdown
Contributor Author

Sorry to be slow. You want me to reopen a PR on 3.4 with nothing more than the diff you posted just above?

@dkurt
Copy link
Copy Markdown
Member

dkurt commented Dec 30, 2019

@Nefast, Yes, if you don't mind.

@JulienMaille
Copy link
Copy Markdown
Contributor Author

Ok. I close this PR as a duplicate of #16232

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.

2 participants