Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 33 additions & 62 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
# OpenVINO Model API

Model API is a set of wrapper classes for particular tasks and model architectures, simplifying data preprocess and postprocess as well as routine procedures (model loading, asynchronous execution, etc.). It is aimed at simplifying end-to-end model inference for different deployment scenarious, including local execution and serving. The Model API is based on the OpenVINO inference API.
Model API is a set of wrapper classes for particular tasks and model architectures, simplifying data preprocess and postprocess as well as routine procedures (model loading, asynchronous execution, etc.). It is aimed at simplifying end-to-end model inference for different deployment scenarios, including local execution and serving. The Model API is based on the OpenVINO inference API.

## How it works

Model API searches for additional information required for model inference, data, pre/postprocessing, label names, etc. directly in OpenVINO Intermediate Representation. This information is used to prepare the inference data, process and output the inference results in a human-readable format.

Currently, ModelAPI supports models trained in [OpenVINO Training Extensions](https://github.com/openvinotoolkit/training_extensions) framework.
Training Extensions embed all the metadata required for inference into model file. For models coming from other than Training Extensions frameworks metadata generation step is required before using ModelAPI.

## Supported model formats

- [OpenVINO IR](https://docs.openvino.ai/2025/documentation/openvino-ir-format.html)
- [ONNX](https://onnx.ai)

## Features

- Python and C++ API
- Automatic prefetch of public models from [OpenVINO Model Zoo](https://github.com/openvinotoolkit/open_model_zoo) (Python only)
- Synchronous and asynchronous inference
- Local inference and serving through the rest API (Python only)
- Model preprocessing embedding for faster inference
Expand All @@ -18,17 +25,15 @@ Model API searches for additional information required for model inference, data

### Python

- Clone this repository
- Navigate to `model_api/python` folder
- Run `pip install .`
`pip install openvino-model-api`

### C++

- Install dependencies. For installation on Ubuntu, you can use the following script:

```bash
chmod +x model_api/cpp/install_dependencies.sh
sudo model_api/cpp/install_dependencies.sh
chmod +x src/cpp/install_dependencies.sh
sudo src/cpp/install_dependencies.sh
```

- Build library:
Expand All @@ -45,44 +50,48 @@ Model API searches for additional information required for model inference, data
cmake ../model_api/cpp -DOpenCV_DIR=<OpenCV cmake dir> -DOpenVINO_DIR=<OpenVINO cmake dir>
```

- Build:
`OpenCV` and `OpenVINO` locations are optional. In most cases, system these dependencies are discovered by cmake without extra guidance.

```bash
cmake --build . -j
```
- Build:

- To build a `.tar.gz` package with the library, run:
```bash
cmake --build . -j
```

```bash
cmake --build . --target package -j
```
- To build a `.tar.gz` package with the library, run:

```bash
cmake --build . --target package -j
```

## Usage

### Python

```python
from model_api.models import DetectionModel
from model_api.models import Model

# Create a model (downloaded and cached automatically for OpenVINO Model Zoo models)
# Use URL to work with served model, e.g. "localhost:9000/models/ssdlite_mobilenet_v2"
ssd = DetectionModel.create_model("ssdlite_mobilenet_v2")
# Create a model wrapper from a compatible model generated by OpenVINO Training Extensions
# Use URL to work with OVMS-served model, e.g. "localhost:9000/models/ssdlite_mobilenet_v2"
model = Model.create_model("model.xml")

# Run synchronous inference locally
detections = ssd(image) # image is numpy.ndarray
result = model(image) # image is numpy.ndarray

# Print the list of Detection objects with box coordinates, confidence and label string
print(f"Detection results: {detections}")
# Print results in model-specific format
print(f"Inference result: {result}")
```

### C++

In C++ we have to specify model type in advance, let's set it to detection model.

```cpp
#include <models/detection_model.h>
#include <models/results.h>

// Load the model fetched using Python API
auto model = DetectionModel::create_model("~/.cache/omz/public/ssdlite_mobilenet_v2/FP16/ssdlite_mobilenet_v2.xml");
// Load the model
auto model = Model::create_model("model.xml");

// Run synchronous inference locally
auto result = model->infer(image); // image is cv::Mat
Expand Down Expand Up @@ -125,41 +134,3 @@ auto model = DetectionModel::create_model(adapter);
```

For more details please refer to the [examples](https://github.com/openvinotoolkit/model_api/tree/master/examples) of this project.

## Supported models

### Python

- Image Classification:
- [OpenVINO Model Zoo models](https://github.com/openvinotoolkit/open_model_zoo/blob/master/models/public/index.md#classification-models)
- Object Detection:
- [OpenVINO Model Zoo models](https://github.com/openvinotoolkit/open_model_zoo/blob/master/models/public/index.md#object-detection-models):
- SSD-based models (e.g. "ssdlite_mobilenet_v2", etc.)
- YOLO-based models (e.g. "yolov3", "yolov4", etc.)
- CTPN: "ctpn"
- DETR: "detr-resnet50"
- CenterNet: "ctdet_coco_dlav0_512"
- FaceBoxes: "faceboxes-pytorch"
- RetinaFace: "retinaface-resnet50-pytorch"
- Ultra Lightweight Face Detection: "ultra-lightweight-face-detection-rfb-320" and "ultra-lightweight-face-detection-slim-320"
- NanoDet with ShuffleNetV2: "nanodet-m-1.5x-416"
- NanoDet Plus with ShuffleNetV2: "nanodet-plus-m-1.5x-416"
- Semantic Segmentation:
- [OpenVINO Model Zoo models](https://github.com/openvinotoolkit/open_model_zoo/blob/master/models/public/index.md#semantic-segmentation-models)
- Instance Segmentation:
- [OpenVINO Model Zoo models](https://github.com/openvinotoolkit/open_model_zoo/blob/master/models/public/index.md#instance-segmentation-models)

### C++

- Image Classification:
- [OpenVINO Model Zoo models](https://github.com/openvinotoolkit/open_model_zoo/blob/master/models/public/index.md#classification-models)
- Object Detection:
- SSD-based models (e.g. "ssdlite_mobilenet_v2", etc.)
- YOLO-based models (e.g. "yolov3", "yolov4", etc.)
- CenterNet: "ctdet_coco_dlav0_512"
- FaceBoxes: "faceboxes-pytorch"
- RetinaFace: "retinaface-resnet50-pytorch"
- Semantic Segmentation:
- [OpenVINO Model Zoo models](https://github.com/openvinotoolkit/open_model_zoo/blob/master/models/public/index.md#semantic-segmentation-models)

[Model configuration](https://github.com/openvinotoolkit/model_api/blob/master/docs/model-configuration.md) discusses possible configurations.
10 changes: 5 additions & 5 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
from pathlib import Path

# Define the path to your module using Path
module_path = Path(__file__).parent.parent / "model_api" / "python"
module_path = Path(__file__).parent.parent / "src" / "python"

# Insert the path to sys.path
sys.path.insert(0, str(module_path.resolve()))

project = "InferenceSDK"
copyright = "2024, Intel OpenVINO"
author = "Intel OpenVINO"
release = "2024"
project = "ModelAPI"
copyright = "2025, Intel"
author = "Intel"
release = "2025"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
2 changes: 1 addition & 1 deletion docs/source/cpp/models/anomaly_model.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Anomaly Model

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).
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/open-edge-platform/anomalib).

Currently, the `AnomalyModel` supports the following models:

Expand Down
2 changes: 1 addition & 1 deletion docs/source/python/models/anomaly.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Anomaly

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).
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/open-edge-platform/anomalib).

Currently, the `AnomalyModel` supports the following models:

Expand Down
4 changes: 2 additions & 2 deletions src/python/docs/visual_prompting.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,5 @@ Decoder OV model should have the following named inputs:

## How to use

See demos: [VPT](https://github.com/openvinotoolkit/model_api/tree/master/examples/python/visual_prompting)
and [ZSL-VPT](https://github.com/openvinotoolkit/model_api/tree/master/examples/python/zsl_visual_prompting)
See demos: [VPT](https://github.com/open-edge-platform/model_api/tree/master/examples/python/visual_prompting)
and [ZSL-VPT](https://github.com/open-edge-platform/model_api/tree/master/examples/python/zsl_visual_prompting)
6 changes: 3 additions & 3 deletions src/python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ build = [
full = ["openvino_model_api[dependencies, ovms, tests, docs, build]"]

[project.urls]
Homepage = "https://github.com/openvinotoolkit/model_api"
Documentation = "https://github.com/openvinotoolkit/model_api/blob/master/README.md"
Repository = "https://github.com/openvinotoolkit/model_api.git"
Homepage = "https://github.com/open-edge-platform/model_api"
Documentation = "https://github.com/open-edge-platform/model_api/blob/master/README.md"
Repository = "https://github.com/open-edge-platform/model_api.git"

[tool.setuptools.packages.find]
include = ["model_api*"]
Expand Down