Skip to main content

OpenVINO Model API

PyPI Downloads

Pre-Merge Test Build Docs

License OpenSSF Scorecard

Introduction

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 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

Features

  • Python API
  • Synchronous and asynchronous inference
  • Local inference and serving through the REST API
  • Model preprocessing embedding for faster inference

Installation

pip install openvino-model-api

Repository layout

This repository contains two independently installable Python subprojects:

  • model_api/ — the inference library published as openvino-model-api with a minimal runtime dependency set.
  • model_converter/ — conversion tooling published as openvino-model-converter, with conversion-time dependencies such as PyTorch, TorchVision, OpenVINO, ONNX, and NNCF.

Each subproject owns its own pyproject.toml and uv.lock. Shared repository files, including this README.md, LICENSE, CONTRIBUTING.md, SECURITY.md, and CI workflows, remain at the repository root.

Usage

from model_api.models import Model

# Create a model wrapper from a compatible model generated by OpenVINO Training Extensions
# To work with an OVMS-served model, pass its endpoint instead of a file path, e.g. "localhost:8000/v2/models/ssdlite_mobilenet_v2"
model = Model.create_model("model.xml")

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

# Print results in model-specific format
print(f"Inference result: {result}")

Prepare a model for InferenceAdapter

There are usecases when it is not possible to modify an internal ov::Model and it is hidden behind InferenceAdapter. For example the model can be served using OVMS. create_model() can construct a model from a given InferenceAdapter. That approach assumes that the model in InferenceAdapter was already configured by create_model() called with a string (a path or a model name). It is possible to prepare such model:

model = DetectionModel.create_model("~/.cache/omz/public/ssdlite_mobilenet_v2/FP16/ssdlite_mobilenet_v2.xml")
model.save("serialized.xml")

Usage with generic OpenVINO models

ModelAPI uses custom field in rt_info/model_info section of OpenVINO IR to store metadata required for preprocessing and postprocessing. If you have a generic OpenVINO model without such metadata, you can provide that metadata in configuration argument of create_model() method:

from model_api.models import Model

# Create a model wrapper from a compatible model generated by OpenVINO Training Extensions
model = Model.create_model(
    "model.xml",
    configuration={
        "model_type": "Segmentation",
        "blur_strength": 1,
        "labels": ["object"],
        "soft_threshold": 0.5,
    }
)

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

# Print results in model-specific format
print(f"Inference result: {result}")

# Save the model with metadata already embedded (passing configuration is not required anymore)
model.save("serialized_with_metadata.xml")

For more details please refer to the examples of this project.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openvino_model_api-0.4.6.tar.gz (550.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

openvino_model_api-0.4.6-py3-none-any.whl (140.6 kB view details)

Uploaded Python 3

File details

Details for the file openvino_model_api-0.4.6.tar.gz.

File metadata

  • Download URL: openvino_model_api-0.4.6.tar.gz
  • Upload date:
  • Size: 550.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for openvino_model_api-0.4.6.tar.gz
Algorithm Hash digest
SHA256 b2fdf67bd6f7bc3bef936d5472608b6f77208ab278b74a6d146f962de5690ab0
MD5 a42b51505667e3b78265849a3d6eaf15
BLAKE2b-256 afcca044a4d25f3a13a6bfd46cb07385062ddabc03f771428c6370ff72f52d5d

See more details on using hashes here.

Provenance

The following attestation bundles were made for openvino_model_api-0.4.6.tar.gz:

Publisher: publish.yaml on open-edge-platform/model_api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file openvino_model_api-0.4.6-py3-none-any.whl.

File metadata

File hashes

Hashes for openvino_model_api-0.4.6-py3-none-any.whl
Algorithm Hash digest
SHA256 5cd26931dccc89ac317e86e0b73eb53bf1d0a4bba87d5fdf80974d0e31e61259
MD5 4b954ba764e05dff1595dd2cfe3fead4
BLAKE2b-256 01765a4d84b16abfa52e35e4a779536186f00051a4ef1f17ae5d66f841f58ce4

See more details on using hashes here.

Provenance

The following attestation bundles were made for openvino_model_api-0.4.6-py3-none-any.whl:

Publisher: publish.yaml on open-edge-platform/model_api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.4.6 This release

2 files

0.4.5

2 files

0.4.3

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.3.0.4

2 files

0.3.0.3

2 files

0.3.0.2

2 files

0.3.0.1

2 files

0.3.0

2 files

0.2.6

2 files

0.2.5.4

2 files

0.2.5.3

2 files

0.2.5.2

2 files

0.2.5.1

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2.2

2 files

0.2.2.1

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.9.2

2 files

0.1.9.1

2 files

0.1.9

2 files

0.1.8

1 file

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page