Skip to content

Commit 7502e2c

Browse files
authored
Merge branch 'master' into feature/py_type_annotation
2 parents 0ca90db + 4cc192d commit 7502e2c

File tree

7 files changed

+119
-0
lines changed

7 files changed

+119
-0
lines changed

docs/source/cpp/models/anomaly_model.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Anomaly Model
22

3+
The `AnomalyModel` is a generic OpenVINO model that aims to provide a single interface for all the exported models based on [Anomalib](https://github.com/openvinotoolkit/anomalib).
4+
5+
Currently, the `AnomalyModel` supports the following models:
6+
7+
- Padim
8+
- STFPM
9+
310
```{eval-rst}
411
.. doxygenclass:: AnomalyModel
512

docs/source/python/models/anomaly.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Anomaly
22

3+
The `AnomalyModel` is a generic OpenVINO model that aims to provide a single interface for all the exported models based on [Anomalib](https://github.com/openvinotoolkit/anomalib).
4+
5+
Currently, the `AnomalyModel` supports the following models:
6+
7+
- Padim
8+
- STFPM
9+
310
```{eval-rst}
411
.. automodule:: model_api.models.anomaly
512
:members:

docs/source/python/models/classification.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
# Classification
22

3+
## Description
4+
5+
The `ClassificationModel` is the OpenVINO wrapper for models exported from [OpenVINO Training Extensions](https://github.com/openvinotoolkit/training_extensions). It supports multi-label classification as well as hierarchical classification.
6+
7+
## Model Specifications
8+
9+
## Inputs
10+
11+
A single input image of shape (H, W, 3) where H and W are the height and width of the image, respectively.
12+
13+
## Outputs
14+
15+
- `top_labels`: List of tuples containing the top labels of the classification model.
16+
- `saliency_map`: Saliency map of the input image.
17+
- `feature_vector`: Feature vector of the input image. This is useful for Active Learning.
18+
- `raw_scores`: Raw scores of the classification model.
19+
320
```{eval-rst}
421
.. automodule:: model_api.models.classification
522
:members:

docs/source/python/models/segmentation.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# Segmentation
22

3+
The `SegmentationModel` is the OpenVINO wrapper for models exported from [OpenVINO Training Extensions](https://github.com/openvinotoolkit/training_extensions). It produces a segmentation mask for the input image.
4+
5+
## Model Specifications
6+
7+
### Inputs
8+
9+
A single input image of shape (H, W, 3) where H and W are the height and width of the image, respectively.
10+
11+
### Outputs
12+
13+
- `resultImage`: Image with the segmentation mask.
14+
- `soft_prediction`: Soft prediction of the segmentation model.
15+
- `saliency_map`: Saliency map of the input image.
16+
- `feature_vector`: Feature vector of the input image. This is useful for Active Learning.
17+
318
```{eval-rst}
419
.. automodule:: model_api.models.segmentation
520
:members:

model_api/python/model_api/models/anomaly.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,40 @@
2323

2424

2525
class AnomalyDetection(ImageModel):
26+
"""Anomaly Detection model.
27+
28+
Generic anomaly detection model that acts as an inference wrapper for all the exported models from
29+
Anomalib.
30+
31+
Args:
32+
inference_adapter (InferenceAdapter): Inference adapter
33+
configuration (dict, optional): Configuration parameters. Defaults to {}.
34+
preload (bool, optional): Whether to preload the model. Defaults to False.
35+
36+
Example:
37+
>>> from model_api.models import AnomalyDetection
38+
>>> import cv2
39+
>>> model = AnomalyDetection.create_model("./path_to_model.xml")
40+
>>> image = cv2.imread("path_to_image.jpg")
41+
>>> result = model.predict(image)
42+
AnomalyResult(anomaly_map=array([[150, 150, 150, ..., 138, 138, 138],
43+
[150, 150, 150, ..., 138, 138, 138],
44+
[150, 150, 150, ..., 138, 138, 138],
45+
...,
46+
[134, 134, 134, ..., 138, 138, 138],
47+
[134, 134, 134, ..., 138, 138, 138],
48+
[134, 134, 134, ..., 138, 138, 138]], dtype=uint8),
49+
pred_boxes=None, pred_label='Anomaly',
50+
pred_mask=array([[1, 1, 1, ..., 1, 1, 1],
51+
[1, 1, 1, ..., 1, 1, 1],
52+
[1, 1, 1, ..., 1, 1, 1],
53+
...,
54+
[1, 1, 1, ..., 1, 1, 1],
55+
[1, 1, 1, ..., 1, 1, 1],
56+
[1, 1, 1, ..., 1, 1, 1]], dtype=uint8),
57+
pred_score=0.8536462108391619)
58+
"""
59+
2660
__model__ = "AnomalyDetection"
2761

2862
def __init__(

model_api/python/model_api/models/classification.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,27 @@
2626

2727

2828
class ClassificationModel(ImageModel):
29+
"""Classification Model.
30+
31+
Args:
32+
inference_adapter (InferenceAdapter): Inference adapter
33+
configuration (dict, optional): Configuration parameters. Defaults to {}.
34+
preload (bool, optional): Whether to preload the model. Defaults to False.
35+
36+
Example:
37+
>>> from model_api.models import ClassificationModel
38+
>>> import cv2
39+
>>> model = ClassificationModel.create_model("./path_to_model.xml")
40+
>>> image = cv2.imread("path_to_image.jpg")
41+
>>> result = model.predict(image)
42+
ClassificationResult(
43+
top_labels=[(1, 'bicycle', 0.90176445), (6, 'car', 0.85433626), (7, 'cat', 0.60699755)],
44+
saliency_map=array([], dtype=float64),
45+
feature_vector=array([], dtype=float64),
46+
raw_scores=array([], dtype=float64)
47+
)
48+
"""
49+
2950
__model__ = "Classification"
3051

3152
def __init__(self, inference_adapter: InferenceAdapter, configuration: dict = {}, preload: bool = False) -> None:

model_api/python/model_api/models/segmentation.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,24 @@ def create_hard_prediction_from_soft_prediction(
5454

5555

5656
class SegmentationModel(ImageModel):
57+
"""Segmentation Model.
58+
59+
Args:
60+
inference_adapter (InferenceAdapter): Inference adapter
61+
configuration (dict, optional): Configuration parameters. Defaults to {}.
62+
preload (bool, optional): Whether to preload the model. Defaults to False.
63+
64+
Example:
65+
>>> from model_api.models import SegmentationModel
66+
>>> import cv2
67+
>>> model = SegmentationModel.create_model("./path_to_model.xml")
68+
>>> image = cv2.imread("path_to_image.jpg")
69+
>>> result = model.predict(image)
70+
ImageResultWithSoftPrediction(
71+
...
72+
)
73+
"""
74+
5775
__model__ = "Segmentation"
5876

5977
def __init__(self, inference_adapter: InferenceAdapter, configuration: dict = {}, preload: bool = False) -> None:

0 commit comments

Comments
 (0)