Skip to content

Commit ad2bff3

Browse files
committed
✨Add model descriptions and documentation for instance segmentation, detection, and keypoint detection
1 parent 23620d1 commit ad2bff3

File tree

5 files changed

+179
-0
lines changed

5 files changed

+179
-0
lines changed

docs/source/index.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,32 @@
11
# InferenceSDK Documentation
22

3+
## Model Description
4+
5+
::::{grid} 1 2 2 3
6+
:margin: 1 1 0 0
7+
:gutter: 1
8+
9+
:::{grid-item-card} Instance Segmentation
10+
:link: ./python/descriptions/instance_segmentation
11+
:link-type: doc
12+
[TODO]
13+
:::
14+
15+
:::{grid-item-card} Detection
16+
:link: ./python/descriptions/detection_model
17+
:link-type: doc
18+
[TODO]
19+
:::
20+
21+
:::{grid-item-card} Keypoint Detection
22+
:link: ./python/descriptions/keypoint_detection
23+
:link-type: doc
24+
[TODO]
25+
:::
26+
27+
28+
::::
29+
330
## Python API Reference
431

532
::::{grid} 1 2 2 3
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Detection Model
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Model Descriptions
2+
3+
::::{grid} 1 2 2 3
4+
:margin: 1 1 0 0
5+
:gutter: 1
6+
7+
:::{grid-item-card} Detection Model
8+
:link: ./detection_model
9+
:link-type: doc
10+
[todo]
11+
:::
12+
13+
:::{grid-item-card} Anomaly
14+
:link: ./anomaly
15+
:link-type: doc
16+
[todo]
17+
:::
18+
19+
:::{grid-item-card} Keypoint Detection
20+
:link: ./keypoint_detection
21+
:link-type: doc
22+
[todo]
23+
:::
24+
25+
:::{grid-item-card} Visual Prompting
26+
:link: ./visual_prompting
27+
:link-type: doc
28+
[todo]
29+
:::
30+
31+
:::{grid-item-card} Classification
32+
:link: ./classification
33+
:link-type: doc
34+
[todo]
35+
:::
36+
37+
:::{grid-item-card} Segmentation
38+
:link: ./segmentation
39+
:link-type: doc
40+
[todo]
41+
:::
42+
43+
:::{grid-item-card} Instance Segmentation
44+
:link: ./instance_segmentation
45+
:link-type: doc
46+
[todo]
47+
:::
48+
49+
:::{grid-item-card} Action Classification
50+
:link: ./action_classification
51+
:link-type: doc
52+
[todo]
53+
:::
54+
55+
::::
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Instance Segmentation
2+
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+
27+
## Example
28+
29+
```python
30+
import cv2
31+
from model_api.models import MaskRCNNModel
32+
33+
# Load the model
34+
model = MaskRCNNModel.create_model("model.xml")
35+
36+
# Forward pass
37+
predictions = model(image)
38+
39+
# Iterate over the segmented objects
40+
for pred_obj in predictions.segmentedObjects:
41+
pred_mask = pred_obj.mask
42+
pred_score = pred_obj.score
43+
label_id = pred_obj.id
44+
bbox = [pred_obj.xmin, pred_obj.ymin, pred_obj.xmax, pred_obj.ymax]
45+
```
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Keypoint Detection
2+
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+
```

0 commit comments

Comments
 (0)