Skip to content

Commit acd989f

Browse files
Merge branch 'master' into ashwin/ruff_rules_2
2 parents cf38a53 + 5830b62 commit acd989f

File tree

3 files changed

+134
-0
lines changed

3 files changed

+134
-0
lines changed

docs/source/python/models/detection_model.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,46 @@
11
# Detection Model
22

3+
## Description
4+
5+
Detection model aims to detect objects in an image. The model outputs a list of detected objects, each containing a bounding box, score and class label.
6+
7+
## OpenVINO 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+
Detection model outputs a list of detection objects (i.e `list[Detection]`) wrapped in `DetectionResult`, each object containing the following attributes:
16+
17+
- `score` (float) - Confidence score of the object.
18+
- `id` (int) - Class label of the object.
19+
- `str_label` (str) - String label of the object.
20+
- `xmin` (int) - X-coordinate of the top-left corner of the bounding box.
21+
- `ymin` (int) - Y-coordinate of the top-left corner of the bounding box.
22+
- `xmax` (int) - X-coordinate of the bottom-right corner of the bounding box.
23+
- `ymax` (int) - Y-coordinate of the bottom-right corner of the bounding box.
24+
25+
## Example
26+
27+
```python
28+
import cv2
29+
from model_api.models import SSD
30+
31+
# Load the model
32+
model = SSD.create_model("model.xml")
33+
34+
# Forward pass
35+
predictions = model(image)
36+
37+
# Iterate over the segmented objects
38+
for pred_obj in predictions.objects:
39+
pred_score = pred_obj.score
40+
label_id = pred_obj.id
41+
bbox = [pred_obj.xmin, pred_obj.ymin, pred_obj.xmax, pred_obj.ymax]
42+
```
43+
344
```{eval-rst}
445
.. automodule:: model_api.models.detection_model
546
:members:

docs/source/python/models/instance_segmentation.md

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

3+
## Description
4+
5+
Instance segmentation model aims to detect and segment objects in an image. It is an extension of object detection, where each object is segmented into a separate mask. The model outputs a list of segmented objects, each containing a mask, bounding box, score and class label.
6+
7+
## OpenVINO 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+
Instance segmentation model outputs a list of segmented objects (i.e `list[SegmentedObject]`)wrapped in `InstanceSegmentationResult.segmentedObjects`, each containing the following attributes:
16+
17+
- `mask` (numpy.ndarray) - A binary mask of the object.
18+
- `score` (float) - Confidence score of the object.
19+
- `id` (int) - Class label of the object.
20+
- `str_label` (str) - String label of the object.
21+
- `xmin` (int) - X-coordinate of the top-left corner of the bounding box.
22+
- `ymin` (int) - Y-coordinate of the top-left corner of the bounding box.
23+
- `xmax` (int) - X-coordinate of the bottom-right corner of the bounding box.
24+
- `ymax` (int) - Y-coordinate of the bottom-right corner of the bounding box.
25+
26+
## Example
27+
28+
```python
29+
import cv2
30+
from model_api.models import MaskRCNNModel
31+
32+
# Load the model
33+
model = MaskRCNNModel.create_model("model.xml")
34+
35+
# Forward pass
36+
predictions = model(image)
37+
38+
# Iterate over the segmented objects
39+
for pred_obj in predictions.segmentedObjects:
40+
pred_mask = pred_obj.mask
41+
pred_score = pred_obj.score
42+
label_id = pred_obj.id
43+
bbox = [pred_obj.xmin, pred_obj.ymin, pred_obj.xmax, pred_obj.ymax]
44+
```
45+
346
```{eval-rst}
447
.. automodule:: model_api.models.instance_segmentation
548
:members:

docs/source/python/models/keypoint_detection.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,55 @@
11
# Keypoint Detection
22

3+
## Description
4+
5+
Keypoint detection model aims to detect a set of pre-defined keypoints on a cropped object.
6+
If a crop is not tight enough, quality of keypoints degrades. Having this model and an
7+
object detector, one can organize keypoint detection for all objects of interest presented on an image (top-down approach).
8+
9+
## Models
10+
11+
Top-down keypoint detection pipeline uses detections that come from any appropriate detector,
12+
and a keypoints regression model acting on crops.
13+
14+
### Parameters
15+
16+
The following parameters can be provided via python API or RT Info embedded into OV model:
17+
18+
- `labels`(`list(str)`) : a list of keypoints names.
19+
20+
## OpenVINO Model Specifications
21+
22+
### Inputs
23+
24+
A single `NCHW` tensor representing a batch of images.
25+
26+
### Outputs
27+
28+
Two vectors in Simple Coordinate Classification Perspective ([SimCC](https://arxiv.org/abs/2107.03332)) format:
29+
30+
- `pred_x` (B, N, D1) - `x` coordinate representation, where `N` is the number of keypoints.
31+
- `pred_y` (B, N, D2) - `y` coordinate representation, where `N` is the number of keypoints.
32+
33+
## Example
34+
35+
```python
36+
import cv2
37+
from model_api.models import TopDownKeypointDetectionPipeline, Detection, KeypointDetectionModel
38+
39+
model = KeypointDetectionModel.create_model("kp_model.xml")
40+
# a list of detections in (x_min, y_min, x_max, y_max, score, class_id) format
41+
detections = [Detection(0, 0, 100, 100, 1.0, 0)]
42+
top_down_pipeline = TopDownKeypointDetectionPipeline(model)
43+
predictions = top_down_detector.predict(image, detections)
44+
45+
# iterating over a list of DetectedKeypoints. Each of the items corresponds to a detection
46+
for obj_keypoints in predictions:
47+
for point in obj_keypoints.keypoints.astype(np.int32):
48+
cv2.circle(
49+
image, point, radius=0, color=(0, 255, 0), thickness=5
50+
)
51+
```
52+
353
```{eval-rst}
454
.. automodule:: model_api.models.keypoint_detection
555
:members:

0 commit comments

Comments
 (0)