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

MobileNet-SSD + NCS1 + my own datasets

Open libingyang0 opened this issue 6 years ago • 1 comments

Hello,PINTO0309! When I trained MobileNet-SSD on my own datasets(20 different classes, 400 images per class), I found the results of FP32 and FP16 be completely different(the caffe model test detection_eval is 0.91). And the same problem also happend when I trained YOLOv3 on my own datasets(follow your other github program). Are you trying to train the model with your own data? I doubted if the openvino and ncsdk can only convert the specific model perfectly. Could you give me some advices? Thank you!

libingyang0 avatar Apr 28 '19 09:04 libingyang0

I also suffer from this issue, I train on my own dataset based on https://github.com/chuanqi305/MobileNet-SSD and generate caffe model.

The output is different run with CPU and NCS2 , any suggestion?

The below codes are run on Raspberry Pi stretch with opencv '4.1.0-openvino' and NCS2:

#!/usr/bin/env python3
import json
import cv2

def decode_out(out):
    detections = []

    for data in out[0,0,:,:]:
        if float(data[2]) > 0.3:
            detections.append({
                "bbox": [float(x) for x in data[3:]],
                "score": float(data[2]),
                "class_id": int(data[1])
            })
    
    return sorted(detections,key=lambda x:x['score'], reverse=True)

image = cv2.imread("/home/pi/test.jpg")
image = cv2.resize(image, (300,300))
input_blob = cv2.dnn.blobFromImage(image, 1.0/127.5, (300,300), (127.5, 127.5, 127.5), False, False)

model = "/home/pi/no_bn.caffemodel"
prototxt = "/home/pi/no_bn.prototxt"
net = cv2.dnn.readNetFromCaffe(prototxt, model)

# wiht CPU
net.setPreferableTarget(cv2.dnn.DNN_TARGET_CPU)
net.setPreferableBackend(cv2.dnn.DNN_BACKEND_OPENCV)
net.setInput(input_blob)
out1 = net.forward()
print(json.dumps(decode_out(out1),indent=2))

# with NCS2
net.setPreferableBackend(cv2.dnn.DNN_BACKEND_INFERENCE_ENGINE)
net.setPreferableTarget(cv2.dnn.DNN_TARGET_MYRIAD)
net.setInput(input_blob)
out2 = net.forward()
print(json.dumps(decode_out(out2),indent=2))

cfdcfc avatar Jun 11 '19 07:06 cfdcfc