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

Add catalog to fork #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions HW-Acceleration-with-Movidious-NCS/description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### HW Acceleration with Movidious NCS

description
623 changes: 623 additions & 0 deletions OpenVINO_IoT_Examples_Python.ipynb

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions advanced-video-analytics/description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Advanced Video Analytics

description
1 change: 1 addition & 0 deletions custom-layer/description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
### Custom Layers
52 changes: 52 additions & 0 deletions demoTools/OpenVINO_IoT_Smart_Video_Workshop.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"css": "demoTools/catalog.css",
"status":
{
"serverSideStatusScript": "demoTools/checkStatus.sh",
"serverSideRefreshScript": "demoTools/refreshRepository.sh",
"messages":
{
"placeholder": "(waiting to check the status; click the Check Status button to check immediately)",
"uptodate": "As of {time}, the catalog is up to date.",
"behind": "As of {time}, the catalog requires an update.",
"ahead": "As of {time}, it seems that you are doing your own version control.",
"unable": "As of {time}, we are unable to determine the catalog status due to a server-side error.",
"foreword": "Upon refresh, we will pull the latest examples from GitHub.<br /><b>After the refresh, you will lose any changes you have made to the demos and any data that your demo runs may have generated.</b><br/>",
"remote": "Remote URL",
"lastCheck": "Server-side time of last status check",
"gitsaid": "Output of 'git status'"
},
"button": "Refresh Catalog",
"reloadCode": "<script>window.location.reload()</script>",
"autorunFirstDelay": "1500",
"autorunInterval": "-1"
},
"intro": false,
"list":
{
"header": "Smart Video Workshop",
"repo_root" : "https://github.com/intel-iot-devkit/smart-video-workshop/blob/master/",
"labs":
[
"advanced-video-analytics/multiple_models.md",
"dl-model-training/README.md",
"object-detection/README.md",
"up2-vision-kit/openvino-projects-using-iss2019.md",
"optimization-tools-and-techniques/README.md",
"custom-layer/README.md",
"safety-gear-example/README.md",
"presentations/README.md",
"hardware-heterogeneity/README.md",
"HW-Acceleration-with-Movidious-NCS/README.md"
],
"messages":
{
"goto": "Go to Lab"
}
},

"messages":
{
"toggle": "Show/Hide Code Cells"
}
}
Binary file added demoTools/__pycache__/catalog.cpython-35.pyc
Binary file not shown.
50 changes: 50 additions & 0 deletions demoTools/catalog.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<style>
a.big-jupyter-button, button.jupyter-button
{
line-height:40px;
height:40px;
display:inline-block;
background-color:#0071c5;
color:white;
border:none;
font-size:100%;
font-weight:bold;
cursor:pointer;
padding-left:1em;
padding-right:1em;
margin-top:10px;
text-decoration:none !important;
}
a.big-jupyter-button:hover
{
-webkit-box-shadow: 0 2px 2px 0 rgba(0, 0, 0, .14), 0 3px 1px -2px rgba(0, 0, 0, .2), 0 1px 5px 0 rgba(0, 0, 0, .12);

box-shadow: 0 2px 2px 0 rgba(0, 0, 0, .14), 0 3px 1px -2px rgba(0, 0, 0, .2), 0 1px 5px 0 rgba(0, 0, 0, .12);
}
div.ahead > div.p-Collapse > div.p-Collapse-header
{
background-color:#8800aa;
color:white;
}
div.behind > div.p-Collapse > div.p-Collapse-header
{
background-color:#ffaa00;
color:white;
}
div.unable > div.p-Collapse > div.p-Collapse-header
{
background-color:#cc0000;
color:white;
}
div.uptodate > div.p-Collapse > div.p-Collapse-header
{
background-color:#008800;
color:white;
}
.rendered_html h2, .rendered_html h2:first-child, .rendered_html h3
{
margin-top:3em;
}


</style>
126 changes: 126 additions & 0 deletions demoTools/catalog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
from IPython.core.display import HTML, Markdown
import ipywidgets as widgets
import subprocess
import json
import os.path

class DemoCatalog:

def __init__(self, config_file):
self.config_file = config_file
with open(config_file, "r") as config:
self.conf = json.load(config)
config.close()
with open(self.conf['css']) as css:
self.css = css.read()
css.close()

def ShowRepositoryControls(self):
url, status, lastCheck, fullstatus = self.GetStatus()
msgs = self.conf['status']['messages']
if int(status) == 0:
c = 'uptodate'
elif int(status) == 1:
c = 'behind'
elif int(status) == 2:
c = 'ahead'
else:
c = 'unable'
v = msgs[c].format(time=lastCheck)

display(HTML(self.css))

w_url = widgets.HTML(value=("{remote}: {remote_url}").format(remote=msgs['remote'], remote_url=url))
w_time = widgets.HTML(value=("{time}: {lastCheck}").format(time=msgs['lastCheck'], lastCheck=lastCheck))
w_git = widgets.HTML(value=("{gitsaid}: {gitline}").format(gitsaid=msgs['gitsaid'], gitline=fullstatus))
w_hint = widgets.HTML(value=msgs['foreword'])
w_refresh=widgets.Button(description=self.conf['status']['button'])
w_info=widgets.VBox([w_refresh, w_hint, w_url, w_time, w_git])
w_acc=widgets.Accordion(children=[w_info], selected_index=None)
w_acc.set_title(0, v)
w_acc.add_class(c)
display(w_acc)

self.refreshButton = w_refresh
self.refreshButton.on_click(self.RefreshRepository)

def ShowCatalog(self):
self.ShowIntro()
self.ShowListOfDemos()

def ShowIntro(self):
if (self.conf['intro']):
with open("description.md", "r") as readme:
cont=readme.read()
readme.close()
display(Markdown(cont))

def ShowListOfDemos(self):
data = "## "+self.conf['list']['header']+"\n"
for lab in self.conf['list']['labs']:
lab_dir=os.path.dirname(lab)
with open(lab_dir+"/description.md", "r") as readme:
cont=readme.read()
readme.close()
data += cont
title = cont[0]
data += "\n<a href='"+self.conf["list"]["repo_root"]+lab+"' target='_blank' class='big-jupyter-button'>"+self.conf['list']['messages']['goto']+": "+lab+"</a>\n"
display(Markdown(data))

def GetStatus(self):
cmd = self.conf['status']['serverSideStatusScript']
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
output,_ = p.communicate()
data = output.decode().split("\n")
return data[0], data[1], data[2], data[3]

def RefreshRepository(self, evt):
self.refreshButton.disabled = True
cmd = self.conf['status']['serverSideRefreshScript']
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
output,_ = p.communicate()
display(HTML(self.conf['status']['reloadCode']))

def Anchor(self, name):
display(HTML("<a class='"+name+"'></a>"))

def Autorun(self, name):
display(HTML("<script>"+
"function ClickRunGenerate() {"+
" var code_cells = document.getElementsByClassName('code_cell');"+
" if (code_cells.length > 0) {"+
" var i;"+
" for (i = 0; i < code_cells.length; i++) {"+
" var anch = code_cells[i].getElementsByClassName('"+name+"');"+
" if (anch.length > 0) {"+
" var rtc = code_cells[i].getElementsByClassName('run_this_cell');"+
" if (rtc.length > 0) {"+
" var j;"+
" for (j = 0; j < rtc.length; j++) {"+
" rtc[j].click();"+
" }"+
" }"+
" }"+
" }"+
" }"+
" if ("+self.conf['status']['autorunInterval']+" > 0) {"+
" setTimeout(ClickRunGenerate, "+self.conf['status']['autorunInterval']+");"+
" }"+
"}"+
"setTimeout(ClickRunGenerate, "+self.conf['status']['autorunFirstDelay']+");"+
"</script>"))

def ToggleCode(self):
display(HTML("<script>"+
"codeShow=true;"+
"function CodeToggle() {"+
" if (codeShow) {"+
" $('div.input').hide();"+
" } else {"+
" $('div.input').show();"+
" }"+
" codeShow = !codeShow;"+
"}"+
"$( document ).ready(CodeToggle);"+
"</script>"+
"<form action='javascript:CodeToggle()'><input type='submit' value='"+self.conf['messages']['toggle']+"'></form>"))
16 changes: 16 additions & 0 deletions demoTools/checkStatus.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
rem=`git config --get remote.origin.url`
echo $rem
git remote update &>/dev/null
st=`git status | awk 'NR==2'`
if [ `echo $st | grep -c 'branch is up-to-date'` -eq 1 ]; then
echo 0
elif [ `echo $st | grep -c 'branch is behind'` -eq 1 ]; then
echo 1
elif [ `echo $st | grep -c 'branch is ahead'` -eq 1 ]; then
echo 2
else
echo 3
fi
date
echo $st
4 changes: 4 additions & 0 deletions demoTools/refreshRepository.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
git clean -f -d
git checkout -- ./
git pull
3 changes: 3 additions & 0 deletions dl-model-training/description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Deep Learning Model Training

description
3 changes: 3 additions & 0 deletions hardware-heterogeneity/description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Hardware Heterogeneity

description
3 changes: 3 additions & 0 deletions object-detection/description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Object detection

description
3 changes: 3 additions & 0 deletions optimization-tools-and-techniques/description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Optimization Tools And Techniques

description
3 changes: 3 additions & 0 deletions presentations/description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Presentations


3 changes: 3 additions & 0 deletions safety-gear-example/description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Safety Gear Example

description
85 changes: 85 additions & 0 deletions up2-vision-kit/HW-Acceleration-with-Movidious-NCS/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@

# Intel® Movidius™ Neural Compute Stick (NCS)

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.

#### Connect Intel® Movidius™ Neural Compute Stick to your development laptop
<br>

![image of Movidius NCS to computer](https://github.com/intel-iot-devkit/smart-video-workshop/blob/master/images/Movidius.png "connected NCS")

<br>

#### System check
First make sure the USB rules are set up.

cat <<EOF > 97-myriad-usbboot.rules
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"
EOF


sudo cp 97-myriad-usbboot.rules /etc/udev/rules.d/

sudo udevadm control --reload-rules

sudo udevadm trigger

Then check if the device is visible with lsusb.

lsusb

The output will be
If using NCS1,

Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 015: ID 03e7:2150

If useing NCS2,

Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 015: ID 03e7:2485

Here ID 03e7:2150 without a description string is the Movidius device.

#### Setup a short path for the workshop directory

export SV=/opt/intel/workshop/smart-video-workshop/
source /opt/intel/openvino/bin/setupvars.sh

#### Run the sample application on Intel® Movidius™ Neural Compute Stick (NCS)
Set target hardware as Intel® Movidius™ NCS with **-d MYRIAD**

cd $SV/object-detection/

```
./tutorial1 -i $SV/object-detection/Cars\ -\ 1900.mp4 -m $SV/object-detection/mobilenet-ssd/FP32/mobilenet-ssd.xml -d MYRIAD
```
You will get following error as Intel® Movidius™ NCS supports only FP16 format.
<br>

![image of Movidius NCS error for FP32 model](https://github.com/intel-iot-devkit/smart-video-workshop/blob/master/images/NCSerror.png)

<br>

The Model Optimizer by default generate FP32 IR files if the data type is not particularly specified.

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.

cd $SV/object-detection/mobilenet-ssd
mkdir -p FP16

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 $SV/object-detection/mobilenet-ssd/FP16 --scale 256 --mean_values [127,127,127] --data_type FP16

Check if the .xml and .bin files are created in folder $SV/object-detection/mobilenet-ssd/FP16.

cd $SV/object-detection/mobilenet-ssd/FP16
ls

Now run the example application with these new IR files.

cd $SV/object-detection/
./tutorial1 -i $SV/object-detection/Cars\ -\ 1900.mp4 -m $SV/object-detection/mobilenet-ssd/FP16/mobilenet-ssd.xml -d MYRIAD
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### HW Acceleration with Movidious NCS

description
Binary file added up2-vision-kit/ISS_Delete_Build.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading