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


Python inference_engine.IECore方法代码示例

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


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

示例1: __init__

# 需要导入模块: from openvino import inference_engine [as 别名]
# 或者: from openvino.inference_engine import IECore [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

示例2: main

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

    ie = IECore()
    inpainting_processor = ImageInpainting(ie, args.model, args.parts,
                                           args.max_brush_width, args.max_length, args.max_vertex, args.device)

    img = cv2.imread(args.input, cv2.IMREAD_COLOR)
    masked_image, output_image = inpainting_processor.process(img)
    concat_imgs = np.hstack((masked_image, output_image))
    cv2.putText(concat_imgs, 'summary: {:.1f} FPS'.format(
            float(1 / inpainting_processor.infer_time)), (5, 15), cv2.FONT_HERSHEY_COMPLEX, 0.5, (0, 0, 200))
    if not args.no_show:
        cv2.imshow('Image Inpainting Demo', concat_imgs)
        key = cv2.waitKey(0)
        if key == 27:
            return 
开发者ID:opencv,项目名称:open_model_zoo,代码行数:19,代码来源:image_inpainting_demo.py

示例3: validate

# 需要导入模块: from openvino import inference_engine [as 别名]
# 或者: from openvino.inference_engine import IECore [as 别名]
def validate(self, entry, field_uri=None, ie_core=None):
        """
        Validate that launcher entry meets all configuration structure requirements.
        Args:
            entry: launcher configuration file entry.
            field_uri: id of launcher entry.
            ie_core: IECore instance.
        """
        if not self.delayed_model_loading:
            framework_parameters = self.check_model_source(entry)
            self._set_model_source(framework_parameters)
        super().validate(entry, field_uri)
        self.create_device_regex(ie.known_plugins)
        try:
            self.fields['device'].validate(entry['device'], field_uri)
        except ConfigError as error:
            if ie_core is not None:
                self.create_device_regex(ie_core.available_devices)
                try:
                    self.fields['device'].validate(entry['device'], field_uri)
                except ConfigError:
                    # workaround for devices where this metric is non implemented
                    warning('unknown device: {}'.format(entry['device']))
            else:
                raise error 
开发者ID:opencv,项目名称:open_model_zoo,代码行数:27,代码来源:dlsdk_launcher.py

示例4: __init__

# 需要导入模块: from openvino import inference_engine [as 别名]
# 或者: from openvino.inference_engine import IECore [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

示例5: main

# 需要导入模块: from openvino import inference_engine [as 别名]
# 或者: from openvino.inference_engine import IECore [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

示例6: camera_demo

# 需要导入模块: from openvino import inference_engine [as 别名]
# 或者: from openvino.inference_engine import IECore [as 别名]
def camera_demo():

    args = build_argparser().parse_args()
    model_xml = "openvino/480x640/FP32/dbface.xml" #<--- CPU
    #model_xml = "openvino/480x640/FP16/dbface.xml" #<--- MYRIAD
    model_bin = os.path.splitext(model_xml)[0] + ".bin"
    ie = IECore()
    net = ie.read_network(model=model_xml, weights=model_bin)
    input_blob = next(iter(net.inputs))
    exec_net = ie.load_network(network=net, device_name='CPU')

    cap = cv2.VideoCapture(0)
    cap.set(cv2.CAP_PROP_FRAME_WIDTH, 640)
    cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 480)

    ok, frame = cap.read()

    while ok:
        img = frame[np.newaxis, :, :, :]   # Batch size axis add
        img = img.transpose((0, 3, 1, 2))  # NHWC to NCHW
        objs = detect(exec_net, input_blob, img)

        for obj in objs:
            common.drawbbox(frame, obj)

        cv2.imshow("demo DBFace", frame)
        key = cv2.waitKey(1) & 0xFF
        if key == ord('q'):
            break

        ok, frame = cap.read()
    
    cap.release()
    cv2.destroyAllWindows() 
开发者ID:PINTO0309,项目名称:PINTO_model_zoo,代码行数:36,代码来源:main_openvino.py

示例7: __init__

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

        self.ie = IECore()

        self.net = self.ie.read_network(net_model_xml_path, os.path.splitext(net_model_xml_path)[0] + '.bin')
        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.exec_net = self.ie.load_network(network=self.net, num_requests=1, device_name=device) 
开发者ID:opencv,项目名称:open_model_zoo,代码行数:17,代码来源:inference_engine.py

示例8: run_demo

# 需要导入模块: from openvino import inference_engine [as 别名]
# 或者: from openvino.inference_engine import IECore [as 别名]
def run_demo(args):
    ie = IECore()
    detector_person = Detector(ie, path_to_model_xml=args.model_od,
                              device=args.device,
                              label_class=args.person_label)

    single_human_pose_estimator = HumanPoseEstimator(ie, path_to_model_xml=args.model_hpe,
                                                  device=args.device)
    if args.input != '':
        img = cv2.imread(args.input[0], cv2.IMREAD_COLOR)
        frames_reader, delay = (VideoReader(args.input), 1) if img is None else (ImageReader(args.input), 0)
    else:
        raise ValueError('--input has to be set')

    for frame in frames_reader:
        bboxes = detector_person.detect(frame)
        human_poses = [single_human_pose_estimator.estimate(frame, bbox) for bbox in bboxes]

        colors = [(0, 0, 255),
                  (255, 0, 0), (0, 255, 0), (255, 0, 0), (0, 255, 0),
                  (255, 0, 0), (0, 255, 0), (255, 0, 0), (0, 255, 0),
                  (255, 0, 0), (0, 255, 0), (255, 0, 0), (0, 255, 0),
                  (255, 0, 0), (0, 255, 0), (255, 0, 0), (0, 255, 0)]

        for pose, bbox in zip(human_poses, bboxes):
            cv2.rectangle(frame, (bbox[0], bbox[1]), (bbox[0] + bbox[2], bbox[1] + bbox[3]), (255, 0, 0), 2)
            for id_kpt, kpt in enumerate(pose):
                cv2.circle(frame, (int(kpt[0]), int(kpt[1])), 3, colors[id_kpt], -1)

        cv2.putText(frame, 'summary: {:.1f} FPS (estimation: {:.1f} FPS / detection: {:.1f} FPS)'.format(
            float(1 / (detector_person.infer_time + single_human_pose_estimator.infer_time * len(human_poses))),
            float(1 / single_human_pose_estimator.infer_time),
            float(1 / detector_person.infer_time)), (5, 15), cv2.FONT_HERSHEY_COMPLEX, 0.5, (0, 0, 200))
        if args.no_show:
            continue
        cv2.imshow('Human Pose Estimation Demo', frame)
        key = cv2.waitKey(delay)
        if key == 27:
            return 
开发者ID:opencv,项目名称:open_model_zoo,代码行数:41,代码来源:single_human_pose_estimation_demo.py

示例9: main

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

    ie = IECore()
    detector = Detector(ie, args.model, args.prob_threshold, args.device)

    img = cv2.imread(args.input[0], cv2.IMREAD_COLOR)
    frames_reader, delay = (VideoReader(args.input), 1) if img is None else (ImageReader(args.input), 0)

    if args.labels:
        with open(args.labels, 'r') as f:
            labels_map = [x.strip() for x in f]
    else:
        labels_map = None

    for frame in frames_reader:
        detections = detector.detect(frame)
        for det in detections:
            xmin, ymin, xmax, ymax = det[:4].astype(np.int)
            xmin = max(0, xmin)
            ymin = max(0, ymin)
            xmax = min(frame.shape[1], xmax)
            ymax = min(frame.shape[0], ymax)
            class_id = det[5]
            det_label = labels_map[int(class_id)] if labels_map else str(int(class_id))
            color = (min(class_id * 12.5, 255), min(class_id * 7, 255), min(class_id * 3, 255))
            cv2.rectangle(frame, (xmin, ymin), (xmax, ymax), color, 2)
            cv2.putText(frame, det_label + ' ' + str(round(det[4] * 100, 1)) + ' %', (xmin, ymin - 7),
                         cv2.FONT_HERSHEY_COMPLEX, 0.6, color, 1)

        cv2.putText(frame, 'summary: {:.1f} FPS'.format(
            float(1 / (detector.infer_time * len(detections)))), (5, 15), cv2.FONT_HERSHEY_COMPLEX, 0.5, (0, 0, 200))
        if args.no_show:
            continue
        cv2.imshow('CenterNet Detection Demo', frame)
        key = cv2.waitKey(delay)
        if key == 27:
            return 
开发者ID:opencv,项目名称:open_model_zoo,代码行数:40,代码来源:object_detection_demo_centernet.py

示例10: __init__

# 需要导入模块: from openvino import inference_engine [as 别名]
# 或者: from openvino.inference_engine import IECore [as 别名]
def __init__(self, config_entry, model_name='', delayed_model_loading=False):
        super().__init__(config_entry, model_name)

        self._set_variable = False
        self.ie_config = self.config.get('ie_config')
        self.ie_core = ie.IECore(xml_config_file=str(self.ie_config)) if self.ie_config is not None else ie.IECore()
        self._delayed_model_loading = delayed_model_loading
        dlsdk_launcher_config = DLSDKLauncherConfigValidator(
            'DLSDK_Launcher', fields=self.parameters(), delayed_model_loading=delayed_model_loading,
        )
        dlsdk_launcher_config.validate(self.config, ie_core=self.ie_core)
        device = self.config['device'].split('.')
        self._device = '.'.join((device[0].upper(), device[1])) if len(device) > 1 else device[0].upper()
        self._set_variable = False
        self._async_mode = False
        self._prepare_bitstream_firmware(self.config)
        self._prepare_ie()
        self._delayed_model_loading = delayed_model_loading

        if not delayed_model_loading:
            if dlsdk_launcher_config.need_conversion:
                self._model, self._weights = DLSDKLauncher.convert_model(self.config, dlsdk_launcher_config.framework)
            else:
                self._model, self._weights = self.automatic_model_search()

            self.load_network(log=True)
            self.allow_reshape_input = self.get_value_from_config('allow_reshape_input') and self.network is not None
        else:
            self.allow_reshape_input = self.get_value_from_config('allow_reshape_input')
        self._do_reshape = False 
开发者ID:opencv,项目名称:open_model_zoo,代码行数:32,代码来源:dlsdk_launcher.py

示例11: no_available_myriad

# 需要导入模块: from openvino import inference_engine [as 别名]
# 或者: from openvino.inference_engine import IECore [as 别名]
def no_available_myriad():
    try:
        from openvino.inference_engine import IECore
        return 'MYRIAD' not in IECore().availabe_devices
    except:
        return True 
开发者ID:opencv,项目名称:open_model_zoo,代码行数:8,代码来源:test_dlsdk_launcher.py

示例12: build

# 需要导入模块: from openvino import inference_engine [as 别名]
# 或者: from openvino.inference_engine import IECore [as 别名]
def build(cls, model_name, model_version, model_xml, model_bin,
              mapping_config, batch_size_param, shape_param, num_ireq,
              target_device, plugin_config):
        core = IECore()
        if GLOBAL_CONFIG['cpu_extension'] is not None \
                and 'CPU' in target_device:
            core.add_extension(
                extension_path=GLOBAL_CONFIG['cpu_extension'],
                device_name='CPU')
        net = IENetwork(model=model_xml, weights=model_bin)
        batching_info = BatchingInfo(batch_size_param)
        shape_info = ShapeInfo(shape_param, net.inputs)
        if batching_info.mode == BatchingMode.FIXED:
            net.batch_size = batching_info.batch_size
        else:
            batching_info.batch_size = net.batch_size

        effective_batch_size = batching_info.get_effective_batch_size()
        logger.debug("[Model: {}, version: {}] --- effective batch size - {}"
                     .format(model_name, model_version, effective_batch_size))
        ###############################
        # Initial shape setup
        if shape_info.mode == ShapeMode.FIXED:
            logger.debug("[Model: {}, version: {}] --- Setting shape to "
                         "fixed value: {}".format(model_name, model_version,
                                                  shape_info.shape))
            net.reshape(shape_info.shape)
        elif shape_info.mode == ShapeMode.AUTO:
            logger.debug("[Model: {}, version: {}] --- Setting shape to "
                         "automatic".format(model_name, model_version))
            net.reshape({})
        elif shape_info.mode == ShapeMode.DEFAULT:
            logger.debug("[Model: {}, version: {}] --- Setting shape to "
                         "default".format(model_name, model_version))
        ###############################
        # Creating free infer requests indexes queue
        free_ireq_index_queue = queue.Queue(maxsize=num_ireq)
        for ireq_index in range(num_ireq):
            free_ireq_index_queue.put(ireq_index)
        ###############################
        requests_queue = queue.Queue(maxsize=GLOBAL_CONFIG[
            'engine_requests_queue_size'])

        exec_net = core.load_network(network=net, num_requests=num_ireq,
                                     config=plugin_config,
                                     device_name=target_device)
        ir_engine = cls(model_name=model_name, model_version=model_version,
                        mapping_config=mapping_config, net=net, core=core,
                        exec_net=exec_net, batching_info=batching_info,
                        shape_info=shape_info,
                        free_ireq_index_queue=free_ireq_index_queue,
                        num_ireq=num_ireq, requests_queue=requests_queue,
                        target_device=target_device,
                        plugin_config=plugin_config)
        return ir_engine 
开发者ID:openvinotoolkit,项目名称:model_server,代码行数:57,代码来源:ir_engine.py

示例13: main

# 需要导入模块: from openvino import inference_engine [as 别名]
# 或者: from openvino.inference_engine import IECore [as 别名]
def main():
    ARGS = parse_args().parse_args()
    image = ARGS.image
    labels = ARGS.labels
    ir = ARGS.ir
    threshold = ARGS.threshold
    
    # Prepare Categories
    with open(labels) as labels_file:
	    label_list = labels_file.read().splitlines()
    
	    
    print(YELLOW + 'Running NCS Caffe TinyYolo example...')

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

    # Set up the input and output blobs
    input_blob = next(iter(net.inputs))
    output_blob = next(iter(net.outputs))
    input_shape = net.inputs[input_blob].shape
    output_shape = net.outputs[output_blob].shape
    
    # Display model information
    display_info(input_shape, output_shape, image, ir, labels)
    
    # Load the network and get the network shape information
    exec_net = ie.load_network(network = net, device_name = DEVICE)
    n, c, h, w = input_shape


    # Read image from file, resize it to network width and height
    # save a copy in display_image for display, then convert to float32, normalize (divide by 255),
    # and finally convert to convert to float16 to pass to LoadTensor as input for an inference
    input_image = cv2.imread(image)
    display_image = input_image
    input_image = cv2.resize(input_image, (w, h), cv2.INTER_LINEAR)
    input_image = input_image.astype(np.float32)
    input_image = np.transpose(input_image, (2,0,1))
    
    output = exec_net.infer({input_blob: input_image})
    output = output[output_blob][0].flatten()


    filtered_objs = filter_objects(output.astype(np.float32), input_image.shape[1], input_image.shape[2], label_list, threshold)

    print('\n Displaying image with objects detected in GUI...')
    print(' Click in the GUI window and hit any key to exit.')
    # display the filtered objects/boxes in a GUI window
    display_objects_in_gui(display_image, filtered_objs, input_image.shape[1], input_image.shape[2])

    print('\n Finished.')


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

示例14: main

# 需要导入模块: from openvino import inference_engine [as 别名]
# 或者: from openvino.inference_engine import IECore [as 别名]
def main():
    ARGS = parse_args().parse_args()
    input_image = ARGS.input
    labels = ARGS.labels
    ir = ARGS.ir
    threshold = ARGS.threshold

    # read an image in bgr format
    img = cv2.imread(input_image)
    original_img = img
	
    ie = IECore()
    net = IENetwork(model = ir, weights = ir[:-3] + 'bin')
	
    # Set up the input and output blobs
    input_blob = next(iter(net.inputs))
    output_blob = next(iter(net.outputs))
    input_shape = net.inputs[input_blob].shape
    output_shape = net.outputs[output_blob].shape
    
    # Display model information
    display_info(input_shape, output_shape, input_image, ir, labels)
    
    # Prepare Categories
    with open(labels) as labels_file:
	    label_list = labels_file.read().splitlines()
    
    # Load the network and get the network shape information
    exec_net = ie.load_network(network = net, device_name = DEVICE)
    n, c, h, w = input_shape

    resized_img = cv2.resize(img, (h, w), cv2.INTER_LINEAR)

    # transpose the image to rgb
    transposed_img = np.transpose(resized_img, (2,0,1))
    reshaped_img = transposed_img.reshape((n, c, h, w))

    resized_img = reshaped_img.astype(np.float32)

    # make an inference
    output = exec_net.infer({input_blob: reshaped_img})
    
    print('\n Displaying image with objects detected in GUI...')
    print(' Click in the GUI window and hit any key to exit.')
    
    # Tiny Yolo V2 requires post processing to filter out duplicate objects and low score objects
    # After post processing, the app will display the image and any detected objects
    post_processing(output[output_blob], original_img, label_list, threshold)

    # clean up
    print("\n Finished.")

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

示例15: infer

# 需要导入模块: from openvino import inference_engine [as 别名]
# 或者: from openvino.inference_engine import IECore [as 别名]
def infer():
    ARGS = parse_args().parse_args()
    ir = ARGS.ir
    image = ARGS.image
    ####################### 1. Setup Plugin and Network #######################
    # Select the myriad plugin and IRs to be used
    ie = IECore()
    
    age_gender_net = IENetwork(model = ir, weights = ir[:-3] + 'bin')

    # Set up the input and output blobs
    age_gender_input_blob = next(iter(age_gender_net.inputs))
    # Make sure to select the age gender output
    age_output_blob = AGE_OUTPUT_LAYER
    gender_output_blob = GENDER_OUTPUT_LAYER
    
    age_gender_input_shape = age_gender_net.inputs[age_gender_input_blob].shape
    # output shapes
    age_output_shape = age_gender_net.outputs[age_output_blob].shape
    gender_output_shape = age_gender_net.outputs[gender_output_blob].shape
    
    # Display model information
    display_info(age_gender_input_shape, age_output_shape, gender_output_shape, image, ir)
    
    # Load the network and get the network shape information
    age_gender_exec_net = ie.load_network(network = age_gender_net, device_name = "MYRIAD")
    
    age_gender_n, age_gender_c, age_gender_h, age_gender_w = age_gender_input_shape
    

    ####################### 2. Image Preprocessing #######################
    # Read in the image.

    frame = cv2.imread(image)

    if frame is None:
        print(RED + "\nUnable to read the image file." + NOCOLOR)
        quit()
			
    # Image preprocessing
    image_to_classify = cv2.resize(frame, (age_gender_w, age_gender_h))
    image_to_classify = numpy.transpose(image_to_classify, (2, 0, 1))
    image_to_classify = image_to_classify.reshape((age_gender_n, age_gender_c, age_gender_h, age_gender_w))

    ####################### 3. Run the inference #######################
    cur_request_id = 0
    detection_threshold = 0.5
    
    age_gender_exec_net.start_async(request_id=cur_request_id, inputs={age_gender_input_blob: image_to_classify})
    if age_gender_exec_net.requests[cur_request_id].wait(-1) == 0:
        age_res = age_gender_exec_net.requests[cur_request_id].outputs[age_output_blob]
        age_res = age_res.flatten()
        gender_res = age_gender_exec_net.requests[cur_request_id].outputs[gender_output_blob]
        gender_res = gender_res.flatten()
        top_ind = numpy.argsort(gender_res)[::-1][:1]
        print('\n Gender prediction is ' + "%3.1f%%" % (100*gender_res[top_ind]) + " " + GENDER_LABEL_LIST[int(top_ind)])
        print(" Age prediction is " + str(int(age_res[0]* 100)) + " years old.\n") 
开发者ID:movidius,项目名称:ncappzoo,代码行数:59,代码来源:age_gender_net.py


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