Skip to content

Instantly share code, notes, and snippets.

@dkurt
Last active January 10, 2020 11:21
Show Gist options
  • Save dkurt/bc567159e5173a6e86c5781badff9ac6 to your computer and use it in GitHub Desktop.
Save dkurt/bc567159e5173a6e86c5781badff9ac6 to your computer and use it in GitHub Desktop.
  1. Скачайте OpenVINO с официального сайта: https://software.seek.intel.com/openvino-toolkit
  2. Установите OpenVINO
  3. Откройте терминал (Development Command Prompt на Windows)
  4. Выставите окружение
  • Windows

    "C:\Program Files (x86)\IntelSWTools\openvino\bin\setupvars.bat"
    

    Ожидаемое сообщение:

    Python 3.7.6
    ECHO is off.
    PYTHONPATH=C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\open_model_zoo\tools\accuracy_checker;C:\Program Files (x86)\IntelSWTools\openvino\python\python3.7;C:\Program Files (x86)\IntelSWTools\openvino\python\python3;C:\Users\dkurtaev\opencv\build\lib\Release
    [setupvars.bat] OpenVINO environment initialized
    
  • Linux

    source /opt/intel/openvino/bin/setupvars.sh
    

    Ожидаемое сообщение:

    [setupvars.sh] OpenVINO environment initialized
    
  1. Скачайте модель нейронной сети для теста (2 файла):

    face-detection-adas-0001.bin
    face-detection-adas-0001.xml

  2. Скачайте тестовое изображение: https://github.com/opencv/opencv_extra/raw/master/testdata/gpu/lbpcascade/er.png

  3. Создайте файл test_openvino.py со следующим содержимым:

    import cv2 as cv
    
    # Load the model.
    net = cv.dnn_DetectionModel('face-detection-adas-0001.xml',
                                'face-detection-adas-0001.bin')
    
    # Read an image.
    frame = cv.imread('er.png')
    if frame is None:
        raise Exception('Image not found!')
    
    # Perform an inference.
    _, confidences, boxes = net.detect(frame, confThreshold=0.5)
    
    # Draw detected faces on the frame.
    for confidence, box in zip(list(confidences), boxes):
        cv.rectangle(frame, box, color=(0, 255, 0))
    
    # Save the frame to an image file.
    cv.imshow('OpenVINO test', frame)
    cv.waitKey()
  4. Запустите скрипт. Ожидается, что на экран выведется следующее изображение с найденными лицами:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment