Skip to content

Commit 53d7c50

Browse files
[DOCS] torchvision and optimization section (openvinotoolkit#22043)
1 parent 3bf6f11 commit 53d7c50

File tree

9 files changed

+89
-23
lines changed

9 files changed

+89
-23
lines changed

docs/articles_en/openvino_workflow/model_preparation.rst

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ Model Preparation
1515
Convert to OpenVINO Model <openvino_docs_OV_Converter_UG_prepare_model_convert_model_Convert_Model_IR>
1616
Conversion Parameters <openvino_docs_OV_Converter_UG_Conversion_Options>
1717
Setting Input Shapes <openvino_docs_OV_Converter_UG_prepare_model_convert_model_Converting_Model>
18-
PyVision preprocessing <pytorch_vision>
1918

2019

2120
You can obtain a model in one of supported formats, **PyTorch, TensorFlow, TensorFlow Lite, ONNX, and PaddlePaddle**,

docs/articles_en/openvino_workflow/model_preparation/pytorch_vision.rst

-12
This file was deleted.

docs/articles_en/openvino_workflow/running_inference_with_openvino/dldt_deployment_optimization_guide.rst

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ Optimize Inference
1313
openvino_docs_OV_UG_Precision_Control
1414
openvino_docs_deployment_optimization_guide_latency
1515
openvino_docs_deployment_optimization_guide_tput
16-
openvino_docs_deployment_optimization_guide_tput_advanced
16+
Advanced Throughput Options <openvino_docs_deployment_optimization_guide_tput_advanced>
1717
openvino_docs_OV_UG_Preprocessing_Overview
1818
openvino_docs_deployment_optimization_guide_internals
19-
openvino_docs_memory_optimization_guide
19+
Optimizing memory usage <openvino_docs_memory_optimization_guide>
20+
2021

2122
.. meta::
2223
:description: Improving inference performance involves model and runtime

docs/articles_en/openvino_workflow/running_inference_with_openvino/dldt_deployment_optimization_guide/dldt_deployment_optimization_tput.rst

+9-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,15 @@ Optimizing for Throughput
1010
simultaneously which improves the device utilization.
1111

1212

13-
As described in the section on the :doc:`latency-specific considerations <openvino_docs_deployment_optimization_guide_latency>`, one of the possible use cases is *delivering every single request at the minimal delay*.
14-
Throughput, on the other hand, is about inference scenarios in which potentially **large number of inference requests are served simultaneously to improve the device utilization**.
13+
.. toctree::
14+
:maxdepth: 1
15+
:hidden:
16+
17+
Advanced Throughput Options <openvino_docs_deployment_optimization_guide_tput_advanced>
18+
19+
20+
As described in the section on the :doc:`latency-specific optimizations <openvino_docs_deployment_optimization_guide_latency>`, one of the possible use cases is delivering every single request with minimal delay.
21+
Throughput, on the other hand, is about inference scenarios in which potentially **large numbers of inference requests are served simultaneously to improve resource use**.
1522

1623
The associated increase in latency is not linearly dependent on the number of requests executed in parallel.
1724
A trade-off between overall throughput and serial performance of individual requests can be achieved with the right performance configuration of OpenVINO.

docs/articles_en/openvino_workflow/running_inference_with_openvino/dldt_deployment_optimization_guide/dldt_deployment_optimization_tput_advanced.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
.. {#openvino_docs_deployment_optimization_guide_tput_advanced}
22
3-
Using Advanced Throughput Options: Streams and Batching
3+
Advanced Throughput Options: Streams and Batching
44
=======================================================
55

66

77
.. meta::
88
:description: With OpenVINO streams a device may handle processing multiple
99
inference requests and the batching helps to saturate the
1010
device and leads to higher throughput.
11-
11+
1212

1313
OpenVINO Streams
1414
####################

docs/articles_en/openvino_workflow/running_inference_with_openvino/dldt_deployment_optimization_guide/precision_control.rst

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ The choice of data types is essential to the inference runtime, which can have a
99
1. Model storage precision (IR precision),
1010
2. Model inference precision.
1111

12-
Previously, these 2 precisions were interrelated, and model storage precision could affect the inference precision in some devices (e.g. GPU did ``f16`` inference only for ``f16`` IRs).
13-
14-
With the ``2023.0`` release this behavior has been changed and the inference precision no longer depends on the precision of IR. Now users have several knobs to find the balance between model performance and accuracy.
12+
Inference precision no longer depends on the precision of IR, which means that users
13+
have several options to find the balance between model performance and accuracy.
1514

1615
Essentially, the IR precision becomes a way of compressing the model by reducing the precision of the weights, and it does not affect how the devices execute the model. This change clears up a lot of confusion where, for example, you couldn't execute a high-performance model on the GPU by default, and the behavior between devices was different.
1716

docs/articles_en/openvino_workflow/running_inference_with_openvino/dldt_deployment_optimization_guide/preprocessing_overview.rst

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Optimize Preprocessing
1111
openvino_docs_OV_UG_Preprocessing_Details
1212
openvino_docs_OV_UG_Layout_Overview
1313
openvino_docs_OV_UG_Preprocess_Usecase_save
14+
Torchvision preprocessing converter <torchvision_preprocessing_converter>
1415

1516
.. meta::
1617
:description: The preprocessing entails additional operations to transform
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
.. {#torchvision_preprocessing_converter}
2+
3+
Torchvision preprocessing converter
4+
=======================================
5+
6+
7+
.. meta::
8+
:description: See how OpenVINO™ enables torchvision preprocessing
9+
to optimize model inference.
10+
11+
12+
The Torchvision-to-OpenVINO converter enables automatic translation of operators from the torchvision
13+
preprocessing pipeline to the OpenVINO format and embed them in your model. It is often used to adjust
14+
images serving as input for AI models to have proper dimensions or data types.
15+
16+
As the converter is fully based on the **openvino.preprocess** module, you can implement the **torchvision.transforms**
17+
feature easily and without the use of external libraries, reducing the overall application complexity
18+
and enabling additional performance optimizations.
19+
20+
21+
.. note::
22+
23+
Not all torchvision transforms are supported yet. The following operations are available:
24+
25+
.. code-block::
26+
27+
transforms.Compose
28+
transforms.Normalize
29+
transforms.ConvertImageDtype
30+
transforms.Grayscale
31+
transforms.Pad
32+
transforms.ToTensor
33+
transforms.CenterCrop
34+
transforms.Resize
35+
36+
37+
Example
38+
###################
39+
40+
.. code-block:: py
41+
42+
preprocess_pipeline = torchvision.transforms.Compose(
43+
[
44+
torchvision.transforms.Resize(256, interpolation=transforms.InterpolationMode.NEAREST),
45+
torchvision.transforms.CenterCrop((216, 218)),
46+
torchvision.transforms.Pad((2, 3, 4, 5), fill=3),
47+
torchvision.transforms.ToTensor(),
48+
torchvision.transforms.ConvertImageDtype(torch.float32),
49+
torchvision.transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
50+
]
51+
)
52+
53+
torch_model = SimpleConvnet(input_channels=3)
54+
55+
torch.onnx.export(torch_model, torch.randn(1, 3, 224, 224), "test_convnet.onnx", verbose=False, input_names=["input"], output_names=["output"])
56+
core = Core()
57+
ov_model = core.read_model(model="test_convnet.onnx")
58+
59+
test_input = np.random.randint(255, size=(260, 260, 3), dtype=np.uint16)
60+
ov_model = PreprocessConverter.from_torchvision(
61+
model=ov_model, transform=preprocess_pipeline, input_example=Image.fromarray(test_input.astype("uint8"), "RGB")
62+
)
63+
ov_model = core.compile_model(ov_model, "CPU")
64+
ov_input = np.expand_dims(test_input, axis=0)
65+
output = ov_model.output(0)
66+
ov_result = ov_model(ov_input)[output]
67+
68+
69+
70+
71+

docs/dev/get_started.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ Explore other resources to learn more about OpenVINO:
1818
* [OpenVINO Developer Documentation](./index.md)
1919
* [OpenVINO Samples](../../samples)
2020
* [OpenVINO Building Documentation](./building_documentation.md)
21-
* [CMake Options for Custom Compilation](./cmake_options_for_custom_comiplation.md)
21+
* [CMake Options for Custom Compilation](./cmake_options_for_custom_compilation.md)

0 commit comments

Comments
 (0)