forked from open-mmlab/mmrazor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Enhancement]: Update configs for OpenVINO (open-mmlab#306)
* Update config for OpenVINO * Update test * Update better test * Update instance-seg config of OpenVINO
- Loading branch information
1 parent
abdf64a
commit 0f9f0a6
Showing
22 changed files
with
77 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
_base_ = ['./classification_dynamic.py', '../_base_/backends/openvino.py'] | ||
|
||
onnx_config = dict(input_shape=None) | ||
|
||
backend_config = dict( | ||
model_inputs=[dict(opt_shapes=dict(input=[1, 3, 224, 224]))]) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
_base_ = ['./base_dynamic.py', '../../_base_/backends/openvino.py'] | ||
|
||
onnx_config = dict(input_shape=None) | ||
|
||
backend_config = dict( | ||
model_inputs=[dict(opt_shapes=dict(input=[1, 3, 800, 1344]))]) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
_base_ = ['../_base_/base_openvino_dynamic-800x1344.py'] |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
configs/mmedit/super-resolution/super-resolution_openvino_dynamic-256x256.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
_base_ = ['./super-resolution_dynamic.py', '../../_base_/backends/openvino.py'] | ||
|
||
backend_config = dict( | ||
model_inputs=[dict(opt_shapes=dict(input=[1, 3, 256, 256]))]) |
1 change: 0 additions & 1 deletion
1
configs/mmedit/super-resolution/super-resolution_openvino_dynamic.py
This file was deleted.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
configs/mmocr/text-detection/text-detection_openvino_dynamic-640x640.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
_base_ = ['./text-detection_dynamic.py', '../../_base_/backends/openvino.py'] | ||
|
||
onnx_config = dict(input_shape=None) | ||
|
||
backend_config = dict( | ||
model_inputs=[dict(opt_shapes=dict(input=[1, 3, 640, 640]))]) |
3 changes: 0 additions & 3 deletions
3
configs/mmocr/text-detection/text-detection_openvino_dynamic.py
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
configs/mmocr/text-detection/text-detection_openvino_static-640x640.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
_base_ = ['./segmentation_dynamic.py', '../_base_/backends/openvino.py'] | ||
|
||
backend_config = dict( | ||
model_inputs=[dict(opt_shapes=dict(input=[1, 3, 1024, 2048]))]) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,22 @@ | ||
# Copyright (c) OpenMMLab. All rights reserved. | ||
from typing import List | ||
from typing import Dict, List | ||
|
||
import mmcv | ||
|
||
from mmdeploy.utils import get_input_shape | ||
from mmdeploy.utils import get_model_inputs | ||
|
||
|
||
def get_input_shape_from_cfg(deploy_cfg: mmcv.Config, | ||
model_cfg: mmcv.Config) -> List[int]: | ||
"""Get the input shape from the configs for OpenVINO Model Optimizer. The | ||
value from config 'deploy_cfg' has the highest priority, then 'model_cfg'. | ||
If there is no input shape in configs, then the default value will be used. | ||
def get_input_info_from_cfg(deploy_cfg: mmcv.Config) -> Dict[str, List]: | ||
"""Get the input names and shapes from the configs for OpenVINO Model | ||
Optimizer. | ||
Args: | ||
deploy_cfg (mmcv.Config): Deployment config. | ||
model_cfg (mmcv.Config): Model config. | ||
Returns: | ||
List[int]: The input shape in [1, 3, H, W] format from config | ||
or [1, 3, 800, 1344]. | ||
Dict[str, List]: A dict that stores the names and shapes of input. | ||
""" | ||
shape = [1, 3] | ||
is_use_deploy_cfg = False | ||
try: | ||
input_shape = get_input_shape(deploy_cfg) | ||
if input_shape is not None: | ||
is_use_deploy_cfg = True | ||
except KeyError: | ||
is_use_deploy_cfg = False | ||
|
||
if is_use_deploy_cfg: | ||
shape += [input_shape[1], input_shape[0]] | ||
else: | ||
test_pipeline = model_cfg.get('test_pipeline', None) | ||
if test_pipeline is not None: | ||
img_scale = test_pipeline[1]['img_scale'] | ||
shape += [img_scale[1], img_scale[0]] | ||
else: | ||
shape += [800, 1344] | ||
return shape | ||
# The partition is not supported now. Set the id of model to 0. | ||
model_inputs = get_model_inputs(deploy_cfg)[0] | ||
input_info = model_inputs['opt_shapes'] | ||
return input_info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters