|
1 | 1 | # Keypoint Detection |
2 | 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 | +``` |
| 52 | + |
3 | 53 | ```{eval-rst} |
4 | 54 | .. automodule:: model_api.models.keypoint_detection |
5 | 55 | :members: |
|
0 commit comments