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

Python Model API package: add main documentation #3268

Merged
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
853599a
add documentation to Model API
anzhella-pankratova Feb 18, 2022
cb9aabe
add readme.md
anzhella-pankratova Feb 18, 2022
e88ecb8
fix spelling
anzhella-pankratova Feb 21, 2022
70cf732
add Model API section to object_detection_demo readme
anzhella-pankratova Feb 21, 2022
94ffd56
remove extra whitespace
anzhella-pankratova Feb 21, 2022
71c9f9a
add bullet points
anzhella-pankratova Feb 21, 2022
e1320e4
Apply suggestions
anzhella-pankratova Feb 21, 2022
d581e16
modify the usage example
anzhella-pankratova Feb 21, 2022
c6bd178
Modify documentation
anzhella-pankratova Feb 22, 2022
b5739fd
add extra module
anzhella-pankratova Feb 24, 2022
8701286
don't check relative links for Model API package
anzhella-pankratova Feb 24, 2022
8cca162
update check-documentation.py
anzhella-pankratova Feb 24, 2022
4b5d7fa
prepare-documentation for Python Model API
anzhella-pankratova Feb 24, 2022
325e4bf
suggestions
anzhella-pankratova Feb 25, 2022
29d247b
move the list of supported demos to demos/README.md
anzhella-pankratova Feb 25, 2022
36eb8a9
remove list of demos, remove statement in documentation
anzhella-pankratova Feb 28, 2022
41398d2
add documentation to Model API
anzhella-pankratova Feb 18, 2022
94d3976
add readme.md
anzhella-pankratova Feb 18, 2022
3ec58fc
fix spelling
anzhella-pankratova Feb 21, 2022
6ff38da
add Model API section to object_detection_demo readme
anzhella-pankratova Feb 21, 2022
0b5e278
remove extra whitespace
anzhella-pankratova Feb 21, 2022
a0ac903
add bullet points
anzhella-pankratova Feb 21, 2022
3951fb2
Apply suggestions
anzhella-pankratova Feb 21, 2022
a78852d
modify the usage example
anzhella-pankratova Feb 21, 2022
6a8144a
Modify documentation
anzhella-pankratova Feb 22, 2022
31bf4d7
add extra module
anzhella-pankratova Feb 24, 2022
f543d57
don't check relative links for Model API package
anzhella-pankratova Feb 24, 2022
a4adf83
update check-documentation.py
anzhella-pankratova Feb 24, 2022
ee53da8
prepare-documentation for Python Model API
anzhella-pankratova Feb 24, 2022
ede0f45
suggestions
anzhella-pankratova Feb 25, 2022
19872b1
move the list of supported demos to demos/README.md
anzhella-pankratova Feb 25, 2022
384c1d9
remove list of demos, remove statement in documentation
anzhella-pankratova Feb 28, 2022
e1217b4
OMZ models instead of architectures, OV supported Python instead cert…
vladimir-dudnik Mar 1, 2022
52ed496
pull recent changes
anzhella-pankratova Mar 2, 2022
06d0e99
remove python in documentation, update package structure section
anzhella-pankratova Mar 2, 2022
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
Prev Previous commit
Next Next commit
Modify documentation
  • Loading branch information
anzhella-pankratova authored and vladimir-dudnik committed Mar 1, 2022
commit 6a8144a398d900ea0d2fe5638c1f5d1012c9241c
36 changes: 18 additions & 18 deletions demos/common/python/openvino/model_zoo/model_api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ python -c "from openvino.model_zoo import model_api"

## Model API Wrappers

The Python* Model API package suggests ready-to-use model wrappers, which implement standardized preprocessing/postprocessing functions per "task type" and might be reused in applications as "black-box" models.
Also, the simple wrapper interface allows the creation of custom wrappers covering different architectures.
The Python* Model API package suggests ready-to-use model wrappers, which implement standardized preprocessing/postprocessing functions per "task type" and incapsulate model-specific logic for usage of different models in a unified manner inside the application.
Wovchena marked this conversation as resolved.
Show resolved Hide resolved

The wrapper interface is simple and flexible, which gives capabilities for the creation of custom wrappers covering different architectures and use cases.

The following tasks can be solved with wrappers usage:

Expand Down Expand Up @@ -91,7 +92,7 @@ Refer to __[`OVMSAdapter`](adapters/ovms_adapter.md)__ to learn about running de

For OpenVINO Model Server Adapter employment, you need to install the requirements:
```sh
pip install <omz_dir>/demos/common/python/requirements_ovms.txt
pip install -r <omz_dir>/demos/common/python/requirements_ovms.txt
```

## Model API Pipelines
Expand All @@ -105,13 +106,15 @@ The `AsyncPipeline` is available, which handles the asynchronous execution of a

To apply Model API wrappers in custom applications, learn the provided example of common scenario of how to use Python* Model API.

In the example, the SSD architecture is used to predict bounding boxes on input image `"sample.png"`. The model execution is produced by `OpenvinoAdapter`, therefore we submit the path to the model's `xml` file. The model is loaded on a CPU device inside the adapter.
In the example, the SSD architecture is used to predict bounding boxes on input image `"sample.png"`. The model execution is produced by `OpenvinoAdapter`, therefore we submit the path to the model's `xml` file.
ivikhrev marked this conversation as resolved.
Show resolved Hide resolved

Once the SSD model wrapper instance is created, we get the predictions by the model in one line: `ssd_model(input_data)` - the wrapper performs the preprocess method, synchronous inference on OpenVINO™ toolkit side and postprocess method.

```python
import cv2
# import model wrapper class
from openvino.model_zoo.model_api.models import SSD
anzhella-pankratova marked this conversation as resolved.
Show resolved Hide resolved
# import inference adapter and helper for runtime setup
from openvino.model_zoo.model_api.adapters import OpenvinoAdapter, create_core
anzhella-pankratova marked this conversation as resolved.
Show resolved Hide resolved


Expand All @@ -125,26 +128,23 @@ model_path = "public/mobilenet-ssd/FP32/mobilenet-ssd.xml"
model_adapter = OpenvinoAdapter(create_core(), model_path, device="CPU")

# create model API wrapper for SSD architecture
# preload=True loads the model on CPU inside the adapter
ssd_model = SSD(model_adapter, preload=True)
eaidova marked this conversation as resolved.
Show resolved Hide resolved

# apply input preprocessing, sync inference, model output postprocessing
results = ssd_model(input_data)

# visualize results and show it
image_with_bboxes = draw_detections(input_data, results)
cv2.imshow('Detection Results', image_with_bboxes)
```
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We won't ever verify the snippet works. To me it's the strong reason to delete it. You should refer to a demo instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the majority prefers to delete it, I will do it

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not about voting.

  1. This is about explaining why your solution is correct.
  2. Even if you insist on conducting a poll, your voice won't count. My voice won't count either. Only the voice of the person who is responsible for OMZ matters. Which is @vladimir-dudnik's one

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My point is the demos contain only complex cases with asynchronous models execution, it is not the only one usage scenario. We should provide somewhere the example of simple synchronous model call.

Didn't get point about the snippet work verification. Many packages have a documentation with API examples. The package is going to be updated with new releases, and with the new releases the documentation will be also updated as well as the snippet.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can write a dedicated sample and refer to it. You will anyway need to cover your lib with tests. The sample could be a part of tests.

Didn't get point about the snippet work verification. Many packages have a documentation with API examples. The package is going to be updated with new releases, and with the new releases the documentation will be also updated as well as the snippet.

Such packages have people whos work to continuously check the example is consistent. We don't have such people. If packages don't do that, they usually end up having broken examples.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the solution. Keep this section, but remove it after tests are added

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay


To study the complex scenarios, refer to [Open Model Zoo Python* demos](https://github.com/openvinotoolkit/open_model_zoo/tree/master/demos), where the asynchronous inference is applied.

The list of Open Model Zoo demos with Model API support:
- BERT Named Entity Recognition Python* Demo
- BERT Question Answering Python* Demo
- BERT Question Answering Embedding Python* Demo
- Classification Python* Demo
- Image Deblurring Python* Demo
- Human Pose Estimation Python* Demo
- Instance Segmentation Python* Demo
- MonoDepth Python* Demo
- Object Detection Python* Demo
- Image Segmentation Python* Demo
- [BERT Named Entity Recognition Python* Demo](https://github.com/openvinotoolkit/open_model_zoo/tree/master/demos/bert_named_entity_recognition_demo/python)
- [BERT Question Answering Python* Demo](https://github.com/openvinotoolkit/open_model_zoo/tree/master/demos/bert_question_answering_demo/python)
- [BERT Question Answering Embedding Python* Demo](https://github.com/openvinotoolkit/open_model_zoo/tree/master/demos/bert_question_answering_embedding_demo/python)
- [Classification Python* Demo](https://github.com/openvinotoolkit/open_model_zoo/tree/master/demos/classification_demo/python)
- [Image Deblurring Python* Demo](https://github.com/openvinotoolkit/open_model_zoo/tree/master/demos/deblurring_demo/python)
- [Human Pose Estimation Python* Demo](https://github.com/openvinotoolkit/open_model_zoo/tree/master/demos/human_pose_estimation_demo/python)
- [Instance Segmentation Python* Demo](https://github.com/openvinotoolkit/open_model_zoo/tree/master/demos/instance_segmentation_demo/python)
- [MonoDepth Python* Demo](https://github.com/openvinotoolkit/open_model_zoo/tree/master/demos/monodepth_demo/python)
- [Object Detection Python* Demo](https://github.com/openvinotoolkit/open_model_zoo/tree/master/demos/object_detection_demo/python)
- [Image Segmentation Python* Demo](https://github.com/openvinotoolkit/open_model_zoo/tree/master/demos/segmentation_demo/python)
Wovchena marked this conversation as resolved.
Show resolved Hide resolved