MobileNet-SSD-RealSense icon indicating copy to clipboard operation
MobileNet-SSD-RealSense copied to clipboard

MultiStickWithPiCamera example using custom mobile net ssd model results error

Open DogukanAltay opened this issue 5 years ago • 1 comments

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 avatar Jun 12 '19 10:06 DogukanAltay

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()

DogukanAltay avatar Oct 01 '19 12:10 DogukanAltay