Skip to content

Instantly share code, notes, and snippets.

@bharath5673
Last active January 2, 2023 02:51
Show Gist options
  • Save bharath5673/2dd9fdd3fdecbab7c03b1d406158b821 to your computer and use it in GitHub Desktop.
Save bharath5673/2dd9fdd3fdecbab7c03b1d406158b821 to your computer and use it in GitHub Desktop.

Easy steps to install OpenVINO and run YOLO.py


***Needed Anaconda or venv for ENVS

Step 1: create conda env and activate


conda create -n openvino-env python=3.9 -y
conda activate openvino-env 
sudo apt-get install python3.9-dev libpython3.9

Step 2: install openvino


pip install openvino-dev[caffe,tensorflow,onnx]
#or 
pip install openvino-dev

lets try YOLO ;)


Step 3: view all open_model_zoo available models

omz_info_dumper --print_all

Step 4: Downloada and Optimize


4.1: Download the model

# omz_downloader --name yolo* --output_dir models


4.2: Optimize the model

# mo --input_model yolo.model --data_type FP16 --output_dir ir

Step 5: Here we will use yolov5 and its has made super easy to use

git clone https://github.com/ultralytics/yolov5
cd yolov5
pip install -r requirements.txt
#run demo
python3 detect.py --weights yolov5n.pt
cd ..

#....export model
#....this one cmd will convert to pytorch --> onnx --> openvino 
#....yolov5n_openvino_model files and dir will be created..
#
python3 export.py --weights yolov5n.pt --include openvino

Step 6: Download Video samples if required

wget -O face-demographics-walking.mp4 https://github.com/intel-iot-devkit/sample-videos/raw/master/face-demographics-walking.mp4
wget -O bottle-detection.mp4 https://github.com/intel-iot-devkit/sample-videos/raw/master/bottle-detection.mp4
wget -O head-pose-face-detection-female.mp4 https://github.com/intel-iot-devkit/sample-videos/raw/master/head-pose-face-detection-female.mp4

Step 7: Running yolo.py


wget https://raw.githubusercontent.com/bharath5673/OpenVINO/main/Openvino-yolo.py
wget https://raw.githubusercontent.com/bharath5673/OpenVINO/main/yolo_80classes.txt
python3 Openvino-yolo.py  ##cam input by default
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment