From 5ee4090e100380dfdbdf4a736d4a5eaa9f812210 Mon Sep 17 00:00:00 2001 From: Karol Blaszczak Date: Wed, 8 Nov 2023 11:12:01 +0100 Subject: [PATCH] [DOCS] improving the "conversion" section v2 (#20904) adjustments to conversion and workflow --- .../ov_workflow_diagram_convenience.svg | 3 ++ .../ov_workflow_diagram_performance.svg | 3 ++ docs/articles_en/openvino_workflow.md | 43 +++++++++++------ .../openvino_workflow/model_preparation.md | 46 ++++++++++--------- 4 files changed, 61 insertions(+), 34 deletions(-) create mode 100644 docs/_static/images/ov_workflow_diagram_convenience.svg create mode 100644 docs/_static/images/ov_workflow_diagram_performance.svg diff --git a/docs/_static/images/ov_workflow_diagram_convenience.svg b/docs/_static/images/ov_workflow_diagram_convenience.svg new file mode 100644 index 00000000000..50867b24996 --- /dev/null +++ b/docs/_static/images/ov_workflow_diagram_convenience.svg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bbc2855ac007644a2562362bc7a8786c93b3d1d3e96ba733eec9a6c03f63a8c9 +size 160830 diff --git a/docs/_static/images/ov_workflow_diagram_performance.svg b/docs/_static/images/ov_workflow_diagram_performance.svg new file mode 100644 index 00000000000..1af57d3d1ab --- /dev/null +++ b/docs/_static/images/ov_workflow_diagram_performance.svg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a013860e4b2f942c5632bae8e3dfade266cfdcad2e34f6371ea8b1873e18f75b +size 178797 diff --git a/docs/articles_en/openvino_workflow.md b/docs/articles_en/openvino_workflow.md index 5453c03426c..9b2f75991ee 100644 --- a/docs/articles_en/openvino_workflow.md +++ b/docs/articles_en/openvino_workflow.md @@ -20,36 +20,53 @@ pytorch_2_0_torch_compile -.. image:: ./_static/images/model_conversion_diagram.svg - :alt: model conversion diagram - OpenVINO offers multiple workflows, depending on the use case and personal or project preferences. -The diagram above is only a rough representation of the available options, but this section will -give you a detailed view of how you can go from preparing your model, through optimizing it, -to executing inference, and deploying your solution. +This section will give you a detailed view of how you can go from preparing your model, +through optimizing it, to executing inference, and deploying your solution. + +Once you obtain a model in one of the :doc:`supported model formats `, +you can decide how to proceed: + +.. tab-set:: + + .. tab-item:: Workflow for convenience + + This approach assumes you run your model directly. + + .. image:: _static/images/ov_workflow_diagram_convenience.svg + :align: center + :alt: OpenVINO workflow diagram for convenience + + .. tab-item:: Workflow for performance (recommended for production) + + This approach assumes you convert your model to OpenVINO IR explicitly, which means the + conversion stage is not part of the final application. + + .. image:: _static/images/ov_workflow_diagram_performance.svg + :align: center + :alt: OpenVINO workflow diagram for performance + | :doc:`Model Preparation ` -| Learn how to convert pre-trained models to OpenVINO IR, using different approaches for more convenience or higher performance. - +| Learn how to convert pre-trained models to OpenVINO IR. | :doc:`Model Optimization and Compression ` -| Find out how to optimize a model to achieve better inference performance, utilizing multiple optimization methods for both in-training compression and post-training quantization. - +| Find out how to optimize a model to achieve better inference performance, utilizing + multiple optimization methods for both in-training compression and post-training quantization. | :doc:`Running Inference ` -| See how to run inference with OpenVINO, which is the most basic form of deployment, and the quickest way of running a deep learning model. +| See how to run inference with OpenVINO, which is the most basic form of deployment, + and the quickest way of running a deep learning model. | :doc:`Deployment Option 1. Using OpenVINO Runtime ` | Deploy a model locally, reading the file directly from your application and utilizing resources available to the system. | Deployment on a local system uses the steps described in the section on running inference. - | :doc:`Deployment Option 2. Using Model Server ` | Deploy a model remotely, connecting your application to an inference server and utilizing external resources, with no impact on the app's performance. | Deployment on OpenVINO Model Server is quick and does not require any additional steps described in the section on running inference. - | :doc:`Deployment Option 3. Using torch.compile for PyTorch 2.0 ` | Deploy a PyTorch model using OpenVINO in a PyTorch-native application. diff --git a/docs/articles_en/openvino_workflow/model_preparation.md b/docs/articles_en/openvino_workflow/model_preparation.md index 0dabb7c5cbd..d30121850e9 100644 --- a/docs/articles_en/openvino_workflow/model_preparation.md +++ b/docs/articles_en/openvino_workflow/model_preparation.md @@ -10,7 +10,6 @@ :maxdepth: 1 :hidden: - Conversion Parameters Setting Input Shapes Convert from PyTorch @@ -21,26 +20,29 @@ Supported_Model_Formats -To start working with OpenVINO, you need to obtain a model in one of the -:doc:`supported model formats `. The easiest way -to do so is to download a pre-trained network from an online database, such as -`TensorFlow Hub `__, -`Hugging Face `__, or -`Torchvision models `__. +You can obtain a model in one of :doc:`supported formats ` +in many ways. The easiest one is to download it from an online database, +such as `TensorFlow Hub `__, `Hugging Face `__, +and `Torchvision models `__. Now you have two options: -The OpenVINO workflow starts with converting the selected model to its -proprietary format, :doc:`OpenVINO IR ` -(`openvino.Model `__ - -`ov.Model `__). -Although in most cases it can be done automatically, under the hood, explicit -conversion may enable more optimization options and better performance. -It is done in one of two ways: +* Skip model conversion and run inference directly from the source format. Conversion + will still be performed but it will happen automatically and "under the hood." + This option, while convenient, offers lower performance and stability, as well as + fewer optimization options. -* the Python API functions (``openvino.convert_model`` and ``openvino.save_model``) -* the ``ovc`` command line tool. +* Explicitly convert the model to :doc:`OpenVINO IR `. + This approach offers the best possible results and is the recommended one, + especially for for production-ready solutions. Explicit conversion can be done in two ways: + + * the Python API functions (``openvino.convert_model`` and ``openvino.save_model``) + * the ``ovc`` command line tool. + + Once saved as :doc:`OpenVINO IR ` (a set of ``.xml`` and ``.bin`` files), + the model may be deployed with maximum performance. Because it is already optimized + for OpenVINO inference, it can be read, compiled, and inferred with no additional delay. .. note:: - + Model conversion API prior to OpenVINO 2023.1 is considered deprecated. Existing and new projects are recommended to transition to the new solutions, keeping in mind that they are not fully backwards compatible @@ -48,13 +50,15 @@ It is done in one of two ways: For more details, see the :doc:`Model Conversion API Transition Guide `. -Convert a Model in Python: ``convert_model`` +Convert a Model with Python: ``convert_model`` ############################################## The Model conversion API in Python uses the ``openvino.convert_model`` function, -turning a given model to the ``openvino.Model`` object. The object may be used -further, compiled and inferred, or saved to a drive as :doc:`OpenVINO IR ` -(``openvino.save_model`` produces a set of ``.xml`` and ``.bin`` files). +turning a given model into the `openvino.Model `__ +object and loading it to memory. Now it can be: saved to a drive with `openvino.save_model`` +or further :doc:`optimized with NNCF ` +prior to saving. + See how to use ``openvino.convert_model`` with models from some of the most popular public repositories: