Skip to content

Commit d48c403

Browse files
committed
fixed bugs in iewrap.py. change inputs/outputs to dictionary
1 parent 54945cc commit d48c403

File tree

5 files changed

+18
-10
lines changed

5 files changed

+18
-10
lines changed

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ list = getInputs()
106106
- None
107107
- *Output*
108108
- List of input blobs of the loaded model.
109-
- The list format is: `[ {'name':blobName, 'data':blobData, 'shape':blobShape, 'type':blobType('imgae' or others)}, ... ]`.
109+
- The list format is: `{ blobName : { 'data':blobData, 'shape':blobShape, 'type':blobType }, ... }`.
110+
- `blobType` is a string. The value can be `image`, or others. If the type is `image`, the `blobData` will go through image preprocess before inferencing.
110111

111112
~~~python
112113
list = getOutputs()
@@ -118,7 +119,7 @@ list = getOutputs()
118119
- None
119120
- *Output*
120121
- List of output blobs of the loaded model.
121-
- The list format is: `[ {'name':blobName, 'shape':blobShape}, ... ]`.
122+
- The list format is: `{ blobName : { 'shape':blobShape }, ... }`.
122123

123124
~~~python
124125
1. outBlob = blockInfer(ocvImg) # for single input model
@@ -132,14 +133,14 @@ list = getOutputs()
132133
- You can obtain the input list with `getInputs()` and stuff your input data to infer to `data` element in the dictionary in the list.
133134
- The dictionary has `type` attribute. If you set `image` to the type, the data stored in `data` is considered as an OpenCV image data and go through image preprocessing before inferencing (resize and transform), otherwise the data in the `data` will be just passed to the Inference Engine without any preprocessing.
134135
- You must use this style of API when your model has multiple inputs.
135-
- e.g. `[{'name': 'data', 'data': 0, 'shape': [1, 3, 224, 224], 'type': 'image'}]`
136+
- e.g. `{ 'data' : { 'data': 0, 'shape': [1, 3, 224, 224], 'type': 'image'} }`
136137
- *Return*
137138
- `outBlob`: Output result of the inferencing
138139
- Single output model: `outBlob` contains the data of the output blob.
139140
- Multiple output model: `outBlob` contains a dictionary which contains the outputs of the model.
140141
- Key: The name of an output blob
141142
- Value: The contents of an output blob
142-
- e.g. `[{'name': 'prob', 'shape': [1, 1000]}]`
143+
- e.g. `{ 'prob' : { 'shape': [1, 1000] } }`
143144

144145
~~~python
145146
1. infID = asyncInfer(ocvimg) # for single input model
@@ -153,7 +154,7 @@ list = getOutputs()
153154
- You can obtain the input list with `getInputs()` and stuff your input data to infer to `data` element in the dictionary in the list.
154155
- The dictionary has `type` attribute. If you set `image` to the type, the data stored in `data` is considered as an OpenCV image data and go through image preprocessing before inferencing (resize and transform), otherwise the data in the `data` will be just passed to the Inference Engine without any preprocessing.
155156
- You must use this style of API when your model has multiple inputs.
156-
- e.g. `[{'name': 'data', 'data': 0, 'shape': [1, 3, 224, 224], 'type': 'image'}]`
157+
- e.g. `{ 'data' : { 'data': 0, 'shape': [1, 3, 224, 224], 'type': 'image'} }`
157158
- *Return*
158159
- `infID`: ID number of the requested inferencing task
159160

@@ -169,7 +170,7 @@ setCallback(callback)
169170
- Multiple output model: `outBlob` contains a dictionary which contains the outputs of the model.
170171
- Key: The name of an output blob
171172
- Value: The contents of an output blob
172-
- e.g. `[{'name': 'prob', 'shape': [1, 1000]}]`
173+
- e.g. `{ 'prob' : { 'shape': [1, 1000] } }`
173174
- *Return*
174175
- None
175176

iewrap.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,11 @@ def callback(self, status, data):
5151
outputs = req.outputs
5252
if self.callbackFunc!=None:
5353
if(len(outputs)==1):
54-
self.callbackFunc(id, outputs[self.outputs[0]['name']]) # if the model has only 1 output, return the blob contents in an array
54+
firstBlobName = next(iter(self.outputs))
55+
self.callbackFunc(id, outputs[firstBlobName]) # if the model has only 1 output, return the blob contents in an array
5556
else:
56-
self.callbackFunc(id, outputs) # if the model has multiple outputs, return the result in dictionary
57-
# e.g. ( {'prob': array[], 'data': array[]})
57+
self.callbackFunc(id, outputs) # if the model has multiple outputs, return the result in dictionary
58+
# e.g. ( {'prob': array[], 'data': array[]})
5859

5960
def imagePreprocess(self, img, shape):
6061
img = cv2.resize(img, (shape[3], shape[2]))

iewrap_gaze_estimation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
ie_faceLM = iewrap.ieWrapper('./intel/facial-landmarks-35-adas-0002/FP16/facial-landmarks-35-adas-0002.xml', 'CPU')
1515
ie_gaze = iewrap.ieWrapper('./intel/gaze-estimation-adas-0002/FP16/gaze-estimation-adas-0002.xml', 'CPU')
1616

17-
print('hit ESC to exit.')
17+
print('Please connect a USB web cam. Hit ESC to exit.')
1818
while cv2.waitKey(1) != 27: # 27 == ESC
1919
ret,img = cam.read()
2020
img = cv2.flip(img, 1) # flip image

prep.bat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ rem Download googlenet-v1 and mobilenet-ssd models with Model Downloader and Mod
1212
python "%INTEL_OPENVINO_DIR%\deployment_tools\tools\model_downloader\downloader.py" --name googlenet-v1,mobilenet-ssd
1313
python "%INTEL_OPENVINO_DIR%\deployment_tools\tools\model_downloader\converter.py" --name googlenet-v1,mobilenet-ssd --precisions FP16
1414

15+
rem Download models for gaze estimation demo
16+
python "%INTEL_OPENVINO_DIR%\deployment_tools\tools\model_downloader\downloader.py" --name face-detection-adas-0001,head-pose-estimation-adas-0001,facial-landmarks-35-adas-0002,gaze-estimation-adas-0002
17+
1518
pip install matplotlib opencv-python numpy
1619

1720
exit /B

prep.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,7 @@ cp $INTEL_OPENVINO_DIR/deployment_tools/inference_engine/samples/python/voc_labe
1616
python3 $INTEL_OPENVINO_DIR/deployment_tools/tools/model_downloader/downloader.py --name googlenet-v1,mobilenet-ssd
1717
python3 $INTEL_OPENVINO_DIR/deployment_tools/tools/model_downloader/converter.py --name googlenet-v1,mobilenet-ssd --precisions FP16
1818

19+
# Download models for gaze estimation demo
20+
python3 $INTEL_OPENVINO_DIR/deployment_tools/tools/model_downloader/downloader.py --name face-detection-adas-0001,head-pose-estimation-adas-0001,facial-landmarks-35-adas-0002,gaze-estimation-adas-0002
21+
1922
pip3 install matplotlib opencv-python numpy

0 commit comments

Comments
 (0)