openvinotoolkit / open_model_zoo

Pre-trained Deep Learning models and demos (high quality and extremely fast)
https://docs.openvino.ai/latest/model_zoo.html
Apache License 2.0
4.1k stars 1.37k forks source link

pedestrain tracker on myriad NCS2 fails in 2019 R3 #505

Closed aungthetnaing closed 5 years ago

aungthetnaing commented 5 years ago
 ./pedestrian_tracker_demo -i ~/Downloads/mall.mp4 -m_det ~/processed_models/Retail/object_detection/pedestrian/rmnet_ssd/0013/dldt/person-detection-retail-0013-fp16.xml -d_det MYRIAD -m_reid ~/processed_models/Retail/object_reidentification/pedestrian/rmnet_based/0031/dldt/person-reidentification-retail-0031-fp16.xml -d_reid myriad
InferenceEngine: 
    API version ............ 2.0
    Build .................. custom_releases/2019/R2_f5827d4773ebbe727c9acac5f007f7d94dd4be4e
    Description ....... API
Parsing input parameters
Loading device MYRIAD
    MYRIAD
    myriadPlugin version ......... 2.0
    Build ........... 27579

Loading device myriad
    myriad
    myriadPlugin version ......... 2.0
    Build ........... 27579

To close the application, press 'CTRL+C' here or switch to the output window and press ESC key
**[ ERROR ] Dynamic batch is not supported**

It is still the issue even after forcing batch size of 1. No issue with CPU

diff --git a/demos/pedestrian_tracker_demo/main.cpp b/demos/pedestrian_tracker_demo/main.cpp
index 703017f..37fbbbe 100644
--- a/demos/pedestrian_tracker_demo/main.cpp
+++ b/demos/pedestrian_tracker_demo/main.cpp
@@ -51,7 +51,7 @@ CreatePedestrianTracker(const std::string& reid_model,

     if (!reid_model.empty() && !reid_weights.empty()) {
         CnnConfig reid_config(reid_model, reid_weights);
-        reid_config.max_batch_size = 16;
+        reid_config.max_batch_size = 1;

         std::shared_ptr<IImageDescriptor> descriptor_strong =
             std::make_shared<DescriptorIE>(reid_config, ie, deviceName);
diff --git a/demos/pedestrian_tracker_demo/src/cnn.cpp b/demos/pedestrian_tracker_demo/src/cnn.cpp
index 5056c05..3198dbd 100644
--- a/demos/pedestrian_tracker_demo/src/cnn.cpp
+++ b/demos/pedestrian_tracker_demo/src/cnn.cpp
@@ -34,7 +34,7 @@ void CnnBase::Load() {
     const int currentBatchSize = net_reader.getNetwork().getBatchSize();
     if (currentBatchSize != config_.max_batch_size)
         net_reader.getNetwork().setBatchSize(config_.max_batch_size);
-
+    net_reader.getNetwork().setBatchSize(1);
     InferenceEngine::InputsDataMap in;
     in = net_reader.getNetwork().getInputsInfo();
     if (in.size() != 1) {
aungthetnaing commented 5 years ago

The following patch fixes the issue:

From 7807070966457f5e225ad0d03daaec6e84ce23d2 Mon Sep 17 00:00:00 2001
From: Aung Naing <aung.t.naing@intel.com>
Date: Thu, 10 Oct 2019 22:12:24 -0700
Subject: [PATCH] [#505] Fix error thrown from SetBatch in VPUs

VPU calls base implementation which is to throw error for SetBatch.

https://github.com/opencv/open_model_zoo/issues/505

Signed-off-by: Aung Naing <aung.t.naing@intel.com>
---
 demos/pedestrian_tracker_demo/main.cpp    | 6 +++++-
 demos/pedestrian_tracker_demo/src/cnn.cpp | 6 +++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/demos/pedestrian_tracker_demo/main.cpp b/demos/pedestrian_tracker_demo/main.cpp
index 703017f..8978e11 100644
--- a/demos/pedestrian_tracker_demo/main.cpp
+++ b/demos/pedestrian_tracker_demo/main.cpp
@@ -51,7 +51,11 @@ CreatePedestrianTracker(const std::string& reid_model,

     if (!reid_model.empty() && !reid_weights.empty()) {
         CnnConfig reid_config(reid_model, reid_weights);
-        reid_config.max_batch_size = 16;
+        reid_config.max_batch_size = 16;   // defaulting to 16
+        if ((deviceName.find("MYRIAD") != std::string::npos) || (deviceName.find("HDDL") != std::string::npos)) {
+            reid_config.max_batch_size = 1;
+        }
+

         std::shared_ptr<IImageDescriptor> descriptor_strong =
             std::make_shared<DescriptorIE>(reid_config, ie, deviceName);
diff --git a/demos/pedestrian_tracker_demo/src/cnn.cpp b/demos/pedestrian_tracker_demo/src/cnn.cpp
index 5056c05..8ad9b5e 100644
--- a/demos/pedestrian_tracker_demo/src/cnn.cpp
+++ b/demos/pedestrian_tracker_demo/src/cnn.cpp
@@ -77,7 +77,11 @@ void CnnBase::InferBatch(
             matU8ToBlob<uint8_t>(frames[batch_i + b], input_blob_, b);
         }

-        infer_request_.SetBatch(current_batch_size);
+        if ((deviceName_.find("MYRIAD") == std::string::npos) && (deviceName_.find("HDDL") == std::string::npos)) {
+             infer_request_.SetBatch(current_batch_size);    // std::cout << "No batch support for " << deviceName_ << std::endl << std::endl;
+        }
+
+
         infer_request_.Infer();

         fetch_results(outputs_, current_batch_size);
-- 
2.7.4
aungthetnaing commented 5 years ago

How to get a push access to this repo?

aungthetnaing commented 5 years ago

I'll try against R3 again..

aungthetnaing commented 5 years ago

No issue on 2019R3

aungthetnaing commented 5 years ago

Incorrect testing; still observable in 2019 R3

InferenceEngine: 
    API version ............ 2.1
    Build .................. custom_releases/2019/R3_cb6cad9663aea3d282e0e8b3e0bf359df665d5d0
    Description ....... API
Parsing input parameters
Loading device MYRIAD
    MYRIAD
    myriadPlugin version ......... 2.1
    Build ........... 30677

To close the application, press 'CTRL+C' here or switch to the output window and press ESC key
[ ERROR ] Dynamic batch is not supported
Wovchena commented 5 years ago

How to get a push access to this repo?

You can submit a pull request.

The provided patch looks good. I would only suggest

@aungthetnaing, will you submit the update, or should I do it?

aungthetnaing commented 5 years ago

What's the procedure to create a PR? I tried this way.

git push origin HEAD:

I was giving error of no access rights..

I'm traveling right now. If I have access rights, I could create a PR when I'm back next week.

Wovchena commented 5 years ago

You should create a fork and push updates to it and than request a merge of your fork with the original repo.

aungthetnaing commented 5 years ago

I did the following:

git checkout -b test_psh git add git commit -m "test commeng" git push origin HEAD:test_psh

I'm getting the following:

remote: Permission to opencv/open_model_zoo.git denied to aungthetnaing. fatal: unable to access 'https://github.com/opencv/open_model_zoo.git/': The requested URL returned error: 403

So that mean my github ID needs to go through some kind of access granting process.

Wovchena commented 5 years ago

The procedure is slightly more complex: 1) there is a Fork button at the top of this page. Clicking it will create a copy of open_model_zoo: it will be https://github.com/aungthetnaing/open_model_zoo for you. 2) Clone that copied repo (alternative solution could be messing with git remotes like git remote add -f aungthetnaing https://github.com/aungthetnaing/open_model_zoo which allows to keep multiple remotes in the same local git repo). 3) do updates and push to your repo. 4) open your repo on github and it will suggest to submit a pull request.

vladimir-dudnik commented 5 years ago

close as implemented

whatisor commented 4 years ago

Why don't VPU support dynamic batch?