Skip to content

Mask rcnn model using OpenVINO is not accurate #14509

Closed

Description

@stq054188

##### System information (version)
OpenCV => 4.1.0
Operating System / Platform => Windows10 64 Bit
Compiler => Visual Studio 2017
OpenVINO => w_openvino_toolkit_p_2018.5.456

##### Detailed description
I have trained a mask rcnn model with tensorflow and I used openvino to accelerate it. But I found the
result with using parameter DNN_BACKEND_OPENCV is more accurate than using DNN_BACKEND_INFERENCE_ENGINE.

##### Steps to reproduce

  1. Test code is OpenCV_Mask_RCNN.cpp, test images are 2.png and 7.png. All files are packed as files.zip.
    files.zip
  2. Model files and config files are here. https://drive.google.com/open?id=1xTI6_bqbZpi3vbeVcFxX1emBSa7QI58z
  3. Here is my test result.
    DNN_BACKEND_INFERENCE_ENGINE result
    Q1

DNN_BACKEND_OPENCV result
Q2

  1. I also test faster rcnn model,both of DNN_BACKEND_OPENCV and DNN_BACKEND_INFERENCE_ENGINE result are same. With mask rcnn model seems bounding rects are same but masks are different. @dkurt This looks like a real bug.

Activity

  1. changed the title [-]Mask rcnn model use OpenVINO is not accurate[/-] [+]Mask rcnn model using OpenVINO is not accurate[/+] on May 8, 2019
  2. alalek commented on May 8, 2019

    @alalek
    Member

    Avoid creation of issues for similar problems: #14480

    w_openvino_toolkit_p_2018.5.456

    This package is not fresh. Try latest release 2019R1 at first.

  3. stq054188 commented on May 9, 2019

    @stq054188
    Author

    @alalek @dkurt Although I changed the version to 2019_R1.01, the results did not improve.

  4. stq054188 commented on May 13, 2019

    @stq054188
    Author

    Has someone encountered a similar situation?

  5. Bleach665 commented on Feb 16, 2020

    @Bleach665
    Contributor

    The same problem. Win10, OpenCV rev. cc259e4, OpenVINO 2019.3.379.
    Model: mask_rcnn_inception_v2_coco_2018_01_28.
    OpenCV backend, CPU target:
    a1
    Inference engine backend, CPU target: 0 object detected.
    UPD. Test image source:
    Complete_Streets_-_bluebonnet_lane

  6. self-assigned this
    on Feb 16, 2020
  7. Bleach665 commented on Feb 16, 2020

    @Bleach665
    Contributor

    @dkurt. A small addition: I use PC's with old CPU which not support AVX instruction set. Maybe that matters.
    In all other models that I tested Inference engine backend works fine.

  8. dkurt commented on Feb 16, 2020

    @dkurt
    Member

    @Bleach665, probably not. I can reproduce the problem on different CPU. The thing is that it can compute masks and boxes separately but the problem appears if we return both of them. Let me try to find a workaround or fix that.

  9. dkurt commented on Feb 16, 2020

    @dkurt
    Member

    @Bleach665, May I ask you to open a .pbtxt file and try to apply these changes?

    @@ -5926,7 +5926,7 @@ node {
       input: "variance_encoded"
     }
     node {
    -  name: "detection_out_final"
    +  name: "detection_out_final/real"
       op: "DetectionOutput"
       input: "variance_encoded/flatten"
       input: "SecondStageBoxPredictor/Reshape_1/Reshape"
    @@ -5992,11 +5992,35 @@ node {
         }
       }
     }
    +node {
    +  name: "one"
    +  op: "Const"
    +  attr {
    +    key: "value"
    +    value {
    +      tensor {
    +        dtype: DT_FLOAT
    +        tensor_shape {
    +          dim {
    +            size: 1
    +          }
    +        }
    +        float_val: 1.0
    +      }
    +    }
    +  }
    +}@Bleach665, May I ask you to open a .pbtxt file and try to apply this changes?
    
    
    +node {
    +  name: "detection_out_final"
    +  op: "Mul"
    +  input: "detection_out_final/real"
    +  input: "one"
    +}
     node {
       name: "CropAndResize_1"
       op: "CropAndResize"
       input: "FirstStageFeatureExtractor/InceptionV2/InceptionV2/Mixed_4e/concat"
    -  input: "detection_out_final"
    +  input: "detection_out_final/real"
       input: "CropAndResize_1/crop_size"
       attr {
         key: "extrapolation_value"

    and try to run with IE backend?

  10. Bleach665 commented on Feb 16, 2020

    @Bleach665
    Contributor

    @dkurt , works great with these changes. The result is the same as when used CUDA or OpenCV backends.
    The result with the changes above and inference engine backend:
    1112

  11. dkurt commented on Feb 16, 2020

    @dkurt
    Member

    @Bleach665, great. thanks! Based on this experiment we will propose a patch so old version of .pbtxt will also work.

  12. dkurt commented on Feb 16, 2020

    @dkurt
    Member

    @stq054188, sorry for late solution, but here it is: #16595. I was not able to download your model but at least with @Bleach665's image we achieve exact outputs.

    BTW, for now OpenCV can work with two APIs of Inference Engine: legacy DNNBuilder and nGraph API. With nGraph API we can achieve monolithic model (all the layers are executed by IE) that means the model can work faster and even go to accelerators (i.e. Myriad NCS2).

    Note(alalek): nGraph is not enabled by default. It should by this call (or through environment):

    setInferenceEngineBackendType(CV_DNN_BACKEND_INFERENCE_ENGINE_NGRAPH);
    
  13. sctrueew commented on Apr 14, 2021

    @sctrueew

    @stq054188 Hi,

    How did you convert yours .h5 to .pb? I'm going to use C++ API.

    Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions