openvinotoolkit / mmdetection

OpenVINO Training Extensions Object Detection

Home Page:https://github.com/opencv/openvino_training_extensions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OpenVINO net reshape corrupts models

druzhkov-paul opened this issue · comments

Description
OpenVINO models are corrupted by reshape, which is essential for the models that resize images keeping their aspect ratio unchanged at a pre-processing stage. As of 2021.2 OpenVINO supports reshape of detection models from the repo. Corresponding changes are introduced in #102. Though, default exported graphs seem to be corrupted by network reshape -- that leads to quality degradation of the val/test dataset.

Reproduction
Use the code from #102 to run models' test:

$ pytest tests/test_models.py -v -k "openvino"

tests should pass.

Comment out this line https://github.com/openvinotoolkit/mmdetection/blob/ote/mmdet/utils/deployment/symbolic.py#L284 and rerun the tests:

$ pytest tests/test_models.py -v -k "openvino"

The following tests start to fail:

FAILED tests/test_models.py::PublicModelsTestCase::test_openvino_atss__atss_r50_fpn_1x_coco - AssertionError: bbox: 0.464 (expected) - 0.02 (threshold) > 0.409
FAILED tests/test_models.py::PublicModelsTestCase::test_openvino_gn__mask_rcnn_r50_fpn_gn_all_2x_coco - AssertionError: bbox: 0.553 (expected) - 0.02 (threshold) > 0.493
FAILED tests/test_models.py::PublicModelsTestCase::test_openvino_gn_ws__faster_rcnn_r50_fpn_gn_ws_all_1x_coco - AssertionError: bbox: 0.466 (expected) - 0.02 (threshold) > 0.413
FAILED tests/test_models.py::PublicModelsTestCase::test_openvino_retinanet_r50_fpn_1x - AssertionError: bbox: 0.461 (expected) - 0.02 (threshold) > 0.367

Environment

$ python mmdet/utils/collect_env.py
sys.platform: linux
Python: 3.7.9 (default, Aug 18 2020, 06:22:45) [GCC 7.5.0]
CUDA available: False
GCC: gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
PyTorch: 1.5.1
PyTorch compiling details: PyTorch built with:
  - GCC 7.3
  - C++ Version: 201402
  - Intel(R) Math Kernel Library Version 2019.0.5 Product Build 20190808 for Intel(R) 64 architecture applications
  - Intel(R) MKL-DNN v0.21.1 (Git Hash 7d2fd500bc78936d1d648ca713b901012f470dbc)
  - OpenMP 201511 (a.k.a. OpenMP 4.5)
  - NNPACK is enabled
  - CPU capability usage: AVX2
  - Build settings: BLAS=MKL, BUILD_TYPE=Release, CXX_FLAGS= -Wno-deprecated -fvisibility-inlines-hidden -fopenmp -DNDEBUG -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DUSE_INTERNAL_THREADPOOL_IMPL -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-result -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Wno-stringop-overflow, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, USE_CUDA=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=ON, USE_NNPACK=ON, USE_OPENMP=ON, USE_STATIC_DISPATCH=OFF, 

TorchVision: 0.6.1
OpenCV: 4.5.2-openvino
MMCV: 0.6.2
MMDetection: 2.1.0+077338f
MMDetection Compiler: GCC 7.5
MMDetection CUDA Compiler: not available
NNCF: None
OpenVINO MO: 2021.3.0-2677-76fed9315e7
OpenVINO IE: 2.1.2021.3.0-2677-76fed9315e

Error traceback
N/A

Bug fix
Changing multiclass NMS exporting path to use explicit symbolic graph definition, rather than tracing (https://github.com/openvinotoolkit/mmdetection/blob/ote/mmdet/utils/deployment/symbolic.py#L284) resolves the issue, but default path should be fixed as well.

Fixed in #112 / #106.