jingweimo的个人博客分享 http://blog.sciencenet.cn/u/jingweimo

博文

Installation of OpenVINO in windows 10 and Tests

已有 4806 次阅读 2019-8-30 06:54 |系统分类:科研笔记

  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://blog.sciencenet.cn/blog-578676-1195820.html

上一篇:[转载]Hydraulics 101 for Beginners
下一篇:Sketchup: modeling a screw
收藏 IP: 35.10.57.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...
扫一扫,分享此博文

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-12-25 02:11

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部