|
1 | 1 | ## Custom Model Loader {#ovms_docs_custom_loader}
|
2 | 2 |
|
| 3 | +### IMPORTANT: THIS FEATURE IS DEPRECATED AND WILL BE REMOVED IN THE FUTURE RELEASES |
| 4 | + |
3 | 5 | Before loading the models directly from files, some extra processing or checking may be required. Typical examples are loading encrypted files or checking for model license, and other. In such cases, this custom loader interface allows users to write their own custom model loader based on the predefined interface and load the same as a dynamic library.
|
4 | 6 |
|
5 | 7 | This document gives details on adding custom loader configuration, custom loader interface, and other details.
|
@@ -45,178 +47,6 @@ Derive the new custom loader class from base class **CustomLoaderInterface** and
|
45 | 47 | **CustomLoaderInterface* createCustomLoader**
|
46 | 48 | which allocates the new custom loader and returns a pointer to the base class.
|
47 | 49 |
|
48 |
| -An example custom loader which reads files and returns required buffers to be loaded is implemented and provided as reference in **[src/example/SampleCustomLoader](https://github.com/openvinotoolkit/model_server/blob/main/src/example/SampleCustomLoader)** |
49 |
| - |
50 |
| -This custom loader is built with the model server build and available in the docker *openvino/model_server-build:latest*. The shared library can be either copied from this docker or built using makefile. An example Makefile is provided as a reference in the directory. |
51 |
| - |
52 |
| -## Running Example Custom Loader: |
53 |
| - |
54 |
| -An example custom loader is implemented under "src/example/SampleCustomLoader". |
55 |
| - |
56 |
| -Follow the below steps to use example custom model loader: |
57 |
| - |
58 |
| -Step 1: Prepare test directory. |
59 |
| - |
60 |
| -Download the model server code & build the docker (make docker_build). |
61 |
| -Once the docker is ready, create a folder where all the artifacts can be downloaded. Make sure that the models, client components, and images are all downloaded to this folder. Additionally, create a json file required for this folder. |
62 |
| -```bash |
63 |
| -mkdir test_custom_loader |
64 |
| -``` |
65 |
| - |
66 |
| -Step 2: Prepare the example of the custom loader library |
67 |
| - |
68 |
| -```bash |
69 |
| -git clone https://github.com/openvinotoolkit/model_server.git |
70 |
| -cd model_server/src/example/SampleCustomLoader |
71 |
| -make docker_build |
72 |
| -``` |
73 |
| -It will generate the library in the `lib/libsampleloader.so` path. |
74 |
| - |
75 |
| -Copy `lib` folder to the previously created directory `test_custom_loader`. |
76 |
| -```bash |
77 |
| -cp -r lib ../../../../test_custom_loader/lib |
78 |
| -cd ../../../../test_custom_loader |
79 |
| -``` |
80 |
| - |
81 |
| -Step 3: Download a Model |
82 |
| - |
83 |
| -```bash |
84 |
| -curl --create-dirs https://storage.openvinotoolkit.org/repositories/open_model_zoo/2022.1/models_bin/2/face-detection-retail-0004/FP32/face-detection-retail-0004.xml https://storage.openvinotoolkit.org/repositories/open_model_zoo/2022.1/models_bin/2/face-detection-retail-0004/FP32/face-detection-retail-0004.bin -o model/fdsample/1/face-detection-retail-0004.xml -o model/fdsample/1/face-detection-retail-0004.bin |
85 |
| - |
86 |
| -chmod -R 755 ./model |
87 |
| -``` |
88 |
| - |
89 |
| -Step 4: Download the required Client Components |
90 |
| - |
91 |
| -```bash |
92 |
| -curl --fail https://raw.githubusercontent.com/openvinotoolkit/model_server/main/demos/common/python/client_utils.py -o client_utils.py https://raw.githubusercontent.com/openvinotoolkit/model_server/main/demos/face_detection/python/face_detection.py -o face_detection.py https://raw.githubusercontent.com/openvinotoolkit/model_server/main/demos/common/python/requirements.txt -o requirements.txt |
93 |
| - |
94 |
| -pip3 install --upgrade pip |
95 |
| -pip3 install -r requirements.txt |
96 |
| -``` |
97 |
| - |
98 |
| - |
99 |
| -Step 5: Download Data for Inference |
100 |
| - |
101 |
| -```bash |
102 |
| -curl --fail --create-dirs https://raw.githubusercontent.com/openvinotoolkit/model_server/main/demos/common/static/images/people/people1.jpeg -o images/people1.jpeg |
103 |
| -``` |
104 |
| - |
105 |
| -Step 6: Prepare the config json. |
106 |
| - |
107 |
| -Example configuration file: Create a sampleloader.json file: |
108 |
| -```bash |
109 |
| -echo ' |
110 |
| - { |
111 |
| - "custom_loader_config_list":[ |
112 |
| - { |
113 |
| - "config":{ |
114 |
| - "loader_name":"sampleloader", |
115 |
| - "library_path": "/sampleloader/lib/libsampleloader.so", |
116 |
| - "loader_config_file": "config.json" |
117 |
| - } |
118 |
| - } |
119 |
| - ], |
120 |
| - "model_config_list":[ |
121 |
| - { |
122 |
| - "config":{ |
123 |
| - "name":"sampleloader-model", |
124 |
| - "base_path":"/sampleloader/model/fdsample", |
125 |
| - "custom_loader_options": {"loader_name": "sampleloader", "model_file": "face-detection-retail-0004.xml", "bin_file": "face-detection-retail-0004.bin", "enable_file": "face-detection-retail.status"} |
126 |
| - } |
127 |
| - } |
128 |
| - ] |
129 |
| - }' >> sampleloader.json |
130 |
| -``` |
131 |
| - |
132 |
| -Step 7: Start the model server container |
133 |
| - |
134 |
| -```bash |
135 |
| -docker run -d -v ${PWD}:/sampleloader -p 9000:9000 openvino/model_server:latest --config_path /sampleloader/sampleloader.json --port 9000 --log_level DEBUG |
136 |
| -``` |
137 |
| - |
138 |
| -Step 8: Run inference & Review the results |
139 |
| - |
140 |
| -```bash |
141 |
| -python3 face_detection.py --batch_size 1 --width 300 --height 300 --input_images_dir images --output_dir results --model_name sampleloader-model --grpc_port 9000 |
142 |
| - |
143 |
| -['people1.jpeg'] |
144 |
| -Start processing 1 iterations with batch size 1 |
145 |
| - |
146 |
| -Request shape (1, 3, 300, 300) |
147 |
| -Response shape (1, 1, 200, 7) |
148 |
| -image in batch item 0 , output shape (3, 300, 300) |
149 |
| -detection 0 [[[0. 1. 0.9999999 0.22627862 0.35042182 0.27032945 |
150 |
| - 0.43312052]]] |
151 |
| -x_min 67 |
152 |
| -y_min 105 |
153 |
| -x_max 81 |
154 |
| -y_max 129 |
155 |
| -detection 1 [[[0. 1. 0.9999999 0.7980574 0.35572374 0.8422255 |
156 |
| - 0.42749226]]] |
157 |
| -x_min 239 |
158 |
| -y_min 106 |
159 |
| -x_max 252 |
160 |
| -y_max 128 |
161 |
| -detection 2 [[[0. 1. 0.9999927 0.4413453 0.29417545 0.48191014 |
162 |
| - 0.37180012]]] |
163 |
| -x_min 132 |
164 |
| -y_min 88 |
165 |
| -x_max 144 |
166 |
| -y_max 111 |
167 |
| -detection 3 [[[0. 1. 0.99964225 0.55356365 0.30400735 0.59468836 |
168 |
| - 0.38264883]]] |
169 |
| -x_min 166 |
170 |
| -y_min 91 |
171 |
| -x_max 178 |
172 |
| -y_max 114 |
173 |
| -detection 4 [[[0. 1. 0.9993523 0.32912934 0.38222942 0.36873418 |
174 |
| - 0.44978413]]] |
175 |
| -x_min 98 |
176 |
| -y_min 114 |
177 |
| -x_max 110 |
178 |
| -y_max 134 |
179 |
| -detection 5 [[[0. 1. 0.9992501 0.33522347 0.6249954 0.38323137 |
180 |
| - 0.7104612 ]]] |
181 |
| -x_min 100 |
182 |
| -y_min 187 |
183 |
| -x_max 114 |
184 |
| -y_max 213 |
185 |
| -detection 6 [[[0. 1. 0.9976745 0.6488881 0.5992611 0.6988456 0.6907843]]] |
186 |
| -x_min 194 |
187 |
| -y_min 179 |
188 |
| -x_max 209 |
189 |
| -y_max 207 |
190 |
| -detection 7 [[[0. 1. 0.9962077 0.5180316 0.5640176 0.5703776 0.6516389]]] |
191 |
| -x_min 155 |
192 |
| -y_min 169 |
193 |
| -x_max 171 |
194 |
| -y_max 195 |
195 |
| -detection 8 [[[0. 1. 0.722986 0.6746904 0.3287916 0.7198625 0.4061382]]] |
196 |
| -x_min 202 |
197 |
| -y_min 98 |
198 |
| -x_max 215 |
199 |
| -y_max 121 |
200 |
| -detection 9 [[[0. 1. 0.566281 0.13994813 0.36546633 0.18363091 |
201 |
| - 0.44829145]]] |
202 |
| -x_min 41 |
203 |
| -y_min 109 |
204 |
| -x_max 55 |
205 |
| -y_max 134 |
206 |
| -saving result to results/1_0.jpg |
207 |
| -Iteration 1; Processing time: 21.92 ms; speed 45.61 fps |
208 |
| - |
209 |
| -processing time for all iterations |
210 |
| -average time: 21.00 ms; average speed: 47.62 fps |
211 |
| -median time: 21.00 ms; median speed: 47.62 fps |
212 |
| -max time: 21.00 ms; min speed: 47.62 fps |
213 |
| -min time: 21.00 ms; max speed: 47.62 fps |
214 |
| -time percentile 90: 21.00 ms; speed percentile 90: 47.62 fps |
215 |
| -time percentile 50: 21.00 ms; speed percentile 50: 47.62 fps |
216 |
| -time standard deviation: 0.00 |
217 |
| -time variance: 0.00 |
218 |
| -``` |
219 |
| - |
220 | 50 | #### Blacklisting the model
|
221 | 51 |
|
222 | 52 | Even though a model is specified in the config file, you may need to disable the model under certain conditions, for example, expired model license.
|
|
0 commit comments