Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move to newer OMZ #163

Merged
merged 9 commits into from
Feb 28, 2024
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
4 changes: 1 addition & 3 deletions .github/workflows/test_precommit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,8 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-20.04, ubuntu-22.04, macos-12]
python-version: [3.7, 3.8, 3.9, '3.10', '3.11']
python-version: [3.8, 3.9, '3.10', '3.11']
exclude:
- os: macos-12
python-version: 3.7
- os: macos-12
python-version: 3.9
- os: macos-12
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ Model API searches for additional information required for model inference, data
from openvino.model_api.models import DetectionModel

# Create a model (downloaded and cached automatically for OpenVINO Model Zoo models)
# Use URL to work with served model, e.g. "localhost:9000/models/ssd300"
ssd = DetectionModel.create_model("ssd300")
# Use URL to work with served model, e.g. "localhost:9000/models/ssdlite_mobilenet_v2"
ssd = DetectionModel.create_model("ssdlite_mobilenet_v2")

# Run synchronous inference locally
detections = ssd(image) # image is numpy.ndarray
Expand All @@ -63,7 +63,7 @@ print(f"Detection results: {detections}")
#include <models/results.h>

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

// Run synchronous inference locally
auto result = model->infer(image); // image is cv::Mat
Expand All @@ -81,13 +81,13 @@ Model's static method `create_model()` has two overloads. One constructs the mod
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](https://github.com/openvinotoolkit/model_server). `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 using C++ or Python:
C++
```Cpp
auto model = DetectionModel::create_model("~/.cache/omz/public/ssd300/FP16/ssd300.xml");
auto model = DetectionModel::create_model("~/.cache/omz/public/ssdlite_mobilenet_v2/FP16/ssdlite_mobilenet_v2.xml");
const std::shared_ptr<ov::Model>& ov_model = model->getModel();
ov::serialize(ov_model, "serialized.xml");
```
Python
```python
model = DetectionModel.create_model("~/.cache/omz/public/ssd300/FP16/ssd300.xml")
model = DetectionModel.create_model("~/.cache/omz/public/ssdlite_mobilenet_v2/FP16/ssdlite_mobilenet_v2.xml")
model.save("serialized.xml")
```
After that the model can be constructed from `InferenceAdapter`:
Expand All @@ -107,7 +107,7 @@ For more details please refer to the [examples](https://github.com/openvinotoolk
- [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. "ssd300", "ssdlite_mobilenet_v2", etc.)
- SSD-based models (e.g. "ssdlite_mobilenet_v2", etc.)
- YOLO-based models (e.g. "yolov3", "yolov4", etc.)
- CTPN: "ctpn"
- DETR: "detr-resnet50"
Expand All @@ -127,7 +127,7 @@ For more details please refer to the [examples](https://github.com/openvinotoolk
- 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. "ssd300", "ssdlite_mobilenet_v2", etc.)
- 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"
Expand Down
1 change: 0 additions & 1 deletion examples/python/synchronous_api/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import sys

import cv2
import openvino.runtime as ov
from openvino.model_api.models import (
ClassificationModel,
DetectionModel,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def __init__(
self.model = core.read_model(self.model_path, weights_path)
return
if isinstance(model, str):
from openvino.model_zoo.models import OMZModel, list_models
from omz_tools.models import OMZModel, list_models

if model in list_models():
omz_model = OMZModel.download(
Expand Down
4 changes: 3 additions & 1 deletion model_api/python/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
numpy>=1.16.6
opencv-python
scipy>=1.5.4
openvino>=2023.0.0
# TODO: set 2024.0 after the release
openvino>=2023.3
openvino-dev>=2023.0.0
sovrasov marked this conversation as resolved.
Show resolved Hide resolved
omz_tools @ git+https://github.com/openvinotoolkit/open_model_zoo.git@master#egg=omz_tools&subdirectory=tools/model_tools
4 changes: 0 additions & 4 deletions tests/cpp/precommit/public_scope.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
[
{
"name": "ssd300",
"type": "DetectionModel"
},
{
"name": "ssd_mobilenet_v1_fpn_coco",
"type": "DetectionModel"
Expand Down
14 changes: 2 additions & 12 deletions tests/python/accuracy/public_scope.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,6 @@
}
]
},
{
"name": "ssd300",
"type": "DetectionModel",
"test_data": [
{
"image": "coco128/images/train2017/000000000074.jpg",
"reference": ["0, 13, 169, 338, 2 (bicycle): 0.870; 58, 275, 360, 384, 12 (dog): 0.998; 324, 98, 344, 148, 15 (person): 0.652; [0]; [0]"]
}
]
},
{
"name": "ssd_mobilenet_v1_fpn_coco",
"type": "DetectionModel",
Expand Down Expand Up @@ -142,12 +132,12 @@
]
},
{
"name": "se-resnext-50",
"name": "mobilenet-v3-large-1.0-224-tf",
"type": "ClassificationModel",
"test_data": [
{
"image": "coco128/images/train2017/000000000074.jpg",
"reference": ["175 (Labrador_retriever): 0.616, [0], [0], [0]"]
"reference": ["208 (Labrador_retriever): 0.166, [0], [0], [0]"]
}
]
},
Expand Down
3 changes: 2 additions & 1 deletion tests/python/precommit/test_save.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

def test_detector_save(tmp_path):
downloaded = Model.create_model(
"ssd300", configuration={"mean_values": [0, 0, 0], "confidence_threshold": 0.6}
"ssd_mobilenet_v1_fpn_coco",
configuration={"mean_values": [0, 0, 0], "confidence_threshold": 0.6},
)
assert True == downloaded.get_model().get_rt_info(
["model_info", "embedded_processing"]
Expand Down
Loading