当前位置: 首页>>代码示例>>Python>>正文


Python inference_engine.IENetwork方法代码示例

本文整理汇总了Python中openvino.inference_engine.IENetwork方法的典型用法代码示例。如果您正苦于以下问题:Python inference_engine.IENetwork方法的具体用法?Python inference_engine.IENetwork怎么用?Python inference_engine.IENetwork使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在openvino.inference_engine的用法示例。


在下文中一共展示了inference_engine.IENetwork方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from openvino import inference_engine [as 别名]
# 或者: from openvino.inference_engine import IENetwork [as 别名]
def __init__(self, devid, frameBuffer, results, camera_width, camera_height, number_of_ncs, vidfps):
        self.devid = devid
        self.frameBuffer = frameBuffer
        self.model_xml = "./lrmodels/YoloV3/FP16/frozen_yolo_v3.xml"
        self.model_bin = "./lrmodels/YoloV3/FP16/frozen_yolo_v3.bin"
        self.camera_width = camera_width
        self.camera_height = camera_height
        self.m_input_size = 416
        self.threshould = 0.7
        self.num_requests = 4
        self.inferred_request = [0] * self.num_requests
        self.heap_request = []
        self.inferred_cnt = 0
        self.plugin = IEPlugin(device="MYRIAD")
        self.net = IENetwork(model=self.model_xml, weights=self.model_bin)
        self.input_blob = next(iter(self.net.inputs))
        self.exec_net = self.plugin.load(network=self.net, num_requests=self.num_requests)
        self.results = results
        self.number_of_ncs = number_of_ncs
        self.predict_async_time = 800
        self.skip_frame = 0
        self.roop_frame = 0
        self.vidfps = vidfps
        self.new_w = int(camera_width * self.m_input_size/camera_width)
        self.new_h = int(camera_height * self.m_input_size/camera_height) 
开发者ID:PINTO0309,项目名称:OpenVINO-YoloV3,代码行数:27,代码来源:openvino_yolov3_MultiStick_test.py

示例2: __init__

# 需要导入模块: from openvino import inference_engine [as 别名]
# 或者: from openvino.inference_engine import IENetwork [as 别名]
def __init__(self, devid, frameBuffer, results, camera_width, camera_height, number_of_ncs, vidfps):
        self.devid = devid
        self.frameBuffer = frameBuffer
        self.model_xml = "./lrmodels/tiny-YoloV3/FP16/frozen_tiny_yolo_v3.xml"
        self.model_bin = "./lrmodels/tiny-YoloV3/FP16/frozen_tiny_yolo_v3.bin"
        self.camera_width = camera_width
        self.camera_height = camera_height
        self.m_input_size = 416
        self.threshould = 0.4
        self.num_requests = 4
        self.inferred_request = [0] * self.num_requests
        self.heap_request = []
        self.inferred_cnt = 0
        self.plugin = IEPlugin(device="MYRIAD")
        self.net = IENetwork(model=self.model_xml, weights=self.model_bin)
        self.input_blob = next(iter(self.net.inputs))
        self.exec_net = self.plugin.load(network=self.net, num_requests=self.num_requests)
        self.results = results
        self.number_of_ncs = number_of_ncs
        self.predict_async_time = 800
        self.skip_frame = 0
        self.roop_frame = 0
        self.vidfps = vidfps
        self.new_w = int(camera_width * self.m_input_size/camera_width)
        self.new_h = int(camera_height * self.m_input_size/camera_height) 
开发者ID:PINTO0309,项目名称:OpenVINO-YoloV3,代码行数:27,代码来源:openvino_tiny-yolov3_MultiStick_test.py

示例3: __init__

# 需要导入模块: from openvino import inference_engine [as 别名]
# 或者: from openvino.inference_engine import IENetwork [as 别名]
def __init__(self, gn_ir: str, ie: IECore, device: str):
        self._ie = ie
        
        try:
            self._gn_labels = np.loadtxt(googlenet_processor.LABELS_FILE_NAME, str, delimiter='\t')
            for label_index in range(0, len(self._gn_labels)):
                temp = self._gn_labels[label_index].split(',')[0].split(' ', 1)[1]
                self._gn_labels[label_index] = temp
        except:
            print('\n\n')
            print('Error - could not read labels from: ' + googlenet_processor.LABELS_FILE_NAME)
            print('\n\n')
            raise
        
        # Set up the network
        self._gn_net = IENetwork(model = gn_ir, weights = gn_ir[:-3] + 'bin')
        # Set up the input and output blobs
        self._gn_input_blob = next(iter(self._gn_net.inputs))
        self._gn_output_blob = next(iter(self._gn_net.outputs))
        self._gn_input_shape = self._gn_net.inputs[self._gn_input_blob].shape
        self._gn_output_shape = self._gn_net.outputs[self._gn_output_blob].shape
        # Load the network
        self._gn_exec_net = ie.load_network(network = self._gn_net, device_name = device)
        # Get the input shapes
        self._gn_n, self._gn_c, self._gn_h, self._gn_w = self._gn_input_shape 
开发者ID:movidius,项目名称:ncappzoo,代码行数:27,代码来源:googlenet_processor.py

示例4: classify_frame

# 需要导入模块: from openvino import inference_engine [as 别名]
# 或者: from openvino.inference_engine import IENetwork [as 别名]
def classify_frame(inputQueue, outputQueue):
	plugin = IEPlugin("MYRIAD")
	net = IENetwork(model=model_xml, weights=model_bin)
	input_blob = next(iter(net.inputs))
	exec_net = plugin.load(network=net)
# keep looping
	while True:
		# check to see if there is a frame in our input queue
		if not inputQueue.empty():
			# grab the frame from the input queue, resize it, and
			# construct a blob from it
			image = inputQueue.get()
			prepimg = cv2.resize(image, (416, 416))
			prepimg = prepimg[np.newaxis, :, :, :]     # Batch size axis add
			prepimg = prepimg.transpose((0, 3, 1, 2))  # NHWC to NCHW
			outputs = exec_net.infer(inputs={input_blob: prepimg})
			# write the detections to the output queue
			outputQueue.put(outputs)
			

# initialize the input queue (frames), output queue (out),
# and the list of actual detections returned by the child process 
开发者ID:leswright1977,项目名称:RPi3_NCS2,代码行数:24,代码来源:yolo_test_threaded.py

示例5: __init__

# 需要导入模块: from openvino import inference_engine [as 别名]
# 或者: from openvino.inference_engine import IENetwork [as 别名]
def __init__(self, devid, frameBuffer, results, camera_mode, camera_width, camera_height, number_of_ncs, vidfps, skpfrm):
        self.devid = devid
        self.frameBuffer = frameBuffer
        self.model_xml = "./lrmodel/MobileNetSSD/MobileNetSSD_deploy.xml"
        self.model_bin = "./lrmodel/MobileNetSSD/MobileNetSSD_deploy.bin"
        self.camera_width = camera_width
        self.camera_height = camera_height
        self.num_requests = 4
        self.inferred_request = [0] * self.num_requests
        self.heap_request = []
        self.inferred_cnt = 0
        self.plugin = IEPlugin(device="MYRIAD")
        self.net = IENetwork(model=self.model_xml, weights=self.model_bin)
        self.input_blob = next(iter(self.net.inputs))
        self.exec_net = self.plugin.load(network=self.net, num_requests=self.num_requests)
        self.results = results
        self.camera_mode = camera_mode
        self.number_of_ncs = number_of_ncs
        if self.camera_mode == 0:
            self.skip_frame = skpfrm
        else:
            self.skip_frame = 0
        self.roop_frame = 0
        self.vidfps = vidfps 
开发者ID:PINTO0309,项目名称:MobileNet-SSD-RealSense,代码行数:26,代码来源:MultiStickSSDwithRealSense_OpenVINO_NCS2.py

示例6: __init__

# 需要导入模块: from openvino import inference_engine [as 别名]
# 或者: from openvino.inference_engine import IENetwork [as 别名]
def __init__(self, devid, frameBuffer, results, camera_width, camera_height, number_of_ncs):
        self.devid = devid
        self.frameBuffer = frameBuffer
        self.model_xml = "./lrmodel/MobileNetSSD/MobileNetSSD_deploy.xml"
        self.model_bin = "./lrmodel/MobileNetSSD/MobileNetSSD_deploy.bin"
        self.camera_width = camera_width
        self.camera_height = camera_height
        self.num_requests = 4
        self.inferred_request = [0] * self.num_requests
        self.heap_request = []
        self.inferred_cnt = 0
        self.plugin = IEPlugin(device="MYRIAD")
        self.net = IENetwork(model=self.model_xml, weights=self.model_bin)
        self.input_blob = next(iter(self.net.inputs))
        self.exec_net = self.plugin.load(network=self.net, num_requests=self.num_requests)
        self.results = results
        self.number_of_ncs = number_of_ncs 
开发者ID:PINTO0309,项目名称:MobileNet-SSD-RealSense,代码行数:19,代码来源:MultiStickSSDwithPiCamera_OpenVINO_NCS2.py

示例7: __init__

# 需要导入模块: from openvino import inference_engine [as 别名]
# 或者: from openvino.inference_engine import IENetwork [as 别名]
def __init__(self, devid, model_path, number_of_ncs):
        global g_plugin
        global g_inferred_request
        global g_heap_request
        global g_inferred_cnt
        global g_number_of_allocated_ncs

        self.devid = devid
        if number_of_ncs   == 0:
            self.num_requests = 4
        elif number_of_ncs == 1:
            self.num_requests = 4
        elif number_of_ncs == 2:
            self.num_requests = 2
        elif number_of_ncs >= 3:
            self.num_requests = 1

        print("g_number_of_allocated_ncs =", g_number_of_allocated_ncs, "number_of_ncs =", number_of_ncs)

        if g_number_of_allocated_ncs < 1:
            self.plugin = IEPlugin(device="MYRIAD")
            self.inferred_request = [0] * self.num_requests
            self.heap_request = []
            self.inferred_cnt = 0
            g_plugin = self.plugin
            g_inferred_request = self.inferred_request
            g_heap_request = self.heap_request
            g_inferred_cnt = self.inferred_cnt
            g_number_of_allocated_ncs += 1
        else:
            self.plugin = g_plugin
            self.inferred_request = g_inferred_request
            self.heap_request = g_heap_request
            self.inferred_cnt = g_inferred_cnt

        self.model_xml = model_path + ".xml"
        self.model_bin = model_path + ".bin"
        self.net = IENetwork(model=self.model_xml, weights=self.model_bin)
        self.input_blob = next(iter(self.net.inputs))
        self.exec_net = self.plugin.load(network=self.net, num_requests=self.num_requests) 
开发者ID:PINTO0309,项目名称:OpenVINO-EmotionRecognition,代码行数:42,代码来源:main.py

示例8: __init__

# 需要导入模块: from openvino import inference_engine [as 别名]
# 或者: from openvino.inference_engine import IENetwork [as 别名]
def __init__(self, devid, device, model_xml, frameBuffer, results, camera_width, camera_height, number_of_ncs, vidfps, nPoints, w, h, new_w, new_h):
        self.devid = devid
        self.frameBuffer = frameBuffer
        self.model_xml = model_xml
        self.model_bin = os.path.splitext(model_xml)[0] + ".bin"
        self.camera_width = camera_width
        self.camera_height = camera_height
        self.threshold = 0.1
        self.nPoints = nPoints
        self.num_requests = 4
        self.inferred_request = [0] * self.num_requests
        self.heap_request = []
        self.inferred_cnt = 0
        self.plugin = IEPlugin(device=device)
        if "CPU" == device:
            if platform.processor() == "x86_64":
                self.plugin.add_cpu_extension("lib/libcpu_extension.so")
        self.net = IENetwork(model=self.model_xml, weights=self.model_bin)
        self.input_blob = next(iter(self.net.inputs))
        self.exec_net = self.plugin.load(network=self.net, num_requests=self.num_requests)
        self.results = results
        self.number_of_ncs = number_of_ncs
        self.predict_async_time = 250
        self.skip_frame = 0
        self.roop_frame = 0
        self.vidfps = vidfps
        self.w = w #432
        self.h = h #368
        self.new_w = new_w
        self.new_h = new_h 
开发者ID:PINTO0309,项目名称:MobileNetV2-PoseEstimation,代码行数:32,代码来源:openvino-usbcamera-cpu-ncs2-async.py

示例9: __init__

# 需要导入模块: from openvino import inference_engine [as 别名]
# 或者: from openvino.inference_engine import IENetwork [as 别名]
def __init__(self, net_model_xml_path, device):
        self.device = device

        net_model_bin_path = os.path.splitext(net_model_xml_path)[0] + '.bin'
        self.net = IENetwork(model=net_model_xml_path, weights=net_model_bin_path)
        required_input_key = {'data'}
        assert required_input_key == set(self.net.inputs.keys()), \
            'Demo supports only topologies with the following input key: {}'.format(', '.join(required_input_key))
        required_output_keys = {'features', 'heatmaps', 'pafs'}
        assert required_output_keys.issubset(self.net.outputs.keys()), \
            'Demo supports only topologies with the following output keys: {}'.format(', '.join(required_output_keys))

        self.ie = IECore()
        self.exec_net = self.ie.load_network(network=self.net, num_requests=1, device_name=device) 
开发者ID:Daniil-Osokin,项目名称:lightweight-human-pose-estimation-3d-demo.pytorch,代码行数:16,代码来源:inference_engine_openvino.py

示例10: __init__

# 需要导入模块: from openvino import inference_engine [as 别名]
# 或者: from openvino.inference_engine import IENetwork [as 别名]
def __init__(self, ie,      # type: IECore 
                       net,     # type: IENetwork
                       device   # type: str
                ):        
        """ Constructor for object detector processor. 
            Does 3 main things:           
            1. Get input and output layer names for the model. 
            2. Gather input and output shapes (n,c,h,w) from the model input/output and input/output blobs.
            3. Create the ExecutableNetwork object by specifying the IENetwork object and device name (in this case MYRIAD). """
        pass 
开发者ID:movidius,项目名称:ncappzoo,代码行数:12,代码来源:Object_detector.py

示例11: main

# 需要导入模块: from openvino import inference_engine [as 别名]
# 或者: from openvino.inference_engine import IENetwork [as 别名]
def main():
    global network_input_h, network_input_w
    ie = IECore()
    net = IENetwork(model = ir, weights = ir[:-3] + 'bin')
    input_blob = next(iter(net.inputs))
    output_blob = next(iter(net.outputs))
    
    exec_net = ie.load_network(network = net, device_name = DEVICE)
    n, c, network_input_h, network_input_w = net.inputs[input_blob].shape

    # Read the image
    validated_image = cv2.imread(validated_image_filename)
    if validated_image is None:
    	print("Cannot read image.")
    	exit(1)
    	
    # Preprocess the image
    preprocessed_image = preprocess_image(validated_image)
    
    # Run the inference
    valid_output = run_inference(preprocessed_image, exec_net, input_blob, output_blob)

    # Get list of all the .jpg files in the image directory
    input_image_filename_list = os.listdir(TEST_IMAGES_DIR)
    input_image_filename_list = [i for i in input_image_filename_list if i.endswith('.png')]
    if (len(input_image_filename_list) < 1):
        # no images to show
        print('No .png files found')
        return 1
    else:
        print("images: " + str(input_image_filename_list) + '\n')
    
    # Run the inferences and make comparisons 
    run_images(valid_output, validated_image_filename, exec_net, input_image_filename_list, input_blob, output_blob)
    print(" Finished.\n")



# main entry point for program. we'll call main() to do what needs to be done. 
开发者ID:movidius,项目名称:ncappzoo,代码行数:41,代码来源:facenet.py

示例12: main

# 需要导入模块: from openvino import inference_engine [as 别名]
# 或者: from openvino.inference_engine import IENetwork [as 别名]
def main():
    ARGS = parse_args().parse_args()

    ####################### 1. Setup Plugin and Network #######################
    # Select the myriad plugin and IRs to be used
    plugin = IEPlugin(device='MYRIAD')
    net = IENetwork(model = ARGS.ir, weights = ARGS.ir[:-3] + 'bin')

    # Set up the input and output blobs
    input_blob = next(iter(net.inputs))
    output_blob = next(iter(net.outputs))

    # Load the network and get the network shape information
    exec_net = plugin.load(network = net)
    input_shape = tuple(net.inputs[input_blob].shape)
    output_shape = net.outputs[output_blob].shape
    display_info(ARGS, input_shape, output_shape)
    # Prepare Categories for age and gender networks
    with open(ARGS.labels) as labels_file:
	    label_list = labels_file.read().splitlines()
	
    ####################### 2. Image Preprocessing #######################
    # Read in the image.
    img = cv2.imread(ARGS.image)
    img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    # Image preprocessing
    img = cv2.resize(img, NETWORK_DIM)
    img = img.astype(numpy.float32)
    img[:] = ((img[:]) * (1.0 / 255.0))
    
    img = img.reshape(input_shape)

    ####################### 3. Run the inference #######################
    res = exec_net.infer({input_blob: img})
    
    ####################### 4. Process and print the results #######################
    top_ind = numpy.argsort(res[output_blob], axis=1)[0, -ARGS.number_top:][::-1]
    print(YELLOW + '\n **********' + NOCOLOR + '  Results  ' + YELLOW + '***********' + NOCOLOR)
    for k, i in enumerate(top_ind):
        print('Prediction is ' + YELLOW + label_list[int(i)] + NOCOLOR + " with a confidence of " + YELLOW + "%3.1f%%." % (100*res[output_blob][0, i]) + NOCOLOR)
    print('') 
开发者ID:movidius,项目名称:ncappzoo,代码行数:43,代码来源:mnist.py

示例13: __init__

# 需要导入模块: from openvino import inference_engine [as 别名]
# 或者: from openvino.inference_engine import IENetwork [as 别名]
def __init__(self, network_graph_filename, plugin=None,
                 prob_thresh=0.0, classification_mask=None):
        """Initialize an instance of the class.

        :param network_graph_filename: the file path and name of the graph file created by the OpenVINO compiler
        :param nc_device: an open neural compute device object to use for inferences for this graph file
        :param prob_thresh: the probability threshold (between 0.0 and 1.0)... results below this threshold will be
        excluded
        :param classification_mask: a list of 0/1 values, one for each classification label in the
        _classification_mask list... if the value is 0 then the corresponding classification won't be reported.
        :return : None

        """
        # Load graph from disk and allocate graph to device
        try:
            
            self._net = IENetwork(model=network_graph_filename + ".xml", weights=network_graph_filename + ".bin")
            self._input_blob = next(iter(self._net.inputs))
            self._output_blob = next(iter(self._net.outputs))
            self._exec_net = plugin.load(network=self._net)
            #print("network shape: ",self._net.inputs[self._input_blob].shape)
            self._n, self._input_total_size = self._net.inputs[self._input_blob].shape
            del self._net


        except IOError as e:
            print('Error - could not load neural network graph file: ' + network_graph_filename)
            raise e

        # If no mask was passed then create one to accept all classifications
        self._classification_mask = classification_mask if classification_mask else [1] * 10
        self._probability_threshold = prob_thresh
        self._end_flag = True 
开发者ID:movidius,项目名称:ncappzoo,代码行数:35,代码来源:mnist_processor.py

示例14: __init__

# 需要导入模块: from openvino import inference_engine [as 别名]
# 或者: from openvino.inference_engine import IENetwork [as 别名]
def __init__(self, ty_ir: str, ie: IECore, device: str):
        self._ie = ie
        
        try:
            self._ty_labels = np.loadtxt(tiny_yolo_processor.LABELS_FILE_NAME, str, delimiter='\t')
            with open(tiny_yolo_processor.LABELS_FILE_NAME) as labels_file:
	            self._ty_labels = labels_file.read().splitlines()
        except:
            print('\n\n')
            print('Error - could not read labels from: ' + tiny_yolo_processor.LABELS_FILE_NAME)
            print('\n\n')
            raise
        
        # Create the network object
        self._ty_net = IENetwork(model = ty_ir, weights = ty_ir[:-3] + 'bin')
        # Set up the input and output blobs
        self._ty_input_blob = next(iter(self._ty_net.inputs))
        self._ty_output_blob = next(iter(self._ty_net.outputs))
        self._ty_input_shape = self._ty_net.inputs[self._ty_input_blob].shape
        self._ty_output_shape = self._ty_net.outputs[self._ty_output_blob].shape
        # Load the network
        self._ty_exec_net = ie.load_network(network = self._ty_net, device_name = device)
        # Get the input shape
        self._ty_n, self._ty_c, self.ty_h, self.ty_w = self._ty_input_shape

    
    # Performs the image preprocessing and makes an inference
    # Returns a list of detected object names, four bounding box points, and the object score 
开发者ID:movidius,项目名称:ncappzoo,代码行数:30,代码来源:tiny_yolo_processor.py

示例15: create_ie_network

# 需要导入模块: from openvino import inference_engine [as 别名]
# 或者: from openvino.inference_engine import IENetwork [as 别名]
def create_ie_network(model_xml, model_bin):
        return ie.IENetwork(model_xml, model_bin) 
开发者ID:opencv,项目名称:open_model_zoo,代码行数:4,代码来源:dlsdk_launcher.py


注:本文中的openvino.inference_engine.IENetwork方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。