Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

MultiStickWithPiCamera example using custom mobile net ssd model results error #28

Open
DogukanAltay opened this issue Jun 12, 2019 · 1 comment

Comments

@DogukanAltay
Copy link

DogukanAltay commented Jun 12, 2019

Device: Raspberry Pi 3 B+

CPU Arch.: armv7l

OS: Raspbian

I have trained a custom 1 class mobile net ssd v2 network using Tensorflow Object Detection API and successfully converted to to IR model using OpenVino 2019 R1.1. Then I substituted the model files in the MultiStickWithPiCamera.py example with my custom model. The predict_async thread raises an error.

Error message:

line 174, in predict_async
cnt, dev = heapq.heappop(self.heap_request)
IndexError: index out of range

@DogukanAltay
Copy link
Author

Update:
I have resolved the problem. The reason is that, I am using a tensorflow implementation of Mobilenet SSDv2. Therefore after the conversion with the openvino model optimizer, the input layers and output layers are actually different from the model here.

In my case, I have changed the lines above in the MultiStickSSDwithUSBCamera_OpenVINO_NCS2.py

# Lines 147-154
def image_preprocessing(self, color_image):

    prepimg = cv2.resize(color_image, (300, 300))
    # Commented out the below lines to match the input format of my model. Edit yours accordingly.
    # prepimg = prepimg - 127.5
    # prepimg = prepimg * 0.007843
    prepimg = prepimg[np.newaxis, :, :, :]  # Batch size axis add
    prepimg = prepimg.transpose((0, 3, 1, 2))  # NHWC to NCHW
    return prepimg

and

# Line 179
# For my model, output dict returns with "DetectionOutput" key. You can find yours and replace accordingly.
out = self.exec_net.requests[dev].outputs["DetectionOutput"].flatten()

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant