Spaces:
Running
Running
File size: 6,866 Bytes
a083fd4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
# Code deployment
## Table of contents
- [Introduction](#introduction)
- [Prerequisites](#prerequisites)
- [Installation](#Installation)
- [Usage](#usage)
- [Troubleshooting](#troubleshooting)
- [Package contents](#package-contents)
## Introduction
This code deployment .zip archive contains:
1. Inference model(s) for your Intel® Geti™ project.
2. A sample image or video frame, exported from your project.
3. A very simple code example to get and visualize the result of inference for your
project, on the sample image.
4. Jupyter notebooks with instructions and code for running inference for your project,
either locally or via the OpenVINO Model Server (OVMS).
The deployment holds one model for each task in your project, so if for example
you created a deployment for a `Detection -> Classification` project, it will consist of
both a detection, and a classification model. The Intel® Geti™ SDK is used to run
inference for all models in the project's task chain.
This README describes the steps required to get the code sample up and running on your
machine.
## Prerequisites
- [Python 3.9, 3.10 or 3.11](https://www.python.org/downloads/)
- [*Optional, only for OVMS notebook*] [Docker](https://docs.docker.com/get-docker/)
## Installation
1. Install [prerequisites](#prerequisites). You may also need to
[install pip](https://pip.pypa.io/en/stable/installation/). For example, on Ubuntu
execute the following command to install Python and pip:
```
sudo apt install python3-dev python3-pip
```
If you already have installed pip before, make sure it is up to date by doing:
```
pip install --upgrade pip
```
2. Create a clean virtual environment: <a name="virtual-env-creation"></a>
One of the possible ways for creating a virtual environment is to use `virtualenv`:
```
python -m pip install virtualenv
python -m virtualenv <directory_for_environment>
```
Before starting to work inside the virtual environment, it should be activated:
On Linux and macOS:
```
source <directory_for_environment>/bin/activate
```
On Windows:
```
.\<directory_for_environment>\Scripts\activate
```
Please make sure that the environment contains
[wheel](https://pypi.org/project/wheel/) by calling the following command:
```
python -m pip install wheel
```
> **NOTE**: On Linux and macOS, you may need to type `python3` instead of `python`.
3. In your terminal, navigate to the `example_code` directory in the code deployment
package.
4. Install requirements in the environment:
```
python -m pip install -r requirements.txt
```
5. (Optional) Install the requirements for running the `demo_notebook.ipynb` or
`demo_ovms.ipynb` Juypter notebooks:
```
python -m pip install -r requirements-notebook.txt
```
## Usage
### Local inference
Both `demo.py` script and the `demo_notebook.ipynb` notebook contain a code sample for:
1. Loading the code deployment (and the models it contains) into memory.
2. Loading the `sample_image.jpg`, which is a random image taken from the project you
deployed.
3. Running inference on the sample image.
4. Visualizing the inference results.
### Inference with OpenVINO Model Server
The additional demo notebook `demo_ovms.ipynb` shows how to set up and run an OpenVINO
Model Server for your deployment, and make inference requests to it. The notebook
contains instructions and code to:
1. Generate a configuration file for OVMS.
2. Launch an OVMS docker container with the proper configuration.
3. Load the image `sample_image.jpg`, as an example image to run inference on.
4. Make an inference request to OVMS.
5. Visualize the inference results.
### Running the demo script
In your terminal:
1. Make sure the virtual environment created [above](#virtual-env-creation) is activated.
2. Make sure you are in the `example_code` directory in your terminal.
3. Run the demo using:
```
python demo.py
```
The script will run inference on the `sample_image.jpg`. A window will pop up that
displays the image, and the results of the inference visualized on top of it.
### Running the demo notebooks
In your terminal:
1. Make sure the virtual environment created [above](#virtual-env-creation) is activated.
2. Make sure you are in the `example_code` directory in your terminal.
3. Start JupyterLab using:
```
jupyter lab
```
4. This should launch your web browser and take you to the main page of JupyterLab.
Inside JuypterLab:
5. In the sidebar of the JupyterLab interface, double-click on `demo_notebook.ipynb` or
`demo_ovms.ipynb` to open one of the notebooks.
6. Execute the notebook cell by cell to view the inference results.
> **NOTE** The `demo_notebook.ipynb` is a great way to explore the `AnnotationScene`
> object that is returned by the inference. The demo code only has very basic
> visualization functionality, which may not be sufficient for all use case. For
> example if your project contains many labels, it may not be able to visualize the
> results very well. In that case, you should build your own visualization logic
> based on the `AnnotationScene` returned by the `deployment.infer()` method.
## Troubleshooting
1. If you have access to the Internet through a proxy server only, please use pip
with a proxy call as demonstrated by the command below:
```
python -m pip install --proxy http://<usr_name>:<password>@<proxyserver_name>:<port#> <pkg_name>
```
2. If you use Anaconda as environment manager, please consider that OpenVINO has
limited [Conda support](https://docs.openvino.ai/2021.4/openvino_docs_install_guides_installing_openvino_conda.html).
It is still possible to use `conda` to create and activate your python environment,
but in that case please use only `pip` (rather than `conda`) as a package manager
for installing packages in your environment.
3. If you have problems when you try to use the `pip install` command, please update
pip version as per the following command:
```
python -m pip install --upgrade pip
```
## Package contents
The code deployment files are structured as follows:
- deployment
- `project.json`
- "<title of task 1>"
- model
- `model.xml`
- `model.bin`
- `config.json`
- python
- model_wrappers
- `__init__.py`
- model_wrappers required to run demo
- `README.md`
- `LICENSE`
- `demo.py`
- `requirements.txt`
- "<title of task 2>" (Optional)
- ...
- example_code
- `demo.py`
- `demo_notebook.ipynb`
- `demo_ovms.ipynb`
- `README.md`
- `requirements.txt`
- `requirements-notebook.txt`
- `sample_image.jpg`
- `LICENSE` |