Skip to content

Commit 0529f4e

Browse files
authored
Merge pull request #2927 from Wovchena/demos/common/python/openvino/model_zoo/model_api-let-openvino-decide-what-it-supports
demos/common/python/openvino/model_zoo/model_api: let openvino decide what it supports
2 parents 45ec799 + 1f6c13a commit 0529f4e

File tree

4 files changed

+11
-20
lines changed

4 files changed

+11
-20
lines changed

demos/common/python/openvino/model_zoo/model_api/adapters/openvino_adapter.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def create_core():
4040

4141
class OpenvinoAdapter(ModelAdapter):
4242
"""
43-
Class that allows working with Inference Engine model, its input and output blobs
43+
Works with OpenVINO model
4444
"""
4545

4646
def __init__(self, ie, model_path, weights_path=None, device='CPU', plugin_config=None, max_num_requests=1):
@@ -51,18 +51,9 @@ def __init__(self, ie, model_path, weights_path=None, device='CPU', plugin_confi
5151
self.max_num_requests = max_num_requests
5252

5353
if isinstance(model_path, (str, Path)):
54-
model_path_suffix = Path(model_path).suffix
55-
if model_path_suffix == ".onnx":
56-
if weights_path:
57-
log.warning('For model in ONNX format should set only "model_path" parameter.'
58-
'The "weights_path" will be omitted')
59-
weights_path = None
60-
elif model_path_suffix == ".xml":
61-
weights_path_suffix = Path(weights_path).suffix if weights_path else None
62-
if weights_path_suffix and weights_path_suffix != ".bin":
63-
raise ValueError(f"Unsupported weights file extension: {weights_path_suffix}")
64-
else:
65-
raise ValueError(f"Unsupported model file extension: {model_path_suffix}")
54+
if Path(model_path).suffix == ".onnx" and weights_path:
55+
log.warning('For model in ONNX format should set only "model_path" parameter.'
56+
'The "weights_path" will be omitted')
6657

6758
self.model_from_buffer = isinstance(model_path, bytes) and isinstance(weights_path, bytes)
6859
log.info('Reading model {}'.format('from buffer' if self.model_from_buffer else model_path))

demos/common/python/openvino/model_zoo/model_api/models/detection_model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818

1919

2020
class DetectionModel(ImageModel):
21-
'''A abstract detection model class
21+
'''An abstract detection model class
2222
23-
This class supports the detection models. The Detection Model should have single image input.
23+
This class supports detection models. The Detection Model must have single image input.
2424
2525
Attributes:
2626
labels(List[str]): list of labels for classes (could be None)

demos/common/python/openvino/model_zoo/model_api/models/image_model.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919

2020

2121
class ImageModel(Model):
22-
'''An abstract wrapper for image-based model
22+
'''An abstract wrapper for an image-based model
2323
24-
An image-based model is model which has one or more inputs with image - 4D tensors with NWHC or NCHW layout.
25-
Also it may have support additional inputs - 2D tensor.
24+
An image-based model is a model which has one or more inputs with image - 4D tensors with NHWC or NCHW layout.
25+
Also it may support additional inputs - 2D tensor.
2626
Implements basic preprocessing for image: resizing and aligning to model input.
2727
2828
Attributes:

demos/common/python/openvino/model_zoo/model_api/models/model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ class Model:
2121
'''An abstract model wrapper
2222
2323
An abstract model wrapper can only load model from the disk.
24-
The ``preprocess`` and ``postprocess`` method should be implemented in concrete class
24+
The ``preprocess`` and ``postprocess`` methods should be implemented in a concrete class
2525
2626
Attributes:
2727
model_adapter(ModelAdapter): allows working with the specified executor
2828
logger(Logger): instance of the logger
2929
'''
3030

3131
def __init__(self, model_adapter):
32-
'''Abstract model constructor
32+
'''Model constructor
3333
3434
Args:
3535
model_adapter(ModelAdapter): allows working with the specified executor

0 commit comments

Comments
 (0)