Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Smart Video Workshop- Jupyter Notebook Support #26

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
@@ -0,0 +1,261 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<div style=\"font-size: 19px\">\n",
"\n",
"# Intel® Movidius™ Neural Compute Stick (NCS)\n",
"\n",
"This lab shows how the Intel® Distribution of OpenVINO™ toolkit provides hardware abstraction to run the sample object detection application which was built in previous modules on Intel® Movidius™ Neural Compute Stick.\n",
"<br>\n",
"\n",
"### Connect Intel® Movidius™ Neural Compute Stick to your development laptop\n",
"<br>\n",
"<img src=\"Movidius.png\">\n",
"<br>\n",
"\n",
"### System check\n",
"<br>\n",
"\n",
"First make sure the USB rules are set up."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%writefile myriad1.sh\n",
"\n",
"cat <<EOF > 97-myriad-usbboot.rules\n",
"SUBSYSTEM==\"usb\", ATTRS{idProduct}==\"2150\", ATTRS{idVendor}==\"03e7\", GROUP=\"users\", MODE=\"0666\", ENV{ID_MM_DEVICE_IGNORE}=\"1\"\n",
"SUBSYSTEM==\"usb\", ATTRS{idProduct}==\"2485\", ATTRS{idVendor}==\"03e7\", GROUP=\"users\", MODE=\"0666\", ENV{ID_MM_DEVICE_IGNORE}=\"1\"\n",
"SUBSYSTEM==\"usb\", ATTRS{idProduct}==\"f63b\", ATTRS{idVendor}==\"03e7\", GROUP=\"users\", MODE=\"0666\", ENV{ID_MM_DEVICE_IGNORE}=\"1\"\n",
"EOF"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%bash\n",
"sh myriad1.sh"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!echo \"intel123\" | sudo -S cp 97-myriad-usbboot.rules /etc/udev/rules.d/ >/dev/null 2>&1"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!echo \"intel123\" | sudo -S udevadm control --reload-rules >/dev/null 2>&1"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!echo \"intel123\" | sudo -S udevadm trigger >/dev/null 2>&1"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<div style=\"font-size: 19px\">\n",
" \n",
"Then check if the device is visible with lsusb."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!lsusb"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<div style=\"font-size: 19px\">\n",
"\n",
"The output will be If using NCS1,\n",
"\n",
"```\n",
"Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub\n",
"Bus 001 Device 015: ID 03e7:2150 \n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<div style=\"font-size: 19px\">\n",
"\n",
"If useing NCS2,\n",
"```\n",
"Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub\n",
"Bus 001 Device 015: ID 03e7:2485 \n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<div style=\"font-size: 19px\">\n",
"Here ID 03e7:2150 without a description string is the Movidius device.\n",
"<br>\n",
"\n",
"Setting up the Environment variables"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"! /opt/intel/openvino/bin/setupvars.sh"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<div style=\"font-size: 19px\">\n",
" \n",
"### Run the sample application on Intel® Movidius™ Neural Compute Stick (NCS)\n",
"\n",
"Set target hardware as Intel® Movidius™ NCS with -d MYRIAD"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!cd /opt/intel/workshop/smart-video-workshop/object-detection && python3 tutorial1.py -i /opt/intel/workshop/smart-video-workshop/object-detection/Cars\\ -\\ 1900.mp4 -m /opt/intel/workshop/smart-video-workshop/object-detection/mobilenet-ssd/FP32/mobilenet-ssd.xml -d MYRIAD"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<div style=\"font-size: 19px\">\n",
"\n",
"You will get an error as Intel® Movidius™ NCS supports only FP16 format. \n",
"<br>\n",
"<img src=\"FP32.png\">\n",
"<br>\n",
"\n",
"The Model Optimizer by default generate FP32 IR files if the data type is not particularly specified.\n",
"\n",
"Let's run the Model Optimizer to get IR files in FP16 format suitable for the Intel® Movidius™ NCS by setting the data_type flag to FP16."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!cd /opt/intel/workshop/smart-video-workshop/object-detection/mobilenet-ssd && mkdir -p FP16"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!cd /opt/intel/openvino/deployment_tools/model_optimizer && python3 mo_caffe.py --input_model /opt/intel/openvino/deployment_tools/tools/model_downloader/object_detection/common/mobilenet-ssd/caffe/mobilenet-ssd.caffemodel -o /opt/intel/workshop/smart-video-workshop/object-detection/mobilenet-ssd/FP16 --scale 256 --mean_values [127,127,127] --data_type FP16"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<div style=\"font-size: 19px\">\n",
" \n",
"Check if the .xml and .bin files are created in folder $SV/object-detection/mobilenet-ssd/FP16."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
" !cd /opt/intel/workshop/smart-video-workshop/object-detection/mobilenet-ssd/FP16 && ls"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<div style=\"font-size: 19px\">\n",
" \n",
"Now run the example application with these new IR files."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!cd /opt/intel/workshop/smart-video-workshop/object-detection/ && python3 tutorial1.py -i /opt/intel/workshop/smart-video-workshop/object-detection/Cars\\ -\\ 1900.mp4 -m /opt/intel/workshop/smart-video-workshop/object-detection/mobilenet-ssd/FP16/mobilenet-ssd.xml -d MYRIAD"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SUBSYSTEM=="usb", ATTRS{idProduct}=="2150", ATTRS{idVendor}=="03e7", GROUP="users", MODE="0666", ENV{ID_MM_DEVICE_IGNORE}="1"
SUBSYSTEM=="usb", ATTRS{idProduct}=="2485", ATTRS{idVendor}=="03e7", GROUP="users", MODE="0666", ENV{ID_MM_DEVICE_IGNORE}="1"
SUBSYSTEM=="usb", ATTRS{idProduct}=="f63b", ATTRS{idVendor}=="03e7", GROUP="users", MODE="0666", ENV{ID_MM_DEVICE_IGNORE}="1"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading