如何使用OpenVINO预训练模型? [英] How to use OpenVINO pre-trained models?

查看:470
本文介绍了如何使用OpenVINO预训练模型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近安装了OpenVINO,但我不知道该如何输入信息并从OpenVINO的预训练模型中获得预测.

I have installed OpenVINO recently but I don't know how I should give inputs and get the predict from OpenVINOs pre-trained models.

有两个带有.bin和.xml后缀的文件,我刚刚使用过keras,所以我不能在opencv中使用此模型.

there is two files with .bin and .xml suffixes, I've just worked with keras so I can't use this models in opencv.

我找到了这段代码,但是没有用.

I find this code but it didn't work.

import cv2 as cv

net = cv.dnn.readNet('face-detection-adas-0001.bin', 'face-detection-adas-0001.xml')

cap = cv.VideoCapture(0)

while cv.waitKey(1) < 0:
    hasFrame, frame = cap.read()
    if not hasFrame:
        break

    blob = cv.dnn.blobFromImage(frame, size=(672, 384))
    net.setInput(blob)
    out = net.forward()

    for detection in out.reshape(-1, 7):
        confidence = float(detection[2])
        xmin = int(detection[3] * frame.shape[1])
        ymin = int(detection[4] * frame.shape[0])
        xmax = int(detection[5] * frame.shape[1])
        ymax = int(detection[6] * frame.shape[0])

        if confidence > 0.5:
            cv.rectangle(frame, (xmin, ymin), (xmax, ymax), color=(0, 255, 0))

    cv.imshow('OpenVINO face detection', frame)

有错误代码:

Traceback (most recent call last):
  File "C:\Users\Ali-10\Desktop\facial_landmark\face.py", line 3, in <module>
    net = cv.dnn.readNet('face-detection-adas-0001.bin', 'face-detection-adas-0001.xml')
    cv2.error: OpenCV(3.4.4) C:\projects\opencv-python\opencv\modules\dnn\src\dnn.cpp:2428: error: (-2:Unspecified error) Build OpenCV with Inference Engine to enable loading models from Model Optimizer. in function 'cv::dnn::experimental_dnn_34_v10::Net::readFromModelOptimizer'

我希望模型能够预测出来,但我只是得到了这个错误.

I expect the prediction of the model but I just get this error.

推荐答案

我刚刚测试了这段代码,它工作得很好.您需要先安装openvino,然后运行setupvars.bat文件以初始化openvino环境.完成后,您可以运行您的代码,它将开始检测您的面孔.我在具有12Gb RAM的Intel i5上进行了测试,得到的速度为23-25fps.

I just tested this code and it works perfectly fine. You need to install openvino first and then run setupvars.bat file in order to initialize the openvino enviroment. Once that is done, you can run your code and it will start detecting your face. I tested this on Intel i5 with 12Gb RAM and I was getting 23-25fps which is good.

这篇关于如何使用OpenVINO预训练模型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆