陆宇振
Installation of OpenVINO in windows 10 and Tests
2019-8-30 06:54
阅读:4754
  1. Install the Intel® Distribution of OpenVINO™ toolkit core components (latest version: openvino_2019.2.275 that comes with opencv411, without the contrib module and cuda support)

  2. Install the dependencies:

  3. Set Environment Variables

    cd C:\Program Files (x86)\IntelSWTools\openvino\bin\

    setupvars.bat

  4. Configure the Model Optimizer

    cd C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\model_optimizer\install_prerequisites

    install_prerequisites.bat

  5. Run two Verification Scripts to Verify Installation

    cd C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\demo\

    demo_squeezenet_download_convert_run.bat

1.png


demo_security_barrier_camera.bat

Untitled.png


Caffe model inference test:

    string caffe_root = "C:/Users/FruitLab/OpenCV/OpenCV-Caffe/opencvvino-opencv/caffe-data-images-models/";
    Mat image = imread(caffe_root+"cat.jpg");

    string labels_file = caffe_root+"caffe_ilsvrc12/synset_words.txt";
    string prototxt = caffe_root+"deploy.prototxt";
    string model = caffe_root+"bvlc_reference_caffenet.caffemodel";

    //load labels
    ifstream ifs(labels_file.c_str());
    if(!ifs.is_open())
    {
        CV_Error(Error::StsError, "File" + labels_file + "not found");
        string line;
        while(getline(ifs, line))
        {
            //classes.push_back(line);
        }
    }

    Mat blob;
    blobFromImage(image, blob, 1.0f, Size(224,224), Scalar(104,117,123),false);
    //DNN_BACKEND_INFERENCE_ENGINE
    Net net = readNetFromCaffe(prototxt, model);
    net.setPreferableBackend(DNN_BACKEND_INFERENCE_ENGINE);
    net.setPreferableTarget(DNN_TARGET_CPU);
    cout<<"[INFO] loading model ..."<<endl;

    //prediction
    net.setInput(blob);
    //vector<float> preds = net.forward();
    Mat probs = net.forward();

    double freq = getTickFrequency()/1000;
    vector<double> layersTimes;
    double t = net.getPerfProfile(layersTimes)/freq;
    cout<<"[INFO] classification took "<<t<<" ms"<<endl;

Untitled.png


It is noted that without openvino acceleration (just use self-built opencv410 for the task):

2.png

About 4-5 times faster due to the use of inference engine!!


References:

http://docs.openvinotoolkit.org/latest/_docs_install_guides_installing_openvino_windows.html#set-the-environment-variables

https://www.learnopencv.com/using-openvino-with-opencv/

https://github.com/spmallick/learnopencv/blob/master/OpenVINO-OpenCV/image-classification.cpp

https://www.pyimagesearch.com/2017/11/06/deep-learning-opencvs-blobfromimage-works/


转载本文请联系原作者获取授权,同时请注明本文来自陆宇振科学网博客。

链接地址:https://wap.sciencenet.cn/blog-578676-1195820.html?mobile=1

收藏

分享到:

当前推荐数:0
推荐到博客首页
网友评论0 条评论
确定删除指定的回复吗?
确定删除本博文吗?