Skip to content

Commit e46a540

Browse files
authored
Merge branch 'openvinotoolkit:master' into master
2 parents e9864f1 + 6537d4c commit e46a540

File tree

53 files changed

+2373
-3493
lines changed

Some content is hidden

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

53 files changed

+2373
-3493
lines changed

demos/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ The Open Model Zoo includes the following demos:
1414
- [BERT Named Entity Recognition Python\* Demo](./bert_named_entity_recognition_demo/python/README.md) - NER Demo application that uses a CONLL2003-tuned BERT model for inference.
1515
- [BERT Question Answering Python\* Demo](./bert_question_answering_demo/python/README.md)
1616
- [BERT Question Answering Embedding Python\* Demo](./bert_question_answering_embedding_demo/python/README.md) - The demo demonstrates how to run BERT based models for question answering task.
17-
- [Classification C++ Demo](./classification_demo/cpp/README.md) - Shows an example of using neural networks for image classification.
17+
- [Classification Python\* Demo](./classification_demo/python/README.md) - Shows an example of using neural networks for image classification.
18+
- [Classification Benchmark C++ Demo](./classification_benchmark_demo/cpp/README.md) - Visualizes OpenVINO performance on inference of neural networks for image classification.
1819
- [Colorization Python\* Demo](./colorization_demo/python/README.md) - Colorization demo colorizes input frames.
1920
- [Crossroad Camera C++ Demo](./crossroad_camera_demo/cpp/README.md) - Person Detection followed by the Person Attributes Recognition and Person Reidentification Retail, supports images/video and camera inputs.
2021
- [Deblurring Python\* Demo](./deblurring_demo/python/README.md) - Demo for deblurring the input images.

demos/classification_demo/cpp/CMakeLists.txt renamed to demos/classification_benchmark_demo/cpp/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
file(GLOB_RECURSE HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp)
66
file(GLOB_RECURSE SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
77

8-
add_demo(NAME classification_demo
8+
add_demo(NAME classification_benchmark_demo
99
SOURCES ${SOURCES}
1010
HEADERS ${HEADERS}
1111
DEPENDENCIES monitors models pipelines)

demos/classification_demo/cpp/README.md renamed to demos/classification_benchmark_demo/cpp/README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# Classification C++ Demo
1+
# Classification Benchmark C++ Demo
2+
3+
![](./classification_benchmark.gif)
24

35
The demo visualize OpenVINO performance on inference of neural networks for image classification.
46

@@ -16,7 +18,7 @@ You can stop the demo by pressing "Esc" or "Q" button. After that, the average m
1618
1719
## Preparing to Run
1820

19-
The list of models supported by the demo is in `<omz_dir>/demos/classification_demo/cpp/models.lst` file.
21+
The list of models supported by the demo is in `<omz_dir>/demos/classification_benchmark_demo/cpp/models.lst` file.
2022
This file can be used as a parameter for [Model Downloader](../../../tools/model_tools/README.md) and Converter to download and, if necessary, convert models to OpenVINO Inference Engine format (\*.xml + \*.bin).
2123

2224
An example of using the Model Downloader:
@@ -147,7 +149,7 @@ and `<omz_dir>/data/dataset_classes/imagenet_2012.txt` labels file with all othe
147149
Running the application with the `-h` option yields the following usage message:
148150

149151
```
150-
classification_demo [OPTION]
152+
classification_benchmark_demo [OPTION]
151153
Options:
152154
153155
-h Print a usage message.
@@ -179,7 +181,7 @@ For higher FPS, it is recommended to use -nireq which slightly exceeds -nstreams
179181
For example, use the following command-line command to run the application:
180182

181183
```sh
182-
./classification_demo -m <path_to_classification_model> \
184+
./classification_benchmark_demo -m <path_to_classification_model> \
183185
-i <path_to_folder_with_images> \
184186
-labels <path_to_file_with_list_of_labels> \
185187
-gt <path_to_ground_truth_data_file> \
1.36 MB
Loading

demos/classification_demo/cpp/main.cpp renamed to demos/classification_benchmark_demo/cpp/main.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ DEFINE_string(u, "", utilization_monitors_message);
7070

7171
static void showUsage() {
7272
std::cout << std::endl;
73-
std::cout << "classification_demo [OPTION]" << std::endl;
73+
std::cout << "classification_benchmark_demo [OPTION]" << std::endl;
7474
std::cout << "Options:" << std::endl;
7575
std::cout << std::endl;
7676
std::cout << " -h " << help_message << std::endl;
@@ -282,20 +282,22 @@ int main(int argc, char *argv[]) {
282282
throw std::invalid_argument("Renderer: image provided in metadata is empty");
283283
}
284284
PredictionResult predictionResult = PredictionResult::Incorrect;
285+
std::string label = classificationResult.topLabels.front().label;
285286
if (!FLAGS_gt.empty()) {
286287
for (size_t i = 0; i < FLAGS_nt; i++) {
287-
unsigned predictedClass = classificationResult.topLabels[i].first;
288+
unsigned predictedClass = classificationResult.topLabels[i].id;
288289
if (predictedClass == classificationImageMetaData.groundTruthId) {
289290
predictionResult = PredictionResult::Correct;
290291
correctPredictionsCount++;
292+
label = classificationResult.topLabels[i].label;
291293
break;
292294
}
293295
}
294296
} else {
295297
predictionResult = PredictionResult::Unknown;
296298
}
297299
framesNum++;
298-
gridMat.updateMat(outputImg, classificationResult.topLabels.front().second, predictionResult);
300+
gridMat.updateMat(outputImg, label, predictionResult);
299301
accuracy = static_cast<double>(correctPredictionsCount) / framesNum;
300302
gridMat.textUpdate(metrics, classificationResult.metaData->asRef<ImageMetaData>().timeStamp, accuracy, FLAGS_nt, isTestMode,
301303
!FLAGS_gt.empty(), presenter);
Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
# Classification Python\* Demo
2+
3+
![](./classification.gif)
4+
5+
This demo showcases inference of Classification networks using Python\* Model API and Async Pipeline.
6+
7+
## How It Works
8+
9+
On startup, the application reads command line parameters and loads a classification network to the Inference Engine for execution. Upon getting a frame from the OpenCV VideoCapture, it performs inference and displays the results.
10+
11+
You can stop the demo by pressing "Esc" or "Q" button. After that, the average metrics values will be printed to the console.
12+
13+
> **NOTE**: By default, Open Model Zoo demos expect input with BGR channels order. If you trained your model to work with RGB order, you need to manually rearrange the default channels order in the demo application or reconvert your model using the Model Optimizer tool with the `--reverse_input_channels` argument specified. For more information about the argument, refer to **When to Reverse Input Channels** section of [Converting a Model Using General Conversion Parameters](https://docs.openvino.ai/latest/openvino_docs_MO_DG_prepare_model_convert_model_Converting_Model.html#general-conversion-parameters).
14+
15+
## Preparing to Run
16+
17+
The list of models supported by the demo is in `<omz_dir>/demos/classification_demo/python/models.lst` file.
18+
This file can be used as a parameter for [Model Downloader](../../../tools/model_tools/README.md) and Converter to download and, if necessary, convert models to OpenVINO Inference Engine format (\*.xml + \*.bin).
19+
20+
An example of using the Model Downloader:
21+
22+
```sh
23+
omz_downloader --list models.lst
24+
```
25+
26+
An example of using the Model Converter:
27+
28+
```sh
29+
omz_converter --list models.lst
30+
```
31+
32+
### Supported Models
33+
34+
* alexnet
35+
* caffenet
36+
* densenet-121
37+
* densenet-121-caffe2
38+
* densenet-121-tf
39+
* densenet-161
40+
* densenet-161-tf
41+
* densenet-169
42+
* densenet-169-tf
43+
* densenet-201
44+
* densenet-201-tf
45+
* dla-34
46+
* efficientnet-b0
47+
* efficientnet-b0_auto_aug
48+
* efficientnet-b0-pytorch
49+
* efficientnet-b5
50+
* efficientnet-b5-pytorch
51+
* efficientnet-b7_auto_aug
52+
* efficientnet-b7-pytorch
53+
* googlenet-v1
54+
* googlenet-v1-tf
55+
* googlenet-v2
56+
* googlenet-v3
57+
* googlenet-v3-pytorch
58+
* googlenet-v4-tf
59+
* hbonet-0.25
60+
* hbonet-0.5
61+
* hbonet-1.0
62+
* inception-resnet-v2-tf
63+
* mixnet-l
64+
* mobilenet-v1-0.25-128
65+
* mobilenet-v1-0.50-160
66+
* mobilenet-v1-0.50-224
67+
* mobilenet-v1-1.0-224
68+
* mobilenet-v1-1.0-224-tf
69+
* mobilenet-v2
70+
* mobilenet-v2-1.0-224
71+
* mobilenet-v2-1.4-224
72+
* mobilenet-v2-pytorch
73+
* nfnet-f0
74+
* octave-densenet-121-0.125
75+
* octave-resnet-101-0.125
76+
* octave-resnet-200-0.125
77+
* octave-resnet-26-0.25
78+
* octave-resnet-50-0.125
79+
* octave-resnext-101-0.25
80+
* octave-resnext-50-0.25
81+
* octave-se-resnet-50-0.125
82+
* regnetx-3.2gf
83+
* repvgg-a0
84+
* repvgg-b1
85+
* repvgg-b3
86+
* resnest-50-pytorch
87+
* resnet-18-pytorch
88+
* resnet-50-caffe2
89+
* resnet-50-pytorch
90+
* resnet-50-tf
91+
* resnet18-xnor-binary-onnx-0001
92+
* resnet50-binary-0001
93+
* rexnet-v1-x1.0
94+
* se-inception
95+
* se-resnet-101
96+
* se-resnet-152
97+
* se-resnet-50
98+
* se-resnext-101
99+
* se-resnext-50
100+
* shufflenet-v2-x0.5
101+
* shufflenet-v2-x1.0
102+
* squeezenet1.0
103+
* squeezenet1.1
104+
* squeezenet1.1-caffe2
105+
* swin-tiny-patch4-window7-224
106+
* vgg16
107+
* vgg19
108+
* vgg19-caffe2
109+
110+
> **NOTE**: Refer to the tables [Intel's Pre-Trained Models Device Support](../../../models/intel/device_support.md) and [Public Pre-Trained Models Device Support](../../../models/public/device_support.md) for the details on models inference support at different devices.
111+
112+
### Required Files
113+
114+
If you want to see classification results, you must use "-labels" flags to specify .txt file containing lists of classes and labels.
115+
116+
Please note that you should use `<omz_dir>/data/dataset_classes/imagenet_2015.txt` labels file with the following models:
117+
118+
* googlenet-v2
119+
* se-inception
120+
* se-resnet-101
121+
* se-resnet-152
122+
* se-resnet-50
123+
* se-resnext-101
124+
* se-resnext-50
125+
126+
and `<omz_dir>/data/dataset_classes/imagenet_2012.txt` labels file with all other models supported by the demo.
127+
128+
## Running
129+
130+
Running the application with the `-h` option yields the following usage message:
131+
132+
```
133+
usage: classification_demo.py [-h] -m MODEL -i INPUT [-d DEVICE] --labels LABELS [-ntop {1,2,3,4,5,6,7,8,9,10}]
134+
[-nireq NUM_INFER_REQUESTS] [-nstreams NUM_STREAMS] [-nthreads NUM_THREADS] [--loop]
135+
[-o OUTPUT] [-limit OUTPUT_LIMIT] [--no_show] [--output_resolution OUTPUT_RESOLUTION]
136+
[-u UTILIZATION_MONITORS] [--reverse_input_channels]
137+
[--mean_values MEAN_VALUES MEAN_VALUES MEAN_VALUES]
138+
[--scale_values SCALE_VALUES SCALE_VALUES SCALE_VALUES] [-r]
139+
140+
Options:
141+
-h, --help Show this help message and exit.
142+
-m MODEL, --model MODEL
143+
Required. Path to an .xml file with a trained model.
144+
-i INPUT, --input INPUT
145+
Required. An input to process. The input must be a single image, a folder of images, video
146+
file or camera id.
147+
-d DEVICE, --device DEVICE
148+
Optional. Specify the target device to infer on; CPU, GPU, HDDL or MYRIAD is acceptable. The
149+
demo will look for a suitable plugin for device specified. Default value is CPU.
150+
151+
Common model options:
152+
--labels LABELS Required. Labels mapping file.
153+
-ntop {1,2,3,4,5,6,7,8,9,10}
154+
Optional. Number of top results. Default value is 5. Must be from 1 to 10.
155+
156+
Inference options:
157+
-nireq NUM_INFER_REQUESTS, --num_infer_requests NUM_INFER_REQUESTS
158+
Optional. Number of infer requests
159+
-nstreams NUM_STREAMS, --num_streams NUM_STREAMS
160+
Optional. Number of streams to use for inference on the CPU or/and GPU in throughput mode (for
161+
HETERO and MULTI device cases use format <device1>:<nstreams1>,<device2>:<nstreams2> or just
162+
<nstreams>).
163+
-nthreads NUM_THREADS, --num_threads NUM_THREADS
164+
Optional. Number of threads to use for inference on CPU (including HETERO cases).
165+
166+
Input/output options:
167+
--loop Optional. Enable reading the input in a loop.
168+
-o OUTPUT, --output OUTPUT
169+
Optional. Name of the output file(s) to save.
170+
-limit OUTPUT_LIMIT, --output_limit OUTPUT_LIMIT
171+
Optional. Number of frames to store in output. If 0 is set, all frames are stored.
172+
--no_show Optional. Don't show output.
173+
--output_resolution OUTPUT_RESOLUTION
174+
Optional. Specify the maximum output window resolution in (width x height) format. Example:
175+
1280x720. Input frame size used by default.
176+
-u UTILIZATION_MONITORS, --utilization_monitors UTILIZATION_MONITORS
177+
Optional. List of monitors to show initially.
178+
179+
Input transform options:
180+
--reverse_input_channels
181+
Optional. Switch the input channels order from BGR to RGB.
182+
--mean_values MEAN_VALUES MEAN_VALUES MEAN_VALUES
183+
Optional. Normalize input by subtracting the mean values per channel. Example: 255 255 255
184+
--scale_values SCALE_VALUES SCALE_VALUES SCALE_VALUES
185+
Optional. Divide input by scale values per channel. Division is applied after mean values
186+
subtraction. Example: 255 255 255
187+
188+
Debug options:
189+
-r, --raw_output_message
190+
Optional. Output inference results raw values showing.
191+
```
192+
193+
Running the application with the empty list of options yields an error message.
194+
195+
For example, use the following command-line command to run the application:
196+
197+
```sh
198+
python3 classification_demo.py -m <path_to_classification_model> \
199+
-i <path_to_folder_with_images> \
200+
--labels <path_to_file_with_list_of_labels>
201+
```
202+
203+
## Demo Output
204+
205+
The demo uses OpenCV to display images with classification results presented as a text on them. The demo reports:
206+
207+
* **FPS**: average rate of video frame processing (frames per second).
208+
* **Latency**: average time required to process one frame (from reading the frame to displaying the results).
209+
* Latency for each of the following pipeline stages:
210+
* **Decoding** — capturing input data.
211+
* **Preprocessing** — data preparation for inference.
212+
* **Inference** — infering input data (images) and getting a result.
213+
* **Postrocessing** — preparation inference result for output.
214+
* **Rendering** — generating output image.
215+
216+
You can use these metrics to measure application-level performance.
217+
218+
## See Also
219+
220+
* [Open Model Zoo Demos](../../README.md)
221+
* [Model Optimizer](https://docs.openvinotoolkit.org/latest/_docs_MO_DG_Deep_Learning_Model_Optimizer_DevGuide.html)
222+
* [Model Downloader](../../../tools/model_tools/README.md)
6.11 MB
Loading

0 commit comments

Comments
 (0)