Skip to content

Commit

Permalink
Merge branch 'main' into facies_segmentation_demo
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeyhorkin committed Jul 19, 2021
2 parents 1cc782f + 811c3c7 commit 77b6fab
Show file tree
Hide file tree
Showing 25 changed files with 801 additions and 89 deletions.
4 changes: 4 additions & 0 deletions .binder/apt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
libpython3.7-dev
ffmpeg
libsm6
libxext6
4 changes: 4 additions & 0 deletions .binder/postBuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
rm -rf notebooks/102-pytorch-onnx-to-openvino
rm -rf notebooks/301-tensorflow-training-openvino

sed -i 's/"PADDLEGAN_INFERENCE = True/"PADDLEGAN_INFERENCE = False/' notebooks/206-vision-paddlegan-anime/206-vision-paddlegan-anime.ipynb
21 changes: 21 additions & 0 deletions .binder/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
openvino-dev[onnx,tensorflow2]==2021.4.*
matplotlib<3.4
gdown
pytube

# ONNX notebook requirements
geffnet==0.9.8
fastseg
ipywidgets

torch>=1.5.1,<=1.7.1; sys_platform == 'darwin'
torchvision>=0.6.1,<=0.8.2; sys_platform == 'darwin'
--find-links https://download.pytorch.org/whl/torch_stable.html
torch>=1.5.1+cpu,<=1.7.1+cpu; sys_platform =='linux' or platform_system == 'Windows'
torchvision>=0.6.1+cpu,<=0.8.2+cpu; sys_platform =='linux' or platform_system == 'Windows'

# Pin versions to prevent known dependency issues
ipython==7.10.*
jedi==0.17.2
setuptools>=56.0.0
Pillow==8.2.*
14 changes: 14 additions & 0 deletions .ci/convert_notebooks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Execute notebooks and convert them to Markdown and HTML

htmldir=$PWD"/html_files"
markdowndir=$PWD"/markdown_files"
mkdir -p $htmldir
mkdir -p $markdowndir

git ls-files "*.ipynb" | while read notebook; do
executed_notebook=${notebook/.ipynb/-with-output.ipynb}
echo $executed_notebook
jupyter nbconvert --execute --to notebook --output $executed_notebook --output-dir . --ExecutePreprocessor.kernel_name="python3" $notebook
jupyter nbconvert --to markdown $executed_notebook --output-dir $markdowndir
jupyter nbconvert --to html $executed_notebook --output-dir $htmldir
done
2 changes: 1 addition & 1 deletion .docker/requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ ipywidgets
torch>=1.5.1+cpu,<=1.7.1+cpu
torchvision>=0.6.1+cpu,<=0.8.2+cpu

# Tensorflow notebook requirements
# TensorFlow notebook requirements
networkx>=1.11
defusedxml>=0.5.0
tensorflow==2.4.2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ];
then pip install -r requirements.txt --use-deprecated=legacy-resolver;
then pip install -r requirements.txt;
fi
# Set the `CODEQL-PYTHON` environment variable to the Python executable
# that includes the dependencies
Expand Down
48 changes: 48 additions & 0 deletions .github/workflows/convert_notebooks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Execute notebooks and convert them to Markdown and HTML

name: Convert Notebooks
on:
workflow_dispatch:
push:
branches:
- 'main'
paths:
- "**.ipynb"
jobs:
build:
strategy:
fail-fast: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r .ci/ci-requirements.txt
python -m pip freeze > pip-freeze.txt
- name: Archive pip freeze
uses: actions/upload-artifact@v2
with:
name: pip-freeze
path: pip-freeze.txt
- name: Modify Notebooks
# Change settings in slower notebooks to speed up notebook execution
run: |
sed -i 's/NUM_FRAMES = 100/NUM_FRAMES = 5/g' notebooks/202-vision-superresolution/202-vision-superresolution-video.ipynb
sed -i 's/epochs = 15/epochs = 2/g' notebooks/301-tensorflow-training-openvino/301-tensorflow-training-openvino.ipynb
- name: convert_notebooks
run: bash .ci/convert_notebooks.sh
- name: Save HTML files
uses: actions/upload-artifact@v2
with:
name: html_files
path: html_files
- name: Save Markdown files
uses: actions/upload-artifact@v2
with:
name: markdown_files
path: markdown_files
7 changes: 6 additions & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ on:
pull_request:
paths:
- "Dockerfile"
- ".openshift/**"
- ".docker/**"
- ".github/workflows/docker.yml"
- 'notebooks/**.ipynb'
- 'notebooks/**.py'
- 'requirements.txt'
- '.ci/*requirements.txt'

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/install_requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r .ci/dev-requirements.txt --use-deprecated=legacy-resolver
python -m pip install -r .ci/dev-requirements.txt
python -m ipykernel install --user --name openvino_env
python -m pip freeze > pip-freeze-${{ github.sha }}-${{matrix.os}}-${{ matrix.python }}.txt
- name: Archive pip freeze
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/install_requirements_china.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ jobs:
python-version: ${{ matrix.python }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt --use-deprecated=legacy-resolver -i https://pypi.tuna.tsinghua.edu.cn/simple
python -m pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple
python -m pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
python -m ipykernel install --user --name openvino_env
python -m pip freeze > pip-freeze-${{ github.sha }}-${{matrix.os}}-${{ matrix.python }}.txt
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/nbval.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ on:
pull_request:
branches:
- 'main'
paths-ignore:
- '**.md'
paths:
- 'notebooks/**.ipynb'
- 'notebooks/**.py'
- 'requirements.txt'
- '.ci/*requirements.txt'
- '.github/workflows/nbval.yml'
schedule:
- cron: '30 8 * * *'

Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# 📚 OpenVINO Notebooks
English | [简体中文](README_cn.md)

A collection of ready-to-run Jupyter\* notebooks for learning and experimenting with the OpenVINO™ Toolkit. The notebooks provide an introduction to OpenVINO basics and teach developers how to leverage our API for optimized deep learning inference.
# 📚 OpenVINO™ Notebooks

A collection of ready-to-run Jupyter\* notebooks for learning and experimenting with the OpenVINO™ Toolkit. The notebooks provide an introduction to OpenVINO basics and teach developers how to leverage our API for optimized deep learning inference. Currently we have an API reference, guides for converting/optimizing PyTorch/TensorFlow/PaddlePaddle models, and model demos. [Click here](notebooks/README.md) to see the list of included notebooks.

## ⚙️ System Requirements

Expand All @@ -18,12 +20,12 @@ The notebooks run almost anywhere &mdash; your laptop, a cloud VM, or even a Doc

## 📝 Installation Guide

OpenVINO Notebooks require Python and Git. See instructions below for your operating system:
OpenVINO Notebooks require Python and Git. For Python 3.8, C++ is also required. See instructions below for your operating system:

| [Windows 10](https://github.com/openvinotoolkit/openvino_notebooks/wiki/Windows) | [Ubuntu](https://github.com/openvinotoolkit/openvino_notebooks/wiki/Ubuntu) | [macOS](https://github.com/openvinotoolkit/openvino_notebooks/wiki/macOS) | [Red Hat](https://github.com/openvinotoolkit/openvino_notebooks/wiki/Red-Hat-and-CentOS) | [CentOS](https://github.com/openvinotoolkit/openvino_notebooks/wiki/Red-Hat-and-CentOS) | [Azure ML](https://github.com/openvinotoolkit/openvino_notebooks/wiki/AzureML) |
| -------------------------------------------------------------------------------- | --------------------------------------------------------------------------- | ------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------ |

Once you have installed Python and Git, follow the steps below.
Once you have installed Python, Git and C++, follow the steps below.

### Step 1: Create and Activate `openvino_env` Environment

Expand Down
133 changes: 133 additions & 0 deletions README_cn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
[English](README.md) | 简体中文

# 📚 OpenVINO Notebooks

一些可以运行的Jupyter\* notebooks,用于学习和试验OpenVINO™开发套件。这些notebooks旨在提供OpenVINO基础知识的介绍,并教开发人员如何利用我们的API在应用程序中优化深度学习推理。

## ⚙️ 系统需求

这些notebooks几乎可以在任何地方运行—你的笔记本电脑,一个云虚拟机,甚至一个Docker容器。下表是目前支持的操作系统及Python版本。****:Python3.9目前还不支持,不过即将支持。

| Supported Operating System | [Python Version (64-bit)](https://www.python.org/) |
| :--------------------------------------------------------- | :------------------------------------------------- |
| Ubuntu\* 18.04 LTS, 64-bit | 3.6, 3.7, 3.8 |
| Ubuntu\* 20.04 LTS, 64-bit | 3.6, 3.7, 3.8 |
| Red Hat* Enterprise Linux* 8, 64-bit | 3.6, 3.8 |
| CentOS\* 7, 64-bit | 3.6, 3.7, 3.8 |
| macOS\* 10.15.x versions | 3.6, 3.7, 3.8 |
| Windows 10\*, 64-bit Pro, Enterprise or Education editions | 3.6, 3.7, 3.8 |
| Windows Server\* 2016 or higher | 3.6, 3.7, 3.8 |

## 📝 安装指南

运行OpenVINO Notebooks需要预装Python和Git, 针对不同操作系统的安装参考以下英语指南:

| [Windows 10](https://github.com/openvinotoolkit/openvino_notebooks/wiki/Windows) | [Ubuntu](https://github.com/openvinotoolkit/openvino_notebooks/wiki/Ubuntu) | [macOS](https://github.com/openvinotoolkit/openvino_notebooks/wiki/macOS) | [Red Hat](https://github.com/openvinotoolkit/openvino_notebooks/wiki/Red-Hat-and-CentOS) | [CentOS](https://github.com/openvinotoolkit/openvino_notebooks/wiki/Red-Hat-and-CentOS) | [Azure ML](https://github.com/openvinotoolkit/openvino_notebooks/wiki/AzureML) |
| -------------------------------------------------------------------------------- | --------------------------------------------------------------------------- | ------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------ |

Python和Git安装完成后,参考以下步骤:

### Step 1: 创建并激活 `openvino_env` 虚拟环境

#### Linux 和 macOS 命令:

```bash
python3 -m venv openvino_env
source openvino_env/bin/activate
```

#### Windows 命令:

```bash
python -m venv openvino_env
openvino_env\Scripts\activate
```

### Step 2: 获取源码

```bash
git clone https://github.com/openvinotoolkit/openvino_notebooks.git
cd openvino_notebooks
```

### Step 3: 安装并启动 Notebooks

将pip升级到最新版本。

```bash
python -m pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
python -m ipykernel install --user --name openvino_env
```

## 💻 运行 Notebooks

### 启动单个 Notebook

如果你希望启动单个的notebook(如:Monodepth notebook),运行以下命令:

```bash
jupyter notebook notebooks/201-vision-monodepth/201-vision-monodepth.ipynb
```

### 启动所有 Notebooks

```bash
jupyter lab notebooks
```

在浏览器中,从Jupyter Lab侧边栏的文件浏览器中选择一个notebook文件,每个notebook文件都位于`notebooks`目录中的子目录中。

<img src="https://user-images.githubusercontent.com/15709723/120527271-006fd200-c38f-11eb-9935-2d36d50bab9f.gif">

## 🧹 清理

### 停止 Jupyter Kernel

`Ctrl-c` 结束 Jupyter session,会弹出一个提示框 `Shutdown this Jupyter server (y/[n])?` 输入 `y` 并按 `回车`

### 注销虚拟环境

注销该虚拟环境:只需在激活了 `openvino_env` 的终端窗口中运行 `deactivate` 即可。

重新激活环境:在Linux上运行 `source openvino_env/bin/activate` 或者在Windows上运行 `openvino_env\Scripts\activate` 即可,然后输入 `jupyter lab``jupyter notebook` 即可重新运行notebooks。

### 删除虚拟环境_(可选)_

直接删除 `openvino_env` 目录即可删除虚拟环境:

#### Linux 和 macOS:

```bash
rm -rf openvino_env
```

#### Windows:

```bash
rmdir /s openvino_env
```

### 从Jupyter中移除openvino_env Kernel

```bash
jupyter kernelspec remove openvino_env
```

## ⚠️ 故障排除

如果以下方法无法解决您的问题,欢迎创建一个 [讨论话题](https://github.com/openvinotoolkit/openvino_notebooks/discussions)[issue](https://github.com/openvinotoolkit/openvino_notebooks/issues) !

- 运行 `python check_install.py` 可以帮助检查一些常见的安装问题,该脚本位于openvino_notebooks 目录中。

记得运行该脚本之前先激活 `openvino_env` 虚拟环境。

- 如果出现 `ImportError` ,请检查是否安装了 Jupyter Kernel。如需手动设置kernel,从 Jupyter Lab 或 Jupyter Notebook 的_Kernel->Change Kernel_菜单中选择openvino_env内核。

- 如果OpenVINO是全局安装的,不要在执行了setupvars.bat或setupvars.sh的终端中运行安装命令。

- 对于Windows系统,我们建议使用_Command Prompt (cmd.exe)_,而不是_PowerShell_

---

\* Other names and brands may be claimed as the property of others.
2 changes: 1 addition & 1 deletion notebooks/001-hello-world/001-hello-world.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"\n",
"A very basic introduction to OpenVINO that shows how to do inference on a given IR model.\n",
"\n",
"We use a [MobileNetV3 model](https://docs.openvinotoolkit.org/latest/omz_models_model_mobilenet_v3_small_1_0_224_tf.html) from [Open Model Zoo](https://github.com/openvinotoolkit/open_model_zoo/). See the [Tensorflow to OpenVINO Notebook](101-tensorflow-to-openvino) for information on how this OpenVINO IR model was created.\n",
"We use a [MobileNetV3 model](https://docs.openvinotoolkit.org/latest/omz_models_model_mobilenet_v3_small_1_0_224_tf.html) from [Open Model Zoo](https://github.com/openvinotoolkit/open_model_zoo/). See the [TensorFlow to OpenVINO Notebook](101-tensorflow-to-openvino) for information on how this OpenVINO IR model was created.\n",
"\n"
]
},
Expand Down
2 changes: 1 addition & 1 deletion notebooks/002-openvino-api/002-openvino-api.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"\n",
"An IR (Intermediate Representation) model consists of an .xml file, containing model information, and a .bin file, containing the weights. `read_network()` expects the weights file to be located in the same directory as the xml file, with the same filename, and the extension .bin: `model_weights_file == Path(model_xml).with_suffix(\".bin\")`. If this is the case, specifying the weights file is optional. If the weights file has a different filename, it can be specified with the `weights` parameter to `read_network()`.\n",
"\n",
"See the [tensorflow-to-openvino](../101-tensorflow-to-openvino/101-tensorflow-to-openvino.ipynb) and [pytorch-onnx-to-openvino](../102-pytorch-onnx-to-openvino/102-pytorch-onnx-to-openvino.ipynb) notebooks for information on how to convert your existing Tensorflow, PyTorch or ONNX model to OpenVINO's IR format."
"See the [tensorflow-to-openvino](../101-tensorflow-to-openvino/101-tensorflow-to-openvino.ipynb) and [pytorch-onnx-to-openvino](../102-pytorch-onnx-to-openvino/102-pytorch-onnx-to-openvino.ipynb) notebooks for information on how to convert your existing TensorFlow, PyTorch or ONNX model to OpenVINO's IR format."
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"id": "JwEAhQVzkAwA"
},
"source": [
"# Tensorflow to OpenVINO\n",
"# TensorFlow to OpenVINO\n",
"\n",
"This short tutorial shows how to convert a TensorFlow MobilenetV3 model to OpenVINO IR format.\n",
"Model documentation: https://docs.openvinotoolkit.org/latest/omz_models_model_mobilenet_v3_small_1_0_224_tf.html"
Expand Down
Loading

0 comments on commit 77b6fab

Please sign in to comment.