Skip to content

Commit 731aab4

Browse files
Jakub Debskiryanloneyhelena-intel
authored
Add readmes to notebooks (openvinotoolkit#184)
* [A]Add README for 001 and 002 notebooks * [F] Restructuring notebooks folders * [F] Major restructuring notebooks * [A] Restructuring 102, add temporal user files to gitignore, minor fix to readme 002 * [A] Add readme for 102, add binder button * [F] Fix readmes, add content table section * [F] Fix 104 and 201 notebooks readme * [F] Change structure of files in 202 * [F] Change folder name for notebook 205 * [A] Add output folder to gitignore, add readme and file structure file to contibution guide, modify structure of files in NB206 * [A] Add readme to 202, add local folder creating function to utils, modified name from output to local, add images for both notebooks in 202 * [A] Add 206 readme, add 202 binder buttons * [F] Fix markdown lint * [F] Change crlf to lf * Apply review suggestions * Apply suggestions from code review Co-authored-by: Ryan Loney <ryanloney@gmail.com> * Clean after review * Apply suggestions from code review Co-authored-by: Helena Kloosterman <helena.kloosterman@intel.com> * Apply review suggestions * Fix nbval Co-authored-by: Ryan Loney <ryanloney@gmail.com> Co-authored-by: Helena Kloosterman <helena.kloosterman@intel.com>
1 parent 20e517c commit 731aab4

File tree

57 files changed

+1755
-1765
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1755
-1765
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ htmlcov/
4444
.coverage
4545
.coverage.*
4646
.cache
47+
.idea
4748
nosetests.xml
4849
coverage.xml
4950
*.cover
@@ -97,3 +98,6 @@ dmypy.json
9798

9899
# vim backup files
99100
*~
101+
102+
# Notebook temporal files
103+
notebooks/*/output/**

CONTRIBUTING.md

+36-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
- [Implementation choices](#implementation-choices)
77
- [Other things to keep in mind](#other-things-to-keep-in-mind)
88
- [Notebook naming](#notebook-naming)
9+
- [Writing Readme](#writing-readme)
10+
- [File structure](#file-structure)
911
- [Validation](#validation)
1012
- [Automated tests](#automated-tests)
1113
- [Manual test and code quality tools](#manual-test-and-code-quality-tools)
@@ -97,7 +99,6 @@ To do this, there are a few requirements that all notebooks need to pass.
9799
7. The notebooks should provide an easy way to clean up the downloaded data, for example with a
98100
commented-out cell at the end of the notebook.
99101

100-
101102
### Other things to keep in mind
102103

103104
1. Always provide links to sources. If your notebook implements a model, link to the research paper
@@ -113,9 +114,41 @@ Names should be descriptive but not too long. We use the following numbering sch
113114
- `200-` OpenVINO model demos: demonstrate inference on a particular model.
114115
- `300-` Training notebooks: notebooks that include code to train neural networks.
115116

117+
### Writing README
118+
119+
Every notebook must have readme file briefly describing content of related tutorial. To keep it simple structure is described below:
120+
121+
``` markdown
122+
# Title of Tutorial
123+
[brief intro, basic information about what will be described]
124+
125+
## Notebook Contents
126+
[more details, possibly information about research papers, the model(s) used and/or data]
127+
Additional subsections, e.g license information.
128+
129+
130+
## Installation Instructions
131+
[link to installation guide, other important information for install process]
132+
```
133+
134+
### File structure
135+
136+
To maintain consistency between notebooks, please follow the directory structure outlined below.
137+
138+
```markdown
139+
<three-digit-number>-<title>/
140+
├── README.md
141+
├── <three-digit-number>-<title>.ipynb
142+
├── utils/
143+
├── model/
144+
└── data/
145+
```
146+
147+
In case of output provided by Notebook please create folder ```output``` on the same level as readme file.
148+
116149
## Validation
117150

118-
### Automated tests
151+
### Automated Tests
119152

120153
We use Github Actions to automatically validate that all notebooks work. The automated tests
121154
currently test that the notebooks execute without problems on all supported platform. More granular
@@ -182,7 +215,7 @@ Once your notebook passes in the CI and you have verified that everything looks
182215
4. On making or updating a Pull Request, the tests in the CI will run again. Please keep an
183216
eye on them. If the tests fail and you think the issue is not related to your PR, please make a comment on your PR.
184217

185-
## Help!
218+
## Help
186219

187220
If you need help at any time, please open a
188221
[discussion](https://github.com/openvinotoolkit/openvino_notebooks/issues)! If you think one of the

notebooks/001-hello-world/001-hello-world.ipynb

+29-39
Original file line numberDiff line numberDiff line change
@@ -2,124 +2,114 @@
22
"cells": [
33
{
44
"cell_type": "markdown",
5-
"id": "miniature-figure",
6-
"metadata": {},
75
"source": [
86
"# Hello World\n",
97
"\n",
108
"A very basic introduction to OpenVINO that shows how to do inference on a given IR model.\n",
119
"\n",
1210
"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",
1311
"\n"
14-
]
12+
],
13+
"metadata": {}
1514
},
1615
{
1716
"cell_type": "markdown",
18-
"id": "narrative-officer",
19-
"metadata": {},
2017
"source": [
2118
"## Imports"
22-
]
19+
],
20+
"metadata": {}
2321
},
2422
{
2523
"cell_type": "code",
2624
"execution_count": null,
27-
"id": "european-delivery",
28-
"metadata": {},
29-
"outputs": [],
3025
"source": [
3126
"import json\n",
3227
"\n",
3328
"import cv2\n",
3429
"import matplotlib.pyplot as plt\n",
3530
"import numpy as np\n",
3631
"from openvino.inference_engine import IECore"
37-
]
32+
],
33+
"outputs": [],
34+
"metadata": {}
3835
},
3936
{
4037
"cell_type": "markdown",
41-
"id": "spiritual-bouquet",
42-
"metadata": {},
4338
"source": [
4439
"## Load the network"
45-
]
40+
],
41+
"metadata": {}
4642
},
4743
{
4844
"cell_type": "code",
4945
"execution_count": null,
50-
"id": "statewide-growth",
51-
"metadata": {},
52-
"outputs": [],
5346
"source": [
5447
"ie = IECore()\n",
5548
"net = ie.read_network(\n",
56-
" model=\"v3-small_224_1.0_float.xml\", weights=\"v3-small_224_1.0_float.bin\"\n",
49+
" model=\"model/v3-small_224_1.0_float.xml\", weights=\"model/v3-small_224_1.0_float.bin\"\n",
5750
")\n",
5851
"exec_net = ie.load_network(net, \"CPU\")\n",
5952
"\n",
6053
"input_key = list(exec_net.input_info)[0]\n",
6154
"output_key = list(exec_net.outputs.keys())[0]"
62-
]
55+
],
56+
"outputs": [],
57+
"metadata": {}
6358
},
6459
{
6560
"cell_type": "markdown",
66-
"id": "convertible-literacy",
67-
"metadata": {},
6861
"source": [
6962
"## Load an Image"
70-
]
63+
],
64+
"metadata": {}
7165
},
7266
{
7367
"cell_type": "code",
7468
"execution_count": null,
75-
"id": "simplified-accommodation",
76-
"metadata": {},
77-
"outputs": [],
7869
"source": [
7970
"# The MobileNet network expects images in RGB format\n",
80-
"image = cv2.cvtColor(cv2.imread(\"coco.jpg\"), cv2.COLOR_BGR2RGB)\n",
71+
"image = cv2.cvtColor(cv2.imread(\"data/coco.jpg\"), cv2.COLOR_BGR2RGB)\n",
8172
"input_image = cv2.resize(image, (224, 224)) # resize to MobileNet image shape\n",
8273
"input_image = np.expand_dims(\n",
8374
" input_image.transpose(2, 0, 1), 0\n",
8475
") # reshape to network input shape\n",
8576
"plt.imshow(image)"
86-
]
77+
],
78+
"outputs": [],
79+
"metadata": {}
8780
},
8881
{
8982
"cell_type": "markdown",
90-
"id": "warming-platinum",
91-
"metadata": {},
9283
"source": [
9384
"## Do Inference"
94-
]
85+
],
86+
"metadata": {}
9587
},
9688
{
9789
"cell_type": "code",
9890
"execution_count": null,
99-
"id": "italic-comment",
100-
"metadata": {},
101-
"outputs": [],
10291
"source": [
10392
"result = exec_net.infer(inputs={input_key: input_image})[output_key]\n",
10493
"result_index = np.argmax(result)"
105-
]
94+
],
95+
"outputs": [],
96+
"metadata": {}
10697
},
10798
{
10899
"cell_type": "code",
109100
"execution_count": null,
110-
"id": "complicated-command",
111-
"metadata": {},
112-
"outputs": [],
113101
"source": [
114102
"# Convert the inference result to a class name.\n",
115-
"imagenet_classes = json.loads(open(\"imagenet_class_index.json\").read())\n",
103+
"imagenet_classes = json.loads(open(\"utils/imagenet_class_index.json\").read())\n",
116104
"# The model description states that for this model, class 0 is background,\n",
117105
"# so we add 1 to the network output to get the class name\n",
118106
"imagenet_classes = {\n",
119107
" int(key) + 1: value for key, value in imagenet_classes.items()\n",
120108
"}\n",
121109
"imagenet_classes[result_index]"
122-
]
110+
],
111+
"outputs": [],
112+
"metadata": {}
123113
}
124114
],
125115
"metadata": {
@@ -143,4 +133,4 @@
143133
},
144134
"nbformat": 4,
145135
"nbformat_minor": 5
146-
}
136+
}

notebooks/001-hello-world/README.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Introduction to OpenVINO
2+
3+
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/openvinotoolkit/openvino_notebooks/HEAD?filepath=notebooks%2F001-hello-world%2F001-hello-world.ipynb)
4+
5+
![classification](https://user-images.githubusercontent.com/36741649/127172572-1cdab941-df5f-42e2-a367-2b334a3db6d8.jpg)
6+
7+
This notebook shows how to do inference on an OpenVINO IR model.
8+
9+
## Notebook Contents
10+
11+
This notebook demonstrates usage of [MobileNet V3](https://github.com/openvinotoolkit/open_model_zoo/blob/master/models/public/mobilenet-v3-small-1.0-224-tf/README.md) from [Open Model Zoo](https://github.com/openvinotoolkit/open_model_zoo/)
12+
13+
## Installation Instructions
14+
15+
If you have not done so already, please follow the [Installation Guide](../../README.md) to install all required dependencies.
File renamed without changes.

0 commit comments

Comments
 (0)