oliver9523 commited on
Commit
35fc7d7
·
verified ·
1 Parent(s): ea36e21

Upload 10 files

Browse files
deployment/Detection task/README.md ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Exportable code
2
+
3
+ Exportable code is a .zip archive that contains simple demo to get and visualize result of model inference.
4
+
5
+ ## Structure of generated zip
6
+
7
+ - `README.md`
8
+ - model
9
+ - `model.xml`
10
+ - `model.bin`
11
+ - `config.json`
12
+ - python
13
+ - model_wrappers (Optional)
14
+ - `__init__.py`
15
+ - model_wrappers required to run demo
16
+ - `LICENSE`
17
+ - `demo.py`
18
+ - `requirements.txt`
19
+
20
+ > **NOTE**: Zip archive contains model_wrappers when [ModelAPI](https://github.com/openvinotoolkit/model_api) has no appropriate standard model wrapper for the model.
21
+
22
+ ## Prerequisites
23
+
24
+ - [Python 3.8](https://www.python.org/downloads/)
25
+ - [Git](https://git-scm.com/)
26
+
27
+ ## Install requirements to run demo
28
+
29
+ 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 get pip installed:
30
+
31
+ ```bash
32
+ sudo apt install python3-pip
33
+ ```
34
+
35
+ 1. Create clean virtual environment:
36
+
37
+ One of the possible ways for creating a virtual environment is to use `virtualenv`:
38
+
39
+ ```bash
40
+ python -m pip install virtualenv
41
+ python -m virtualenv <directory_for_environment>
42
+ ```
43
+
44
+ Before starting to work inside virtual environment, it should be activated:
45
+
46
+ On Linux and macOS:
47
+
48
+ ```bash
49
+ source <directory_for_environment>/bin/activate
50
+ ```
51
+
52
+ On Windows:
53
+
54
+ ```bash
55
+ .\<directory_for_environment>\Scripts\activate
56
+ ```
57
+
58
+ Please make sure that the environment contains [wheel](https://pypi.org/project/wheel/) by calling the following command:
59
+
60
+ ```bash
61
+ python -m pip install wheel
62
+ ```
63
+
64
+ > **NOTE**: On Linux and macOS, you may need to type `python3` instead of `python`.
65
+
66
+ 1. Install requirements in the environment:
67
+
68
+ ```bash
69
+ python -m pip install -r requirements.txt
70
+ ```
71
+
72
+ ## Usecase
73
+
74
+ 1. Running the `demo.py` application with the `-h` option yields the following usage message:
75
+
76
+ ```bash
77
+ usage: demo.py [-h] -i INPUT -m MODELS [MODELS ...] [-it {sync,async}] [-l] [--no_show] [-d {CPU,GPU}] [--output OUTPUT]
78
+
79
+ Options:
80
+ -h, --help Show this help message and exit.
81
+ -i INPUT, --input INPUT
82
+ Required. An input to process. The input must be a single image, a folder of images, video file or camera id.
83
+ -m MODELS [MODELS ...], --models MODELS [MODELS ...]
84
+ Optional. Path to directory with trained model and configuration file. If you provide several models you will start the task chain pipeline with the provided models in the order in which they were specified. Default value points to deployed model folder '../model'.
85
+ -it {sync,async}, --inference_type {sync,async}
86
+ Optional. Type of inference for single model.
87
+ -l, --loop Optional. Enable reading the input in a loop.
88
+ --no_show Optional. Disables showing inference results on UI.
89
+ -d {CPU,GPU}, --device {CPU,GPU}
90
+ Optional. Device to infer the model.
91
+ --output OUTPUT Optional. Output path to save input data with predictions.
92
+ ```
93
+
94
+ 2. As a `model` parameter the default value `../model` will be used. Or you can specify the other path to the model directory from generated zip. You can pass as `input` a single image, a folder of images, a video file, or a web camera id. So you can use the following command to do inference with a pre-trained model:
95
+
96
+ ```bash
97
+ python3 demo.py -i <path_to_video>/inputVideo.mp4
98
+ ```
99
+
100
+ You can press `Q` to stop inference during demo running.
101
+
102
+ > **NOTE**: If you provide a single image as input, the demo processes and renders it quickly, then exits. To continuously
103
+ > visualize inference results on the screen, apply the `--loop` option, which enforces processing a single image in a loop.
104
+ > In this case, you can stop the demo by pressing `Q` button or killing the process in the terminal (`Ctrl+C` for Linux).
105
+ >
106
+ > **NOTE**: Default configuration contains info about pre- and post processing for inference and is guaranteed to be correct.
107
+ > Also you can change `config.json` that specifies the confidence threshold and color for each class visualization, but any
108
+ > changes should be made with caution.
109
+
110
+ 3. To save inferenced results with predictions on it, you can specify the folder path, using `--output`.
111
+ It works for images, videos, image folders and web cameras. To prevent issues, do not specify it together with a `--loop` parameter.
112
+
113
+ ```bash
114
+ python3 demo.py \
115
+ --input <path_to_image>/inputImage.jpg \
116
+ --models ../model \
117
+ --output resulted_images
118
+ ```
119
+
120
+ 4. To run a demo on a web camera, you need to know its ID.
121
+ You can check a list of camera devices by running this command line on Linux system:
122
+
123
+ ```bash
124
+ sudo apt-get install v4l-utils
125
+ v4l2-ctl --list-devices
126
+ ```
127
+
128
+ The output will look like this:
129
+
130
+ ```bash
131
+ Integrated Camera (usb-0000:00:1a.0-1.6):
132
+ /dev/video0
133
+ ```
134
+
135
+ After that, you can use this `/dev/video0` as a camera ID for `--input`.
136
+
137
+ ## Troubleshooting
138
+
139
+ 1. If you have access to the Internet through the proxy server only, please use pip with proxy call as demonstrated by command below:
140
+
141
+ ```bash
142
+ python -m pip install --proxy http://<usr_name>:<password>@<proxyserver_name>:<port#> <pkg_name>
143
+ ```
144
+
145
+ 1. If you use Anaconda environment, you should consider that OpenVINO has limited [Conda support](https://docs.openvino.ai/2021.4/openvino_docs_install_guides_installing_openvino_conda.html) for Python 3.6 and 3.7 versions only. But the demo package requires python 3.8. So please use other tools to create the environment (like `venv` or `virtualenv`) and use `pip` as a package manager.
146
+
147
+ 1. If you have problems when you try to use `pip install` command, please update pip version by following command:
148
+
149
+ ```bash
150
+ python -m pip install --upgrade pip
151
+ ```
deployment/Detection task/model.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": "671f86a824640b8373989a71",
3
+ "name": "YOLOX-TINY OpenVINO FP16",
4
+ "version": 5,
5
+ "creation_date": "2024-10-28T12:42:16.659000+00:00",
6
+ "model_format": "OpenVINO",
7
+ "precision": [
8
+ "FP16"
9
+ ],
10
+ "has_xai_head": false,
11
+ "target_device": "CPU",
12
+ "target_device_type": null,
13
+ "performance": {
14
+ "score": 0.9401041666666665
15
+ },
16
+ "size": 10679671,
17
+ "latency": 0,
18
+ "fps_throughput": 0,
19
+ "optimization_type": "MO",
20
+ "optimization_objectives": {},
21
+ "model_status": "SUCCESS",
22
+ "configurations": [],
23
+ "previous_revision_id": "671f86a824640b8373989a6e",
24
+ "previous_trained_revision_id": "671f86a824640b8373989a6e",
25
+ "optimization_methods": []
26
+ }
deployment/Detection task/model/config.json ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "type_of_model": "SSD",
3
+ "converter_type": "DETECTION",
4
+ "model_parameters": {
5
+ "result_based_confidence_threshold": true,
6
+ "confidence_threshold": 0.699999988079071,
7
+ "nms_iou_threshold": 0.5,
8
+ "max_num_detections": 0,
9
+ "use_ellipse_shapes": false,
10
+ "resize_type": "fit_to_window_letterbox",
11
+ "pad_value": 114,
12
+ "labels": {
13
+ "label_tree": {
14
+ "type": "tree",
15
+ "directed": true,
16
+ "nodes": [
17
+ "6483613d18fb8c1c529cb061",
18
+ "6483613d18fb8c1c529cb065"
19
+ ],
20
+ "edges": []
21
+ },
22
+ "label_groups": [
23
+ {
24
+ "_id": "671f86cb2da8d99626c678a1",
25
+ "name": "Default group",
26
+ "label_ids": [
27
+ "6483613d18fb8c1c529cb061"
28
+ ],
29
+ "relation_type": "EXCLUSIVE"
30
+ },
31
+ {
32
+ "_id": "671f86cb2da8d99626c678a2",
33
+ "name": "No Object",
34
+ "label_ids": [
35
+ "6483613d18fb8c1c529cb065"
36
+ ],
37
+ "relation_type": "EMPTY_LABEL"
38
+ }
39
+ ],
40
+ "all_labels": {
41
+ "6483613d18fb8c1c529cb061": {
42
+ "_id": "6483613d18fb8c1c529cb061",
43
+ "name": "bird",
44
+ "color": {
45
+ "red": 255,
46
+ "green": 0,
47
+ "blue": 0,
48
+ "alpha": 255
49
+ },
50
+ "hotkey": "",
51
+ "domain": "DETECTION",
52
+ "creation_date": "2024-10-28T12:42:51.839000",
53
+ "is_empty": false,
54
+ "is_anomalous": false
55
+ },
56
+ "6483613d18fb8c1c529cb065": {
57
+ "_id": "6483613d18fb8c1c529cb065",
58
+ "name": "No Object",
59
+ "color": {
60
+ "red": 0,
61
+ "green": 0,
62
+ "blue": 0,
63
+ "alpha": 255
64
+ },
65
+ "hotkey": "",
66
+ "domain": "DETECTION",
67
+ "creation_date": "2024-10-28T12:42:51.839000",
68
+ "is_empty": true,
69
+ "is_anomalous": false
70
+ }
71
+ }
72
+ }
73
+ },
74
+ "tiling_parameters": {
75
+ "visible_in_ui": true,
76
+ "type": "PARAMETER_GROUP",
77
+ "enable_tiling": false,
78
+ "enable_tile_classifier": false,
79
+ "enable_adaptive_params": true,
80
+ "tile_size": 400,
81
+ "tile_overlap": 0.2,
82
+ "tile_max_number": 1500,
83
+ "tile_ir_scale_factor": 1.0,
84
+ "tile_sampling_ratio": 1.0,
85
+ "object_tile_ratio": 0.03,
86
+ "header": "Tiling Parameters",
87
+ "description": "Tiling Parameters",
88
+ "_ParameterGroup__metadata_overrides": {},
89
+ "groups": [],
90
+ "parameters": [
91
+ "enable_adaptive_params",
92
+ "enable_tile_classifier",
93
+ "enable_tiling",
94
+ "object_tile_ratio",
95
+ "tile_ir_scale_factor",
96
+ "tile_max_number",
97
+ "tile_overlap",
98
+ "tile_sampling_ratio",
99
+ "tile_size"
100
+ ]
101
+ }
102
+ }
deployment/Detection task/model/model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1d1c5c9882eeeb92b1a50bb3f33a2105a2ced1ca3c0fc5ee20b3223b72b0fd5d
3
+ size 10048860
deployment/Detection task/model/model.xml ADDED
The diff for this file is too large to render. See raw diff
 
deployment/Detection task/python/LICENSE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright (C) 2018-2021 Intel Corporation
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
deployment/Detection task/python/demo.py ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Demo based on ModelAPI."""
2
+ # Copyright (C) 2021-2022 Intel Corporation
3
+ # SPDX-License-Identifier: Apache-2.0
4
+ #
5
+
6
+ import os
7
+ import sys
8
+ from argparse import SUPPRESS, ArgumentParser
9
+ from pathlib import Path
10
+
11
+ os.environ["FEATURE_FLAGS_OTX_ACTION_TASKS"] = "1"
12
+
13
+ # pylint: disable=no-name-in-module, import-error
14
+ from otx.api.usecases.exportable_code.demo.demo_package import (
15
+ AsyncExecutor,
16
+ ChainExecutor,
17
+ ModelContainer,
18
+ SyncExecutor,
19
+ create_visualizer,
20
+ )
21
+
22
+
23
+ def build_argparser():
24
+ """Parses command line arguments."""
25
+ parser = ArgumentParser(add_help=False)
26
+ args = parser.add_argument_group("Options")
27
+ args.add_argument(
28
+ "-h",
29
+ "--help",
30
+ action="help",
31
+ default=SUPPRESS,
32
+ help="Show this help message and exit.",
33
+ )
34
+ args.add_argument(
35
+ "-i",
36
+ "--input",
37
+ required=True,
38
+ help="Required. An input to process. The input must be a single image, "
39
+ "a folder of images, video file or camera id.",
40
+ )
41
+ args.add_argument(
42
+ "-m",
43
+ "--models",
44
+ help="Optional. Path to directory with trained model and configuration file. "
45
+ "If you provide several models you will start the task chain pipeline with "
46
+ "the provided models in the order in which they were specified. Default value "
47
+ "points to deployed model folder '../model'.",
48
+ nargs="+",
49
+ default=[Path("../model")],
50
+ type=Path,
51
+ )
52
+ args.add_argument(
53
+ "-it",
54
+ "--inference_type",
55
+ help="Optional. Type of inference for single model.",
56
+ choices=["sync", "async"],
57
+ default="sync",
58
+ type=str,
59
+ )
60
+ args.add_argument(
61
+ "-l",
62
+ "--loop",
63
+ help="Optional. Enable reading the input in a loop.",
64
+ default=False,
65
+ action="store_true",
66
+ )
67
+ args.add_argument(
68
+ "--no_show",
69
+ help="Optional. Disables showing inference results on UI.",
70
+ default=False,
71
+ action="store_true",
72
+ )
73
+ args.add_argument(
74
+ "-d",
75
+ "--device",
76
+ help="Optional. Device to infer the model.",
77
+ choices=["CPU", "GPU"],
78
+ default="CPU",
79
+ type=str,
80
+ )
81
+ args.add_argument(
82
+ "--output",
83
+ default=None,
84
+ type=str,
85
+ help="Optional. Output path to save input data with predictions.",
86
+ )
87
+
88
+ return parser
89
+
90
+
91
+ EXECUTORS = {
92
+ "sync": SyncExecutor,
93
+ "async": AsyncExecutor,
94
+ "chain": ChainExecutor,
95
+ }
96
+
97
+
98
+ def get_inferencer_class(type_inference, models):
99
+ """Return class for inference of models."""
100
+ if len(models) > 1:
101
+ type_inference = "chain"
102
+ print("You started the task chain pipeline with the provided models in the order in which they were specified")
103
+ return EXECUTORS[type_inference]
104
+
105
+
106
+ def main():
107
+ """Main function that is used to run demo."""
108
+ args = build_argparser().parse_args()
109
+
110
+ if args.loop and args.output:
111
+ raise ValueError("--loop and --output cannot be both specified")
112
+
113
+ # create models
114
+ models = []
115
+ for model_dir in args.models:
116
+ model = ModelContainer(model_dir, device=args.device)
117
+ models.append(model)
118
+
119
+ inferencer = get_inferencer_class(args.inference_type, models)
120
+
121
+ # create visualizer
122
+ visualizer = create_visualizer(models[-1].task_type, no_show=args.no_show, output=args.output)
123
+
124
+ if len(models) == 1:
125
+ models = models[0]
126
+
127
+ # create inferencer and run
128
+ demo = inferencer(models, visualizer)
129
+ demo.run(args.input, args.loop and not args.no_show)
130
+
131
+
132
+ if __name__ == "__main__":
133
+ sys.exit(main() or 0)
deployment/Detection task/python/model_wrappers/__init__.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Model Wrapper Initialization of OTX Detection."""
2
+
3
+ # Copyright (C) 2021 Intel Corporation
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions
15
+ # and limitations under the License.
deployment/Detection task/python/requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ openvino==2023.3.0
2
+ openvino-model-api==0.1.9.1
3
+ otx==1.6.5
4
+ numpy>=1.21.0,<=1.23.5 # np.bool was removed in 1.24.0 which was used in openvino runtime
deployment/project.json ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": "6483613d18fb8c1c529cb05a",
3
+ "name": "birds",
4
+ "creation_time": "2023-06-09T17:28:29.944000+00:00",
5
+ "creator_id": "dd725a2c-b183-4616-bcf3-0894843fb6a5",
6
+ "pipeline": {
7
+ "tasks": [
8
+ {
9
+ "id": "6483613d18fb8c1c529cb05b",
10
+ "title": "Dataset",
11
+ "task_type": "dataset"
12
+ },
13
+ {
14
+ "id": "6483613d18fb8c1c529cb05e",
15
+ "title": "Detection task",
16
+ "task_type": "detection",
17
+ "labels": [
18
+ {
19
+ "id": "6483613d18fb8c1c529cb061",
20
+ "name": "bird",
21
+ "is_anomalous": false,
22
+ "color": "#ff0000ff",
23
+ "hotkey": "",
24
+ "is_empty": false,
25
+ "group": "Default group",
26
+ "parent_id": null
27
+ },
28
+ {
29
+ "id": "6483613d18fb8c1c529cb065",
30
+ "name": "No Object",
31
+ "is_anomalous": false,
32
+ "color": "#000000ff",
33
+ "hotkey": "",
34
+ "is_empty": true,
35
+ "group": "No Object",
36
+ "parent_id": null
37
+ }
38
+ ],
39
+ "label_schema_id": "6483613d18fb8c1c529cb067"
40
+ }
41
+ ],
42
+ "connections": [
43
+ {
44
+ "from": "6483613d18fb8c1c529cb05b",
45
+ "to": "6483613d18fb8c1c529cb05e"
46
+ }
47
+ ]
48
+ },
49
+ "thumbnail": "/api/v1/organizations/0ec46502-f590-4358-afff-a6beb25fe89f/workspaces/97ecb1e9-4367-4bc6-b335-1c6e7aedbf77/projects/6483613d18fb8c1c529cb05a/thumbnail",
50
+ "performance": {
51
+ "score": 0.9401041666666665,
52
+ "task_performances": [
53
+ {
54
+ "task_id": "6483613d18fb8c1c529cb05e",
55
+ "score": {
56
+ "value": 0.9401041666666665,
57
+ "metric_type": "f-measure"
58
+ }
59
+ }
60
+ ]
61
+ },
62
+ "storage_info": {},
63
+ "datasets": [
64
+ {
65
+ "id": "6483613d18fb8c1c529cb062",
66
+ "name": "Dataset",
67
+ "use_for_training": true,
68
+ "creation_time": "2023-06-09T17:28:29.944000+00:00"
69
+ }
70
+ ]
71
+ }