Skip to content

Commit 94a2811

Browse files
authored
Merge pull request #3542 from wdkwyf/Sept_version
Update smart science lab demo
2 parents a017fbe + 43b4a3b commit 94a2811

19 files changed

+1930
-670
lines changed

demos/smartlab_demo/python/README.md

Lines changed: 76 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,42 @@
11
# Smartlab Python\* Demo
22

3-
This is the demo application with smartlab action recognition and smartlab object detection algorithms.
4-
This demo takes multi-view video inputs to identify actions and objects, then evaluates scores of current state.
5-
Action recognition architecture uses two encoders for front-view and top-view respectively, and a single decoder.
6-
Object detection uses two models for each view to detect large and small objects, respectively.
3+
This is the demo application with smartlab object detection and smartlab action recognition algorithms.
4+
This demo takes multi-view video inputs to identify objects and actions, then evaluates scores for teacher's reference.
5+
The UI is shown as:
6+
![image](smartlab.gif)
7+
**The left picture** and **right picture** show top view and side view on the test bench respectively. For object detection part,
8+
**blue bounding boxes** are shown. Below these pictures, **progress bar** is shown for action types, and the colors of actions correspond to
9+
the **action names** above. Scoring part is below the entire UI and there are 8 score points. `[1]` means student can
10+
get 1 point while `[0]` means student loses the point. `[-]` means under evaluation.
11+
12+
## Algorithms
13+
Architecture of smart science lab contains object detection, action recognition and scoring evaluator.
714
The following pre-trained models are delivered with the product:
815

9-
* `i3d-rgb-tf` + `smartlab-sequence-modelling-0001`, which are other models for identifying actions 2 actions of smartlab (adjust_rider, put_take).
16+
* `smartlab-object-detection-0001` + `smartlab-object-detection-0002` + `smartlab-object-detection-0003` + `smartlab-object-detection-0004`, which are models
17+
to detect 10 objects including: balance, weights, tweezers, box, battery, tray, ruler, rider, scale, hand.
1018

11-
* `smartlab-object-detection-0001` + `smartlab-object-detection-0002` + `smartlab-object-detection-0003` + `smartlab-object-detection-0004`, which are models for detecting smartlab objects (10 objects). They detect balance, weights, tweezers, box, battery, tray, ruler, rider, scale, hand.
19+
Action recognition include two options:
20+
* --mode multiview: `smartlab-action-recognition-0001-encoder-top` + `smartlab-action-recognition-0001-encoder-side` +
21+
`smartlab-action-recognition-0001-decoder` , identifying 3 action types.
22+
* --mode mstcn: `smartlab-sequence-modelling-0001` + `smartlab-sequence-modelling-0002`, identifying 14 action types.
1223

1324
## How It works
1425

1526
The demo pipeline consists of several steps:
1627

17-
* `Decode` reads frames from the input videos
18-
* `Detector` detects smartlab objects (balance, weights, tweezers, box, battery, tray, ruler, rider scale, hand)
19-
* `Segmentor` segments video frames based on action of the frame
20-
* `Evaluator` calculates scores of the current state
21-
* `Display` displays detected objects, recognized action, calculated scores on the current frame
22-
23-
24-
> **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 [Embedding Preprocessing Computation](@ref openvino_docs_MO_DG_Additional_Optimization_Use_Cases).
28+
* `Decode` read frames from the two input videos
29+
* `Detector` detect objects (balance, weights, tweezers, box, battery, tray, ruler, rider scale, hand)
30+
* `Segmentor` segment and classify video frames based on action type of the frame
31+
* `Evaluator` give scores of the current state
32+
* `Display` display the whole UI
2533

2634
## Preparing to Run
27-
For demo input image or video files, you need to provide smartlab videos (https://storage.openvinotoolkit.org/data/test_data/videos/smartlab/).
28-
The list of models supported by the demo is in `<omz_dir>/demos/smartlab_demo/python/models.lst` file.
29-
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 format (\*.xml + \*.bin).
35+
Example input video: https://storage.openvinotoolkit.org/data/test_data/videos/smartlab/v3.
3036

37+
The list of models supported by the demo is in `<omz_dir>/demos/smartlab_demo/python/models.lst` file.
38+
This file can be used as a parameter for [Model Downloader](../../../tools/model_tools/README.md) to download.
3139
An example of using the Model Downloader:
32-
3340
```sh
3441
omz_downloader --list models.lst
3542
```
@@ -39,62 +46,86 @@ omz_downloader --list models.lst
3946
* smartlab-object-detection-0002
4047
* smartlab-object-detection-0003
4148
* smartlab-object-detection-0004
42-
* smartlab-sequence-modelling-0001
43-
* i3d-rgb-tf
49+
* mode mtcnn
50+
- smartlab-sequence-modelling-0001
51+
- smartlab-sequence-modelling-0002
52+
* mode multiview
53+
- smartlab-action-recognition-0001-encoder-top
54+
- smartlab-action-recognition-0001-encoder-side
55+
- smartlab-action-recognition-0001-decoder
56+
4457

45-
> **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.
58+
> **NOTE**: Refer to the tables [Intel's Pre-Trained Models Device Support](../../../models/intel/device_support.md) for
59+
> the details on models inference support at different devices.
4660
4761
## Running
4862

4963
Running the demo with `-h` shows this help message:
5064
```
51-
usage: smartlab_demo.py [-h] [-d DEVICE] -tv TOPVIEW -fv FRONTVIEW -m_ta M_TOPALL -m_tm M_TOPMOVE -m_fa M_FRONTALL
52-
-m_fm M_FRONTMOVE -m_en M_ENCODER -m_de M_DECODER
65+
usage: smartlab_demo.py [-h] [-d DEVICE] -tv TOPVIEW -sv SIDEVIEW -m_ta M_TOPALL -m_tm M_TOPMOVE -m_sa M_SIDEALL
66+
-m_sm M_SIDEMOVE -m_de M_DECODER -m_en M_ENCODER [-m_en_t M_ENCODER_TOP -m_en_s M_ENCODER_SIDE]
5367
5468
Options:
5569
-h, --help Show this help message and exit.
5670
-d DEVICE, --device DEVICE
5771
Optional. Specify the target to infer on CPU or GPU.
5872
-tv TOPVIEW, --topview TOPVIEW
59-
Required. Topview stream to be processed. The input must be a single image, a folder of images,
60-
video file or camera id.
61-
-fv FRONTVIEW, --frontview FRONTVIEW
62-
Required. FrontView to be processed. The input must be a single image, a folder of images,
63-
video file or camera id.
73+
Required. Topview stream to be processed. The input must be a single image, a folder of images, video file or
74+
camera id.
75+
-sv SIDEVIEW, --sideview SIDEVIEW
76+
Required. SideView to be processed. The input must be a single image, a folder of images, video file or camera
77+
id.
6478
-m_ta M_TOPALL, --m_topall M_TOPALL
6579
Required. Path to topview all class model.
6680
-m_tm M_TOPMOVE, --m_topmove M_TOPMOVE
6781
Required. Path to topview moving class model.
68-
-m_fa M_FRONTALL, --m_frontall M_FRONTALL
69-
Required. Path to frontview all class model.
70-
-m_fm M_FRONTMOVE, --m_frontmove M_FRONTMOVE
71-
Required. Path to frontview moving class model.
72-
-m_en M_ENCODER, --m_encoder M_ENCODER
73-
Required. Path to encoder model.
82+
-m_sa M_SIDEALL, --m_sideall M_SIDEALL
83+
Required. Path to sidetview all class model.
84+
-m_sm M_SIDEMOVE, --m_sidemove M_SIDEMOVE
85+
Required. Path to sidetview moving class model.
86+
--mode MODE Optional. Action recognition mode: multiview or mstcn
87+
-m_en_t M_ENCODER_TOP, --m_encoder_top M_ENCODER_TOP
88+
Required for multiview mode. Path to encoder model for topview.
89+
-m_en_s M_ENCODER_SIDE, --m_encoder_side M_ENCODER_SIDE
90+
Required for multiview mode. Path to encoder model for sideview.
7491
-m_de M_DECODER, --m_decoder M_DECODER
75-
Required. Path to decoder model.
92+
Required for both multiview and mstcn mode. Path to decoder model.
93+
-m_en M_ENCODER, --m_encoder M_ENCODER
94+
Required for mstcn mode. Path to encoder model.
7695
```
7796

78-
**For example**, to run the demo, please provide the model paths and two input streams:
79-
97+
For example, run the demo with multiview mode:
98+
```sh
99+
python3 smartlab_demo.py
100+
-tv stream_1_top.mp4
101+
-sv stream_1_left.mp4
102+
-m_ta "./intel/smartlab-object-detection-0001/FP32/smartlab-object-detection-0001.xml"
103+
-m_tm "./intel/smartlab-object-detection-0002/FP32/smartlab-object-detection-0002.xml"
104+
-m_sa "./intel/smartlab-object-detection-0003/FP32/smartlab-object-detection-0003.xml"
105+
-m_sm "./intel/smartlab-object-detection-0004/FP32/smartlab-object-detection-0004.xml"
106+
-m_en_t "./intel/smartlab-action-recognition-0001-encoder-top/FP32/smartlab-action-recognition-0001-encoder-top.xml"
107+
-m_en_s "./intel/smartlab-action-recognition-0001-encoder-side/FP32/smartlab-action-recognition-0001-encoder-side.xml"
108+
-m_de "./intel/smartlab-action-recognition-0001-decoder/FP32/smartlab-action-recognition-0001-decoder.xml"
109+
```
110+
run the demo with mstcn mode:
80111
```sh
81112
python3 smartlab_demo.py
82-
-tv ./stream_1_top.mp4
83-
-fv ./stream_1_high.mp4
113+
-tv stream_1_top.mp4
114+
-sv stream_1_left.mp4
84115
-m_ta "./intel/smartlab-object-detection-0001/FP32/smartlab-object-detection-0001.xml"
85116
-m_tm "./intel/smartlab-object-detection-0002/FP32/smartlab-object-detection-0002.xml"
86-
-m_fa "./intel/smartlab-object-detection-0003/FP32/smartlab-object-detection-0003.xml"
87-
-m_fm "./intel/smartlab-object-detection-0004/FP32/smartlab-object-detection-0004.xml"
88-
-m_en "./public/i3d-rgb-tf/FP32/i3d-rgb-tf.xml"
89-
-m_de "./intel/smartlab-sequence-modelling-0001/FP32/smartlab-sequence-modelling-0001.xml"
117+
-m_sa "./intel/smartlab-object-detection-0003/FP32/smartlab-object-detection-0003.xml"
118+
-m_sm "./intel/smartlab-object-detection-0004/FP32/smartlab-object-detection-0004.xml"
119+
--mode mstcn
120+
-m_en "./intel/sequence_modelling/FP32/smartlab-sequence-modelling-0001.xml"
121+
-m_de "./intel/sequence_modelling/FP32/smartlab-sequence-modelling-0002.xml"
90122
```
91123

92124
## Demo Output
93125

94-
The application uses OpenCV to display the real-time object detection, action recognition results and evaluation results.
126+
The application uses OpenCV to display the online results.
95127

96128
## See Also
97129

98130
* [Open Model Zoo Demos](../../README.md)
99-
* [Model Optimizer](https://docs.openvino.ai/latest/openvino_docs_MO_DG_Deep_Learning_Model_Optimizer_DevGuide.html)
100131
* [Model Downloader](../../../tools/model_tools/README.md)

0 commit comments

Comments
 (0)