[Docs][PyOV] update python snippets (#19367)

* [Docs][PyOV] update python snippets

* first snippet

* Fix samples debug

* Fix linter

* part1

* Fix speech sample

* update model state snippet

* add serialize

* add temp dir

* CPU snippets update (#134)

* snippets CPU 1/6

* snippets CPU 2/6

* snippets CPU 3/6

* snippets CPU 4/6

* snippets CPU 5/6

* snippets CPU 6/6

* make  module TODO: REMEMBER ABOUT EXPORTING PYTONPATH ON CIs ETC

* Add static model creation in snippets for CPU

* export_comp_model done

* leftovers

* apply comments

* apply comments -- properties

* small fixes

* rempve debug info

* return IENetwork instead of Function

* apply comments

* revert precision change in common snippets

* update opset

* [PyOV] Edit docs for the rest of plugins (#136)

* modify main.py

* GNA snippets

* GPU snippets

* AUTO snippets

* MULTI snippets

* HETERO snippets

* Added properties

* update gna

* more samples

* Update docs/OV_Runtime_UG/model_state_intro.md

* Update docs/OV_Runtime_UG/model_state_intro.md

* attempt1 fix ci

* new approach to test

* temporary remove some files from run

* revert cmake changes

* fix ci

* fix snippet

* fix py_exclusive snippet

* fix preprocessing snippet

* clean-up main

* remove numpy installation in gha

* check for GPU

* add logger

* iexclude main

* main update

* temp

* Temp2

* Temp2

* temp

* Revert temp

* add property execution devices

* hide output from samples

---------

Co-authored-by: p-wysocki <przemyslaw.wysocki@intel.com>
Co-authored-by: Jan Iwaszkiewicz <jan.iwaszkiewicz@intel.com>
Co-authored-by: Karol Blaszczak <karol.blaszczak@intel.com>
This commit is contained in:
authored and GitHub committed 2023-09-13 21:05:24 +02:00
1 parent 4f92676c85
commit 2bf8d910f6
68 files changed
+1223 -892

No files matched your search

+9 -10
View File
@@ -9,8 +9,7 @@ from timeit import default_timer
from typing import Dict
import numpy as np
from openvino.preprocess import PrePostProcessor
from openvino.runtime import Core, InferRequest, Layout, Type, set_batch
import openvino as ov
from arg_parser import parse_args
from file_options import read_utterance_file, write_utterance_file
@@ -20,7 +19,7 @@ from utils import (GNA_ATOM_FREQUENCY, GNA_CORE_FREQUENCY,
set_scale_factors)
def do_inference(data: Dict[str, np.ndarray], infer_request: InferRequest, cw_l: int = 0, cw_r: int = 0) -> np.ndarray:
def do_inference(data: Dict[str, np.ndarray], infer_request: ov.InferRequest, cw_l: int = 0, cw_r: int = 0) -> np.ndarray:
"""Do a synchronous matrix inference."""
frames_to_infer = {}
result = {}
@@ -69,7 +68,7 @@ def main():
# --------------------------- Step 1. Initialize OpenVINO Runtime Core ------------------------------------------------
log.info('Creating OpenVINO Runtime Core')
core = Core()
core = ov.Core()
# --------------------------- Step 2. Read a model --------------------------------------------------------------------
if args.model:
@@ -83,19 +82,19 @@ def main():
if args.layout:
layouts = get_input_layouts(args.layout, model.inputs)
ppp = PrePostProcessor(model)
ppp = ov.preprocess.PrePostProcessor(model)
for i in range(len(model.inputs)):
ppp.input(i).tensor().set_element_type(Type.f32)
ppp.input(i).tensor().set_element_type(ov.Type.f32)
input_name = model.input(i).get_any_name()
if args.layout and input_name in layouts.keys():
ppp.input(i).tensor().set_layout(Layout(layouts[input_name]))
ppp.input(i).model().set_layout(Layout(layouts[input_name]))
ppp.input(i).tensor().set_layout(ov.Layout(layouts[input_name]))
ppp.input(i).model().set_layout(ov.Layout(layouts[input_name]))
for i in range(len(model.outputs)):
ppp.output(i).tensor().set_element_type(Type.f32)
ppp.output(i).tensor().set_element_type(ov.Type.f32)
model = ppp.build()
@@ -103,7 +102,7 @@ def main():
batch_size = args.batch_size if args.context_window_left == args.context_window_right == 0 else 1
if any((not _input.node.layout.empty for _input in model.inputs)):
set_batch(model, batch_size)
ov.set_batch(model, batch_size)
else:
log.warning('Layout is not set for any input, so custom batch size is not set')