Esempio n. 1
0
# SPDX-License-Identifier: Apache-2.0

import numpy as np
import os
import pytest
import warnings
import threading
from datetime import datetime
import time

from openvino.inference_engine import ie_api as ie
from conftest import model_path, image_path

is_myriad = os.environ.get("TEST_DEVICE") == "MYRIAD"
test_net_xml, test_net_bin = model_path(is_myriad)
path_to_img = image_path()


def create_function_with_memory(input_shape, data_type):
    from ngraph.impl import Function, Type
    import ngraph as ng
    input_data = ng.parameter(input_shape, name="input_data", dtype=data_type)
    rv = ng.read_value(input_data, "var_id_667")
    add = ng.add(rv, input_data, name="MemoryAdd")
    node = ng.assign(add, "var_id_667")
    res = ng.result(add, "res")
    func = Function(results=[res],
                    sinks=[node],
                    parameters=[input_data],
                    name="name")
    caps = Function.to_capsule(func)
Esempio n. 2
0
import numpy as np
import os
import pytest
import warnings

from openvino.inference_engine import ie_api as ie
from conftest import model_path, image_path


is_myriad = os.environ.get("TEST_DEVICE") == "MYRIAD"
path_to_image = image_path()
test_net_xml, test_net_bin = model_path(is_myriad)


def read_image():
    import cv2
    n, c, h, w = (1, 3, 32, 32)
    image = cv2.imread(path_to_image)
    if image is None:
        raise FileNotFoundError("Input image not found")

    image = cv2.resize(image, (h, w)) / 255
    image = image.transpose((2, 0, 1))
    image = image.reshape((n, c, h, w))
    return image


def test_infer(device):
    ie_core = ie.IECore()
    net = ie_core.read_network(model=test_net_xml, weights=test_net_bin)
    exec_net = ie_core.load_network(net, device)