You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
HI, I have no clues why the NeuralNetwork node's output tensor comes with almost all zero with using openvino pretrained model ssdlite_mobilenet_v2 and my pytorch custom model. Before converting to the blob, I have ensure both can either run on onnxruntime or openvino.
Check if issue already exists
I did Google it (e.g. error xy github luxonis depthai)
I have checked troubleshooting in documentation. Unfortunately, no related topics so far...
Describe the bug dai.node.NeuralNetwork output tensor from nnData.getLayerFp16("<layer_name>") contains almost all zeros either on TensorFlow model or Pytorch ssdlite_mobilenetv2 model.
Minimal Reproducible Example
Well, I am performing the sanity check for the pretrained detection model ssdlite_mobilenet_v2 from openvino to blob with using dai.node.NeuralNetwork instead of the example from the mobilenetv2Network docs which uses dai.node.MobileNetDetectionNetwork. I referenced from the two following tutorial code examples for the test.
gen2-face-detection/main.py: since the ssdlite is structrally different from ssd and dai.node.NeuralNetwork supposes to be compatible with any openvino model. This example is showing how to decode the nnData ouput tensor. For the dai.node.MobileNetDetectionNetwork, it returns ImgDetections which contains [label, confidence, x1, y1, x2, y2] in that example. Therefore, I was thinking dai.node.NeuralNetwork is more suitable for ssdlite in this case. correct me if I'm wrong here.
To reproduce this, since both tensorflow and pytorch comes with the same output array with almost all zeros. I'm here tor provide the flow that reproduce the behaviour I have.
Firstly, I pull the pretrained model from the openvino model zoo - ssdlite_mobilenet_v2. To run the model on oak, I converted it with the following options. (from tensorflow to openvino firtst)
refer : conversion to openvino #194
To test the result, I simply modify the original tutorial code from the Video & MobilenetSSD
Testing Snippet:
fromtimeimportmonotonicfrompathlibimportPathimportargparseimportsysimportcv2importdepthaiasdaiimportnumpyasnpparser=argparse.ArgumentParser("test nn with inference on video")
parser.add_argument("blob_model", type=str, help="path to the blob model file")
parser.add_argument("video", type=str, help="path to the video file")
LABELS= [ "vehicle", "person" ]
args=vars(parser.parse_args())
defmain(args):
blob_path=f'{Path(args.get("blob_model")).resolve().absolute()}'video_source=f'{Path(args.get("video")).resolve().absolute()}'# create pipelinepipeline=dai.Pipeline()
nn=pipeline.create(dai.node.NeuralNetwork)
xinFrame=pipeline.create(dai.node.XLinkIn)
nnOut=pipeline.create(dai.node.XLinkOut)
# node propertiesxinFrame.setStreamName("inFrame")
nnOut.setStreamName("nn")
nn.setBlobPath(blob_path)
nn.setNumInferenceThreads(2)
nn.input.setBlocking(False)
# node connectionxinFrame.out.link(nn.input)
nn.out.link(nnOut.input)
withdai.Device(pipeline) asdevice :
inQ=device.getInputQueue(name="inFrame") # -> type : depthai.DataInputQueuedetQ=device.getOutputQueue(name="nn") # -> type : depthai.DataOutputQueueassertdevice.isPipelineRunning, "pipeline not running please check the pipeline instantiation or node connection"frame=None#to_planar = lambda arr, shape: cv2.resize(arr, shape).transpose(2, 0, 1).flatten()cap=cv2.VideoCapture(video_source)
whilecap.isOpened():
rect, frame=cap.read()
ifnotrect : breakimg=dai.ImgFrame()
img.setData(frame)
img.setTimestamp(monotonic())
img.setWidth(300)
img.setHeight(300)
inQ.send(img)
inDet=detQ.get()
print(f'[tensorflow pretrained blob]: {inDet.getAllLayerNames()}')
# -> ['DetectionOutput']lo_detectionOutput=inDet.getLayerFp16("DetectionOutput")
ifframeisnotNone:
cv2.imshow("test", frame)
print(np.array(lo_detectionOutput).reshape((100, 7)))
ifcv2.waitKey(1) ==ord('q'): breakif__name__=='__main__':
main(args)
Expected behavior
Suppose I was getting the decoded tensor output from the nnData.getLayerFp16("DetectionOutput") following the format mentioned in the openvino's repo i.e
with np.array(lo_detectionOutput).reshape((100, 7)), the detection will be : [image_id, label, conf, x_min, y_min, x_max, y_max]
Screenshots
I think most of the error can be revolved with only terminal prompt since I still cannot get the correct expected result...
Pipeline Graph
I haven't installed this plugin and my pipeline is relatively simple. Just link the input frame node to the dai.node.NeuralNetworknode.
Attach system log
The PC I run the snippet script
{
"architecture": "64bit",
"machine": "x86_64",
"platform": "macOS-10.16-x86_64-i386-64bit",
"processor": "i386",
"python_build": "main Nov 24 2022 08:29:02",
"python_compiler": "Clang 14.0.6 ",
"python_implementation": "CPython",
"python_version": "3.9.15",
"release": "21.2.0",
"system": "Darwin",
"version": "Darwin Kernel Version 21.2.0: Sun Nov 28 20:28:54 PST 2021; root:xnu-8019.61.5~1/RELEASE_X86_64",
"win32_ver": "",
"packages": [
"certifi @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_477u68wvzm/croot/certifi_1671487773341/work/certifi",
"charset-normalizer==2.1.1",
"depthai==2.19.1.0",
"idna==3.4",
"numpy==1.24.1",
"opencv-python==4.7.0.68",
"pip==22.3.1",
"PyYAML==6.0",
"requests==2.28.1",
"setuptools==65.5.0",
"urllib3==1.26.13",
"wheel==0.37.1"
],
"usb": [
"NoLib"
],
"uname": [
"Darwin ws11.local 21.2.0 Darwin Kernel Version 21.2.0: Sun Nov 28 20:28:54 PST 2021; root:xnu-8019.61.5~1/RELEASE_X86_64 x86_64 i386"
]
}
System info gathered successfully - saved as "log_system_information.json"
Additional context
However, I compiled the models on another PC and I don' think that matters.
That's all I have...
Thank you in advance
The text was updated successfully, but these errors were encountered:
htangcreaxon
changed the title
[BUG] {dai.node.NeuralNetwork Output tensor contains almost all zeros }
[BUG] dai.node.NeuralNetwork Output tensor contains almost all zeros
Jan 12, 2023
HI, I have no clues why the NeuralNetwork node's output tensor comes with almost all zero with using openvino pretrained model ssdlite_mobilenet_v2 and my pytorch custom model. Before converting to the blob, I have ensure both can either run on
onnxruntim
e oropenvino
.Check if issue already exists
Describe the bug
dai.node.NeuralNetwork
output tensor fromnnData.getLayerFp16("<layer_name>")
contains almost all zeros either on TensorFlow model or Pytorch ssdlite_mobilenetv2 model.Minimal Reproducible Example
Well, I am performing the sanity check for the pretrained detection model ssdlite_mobilenet_v2 from openvino to blob with using
dai.node.NeuralNetwork
instead of the example from the mobilenetv2Network docs which usesdai.node.MobileNetDetectionNetwork
. I referenced from the two following tutorial code examples for the test.ssdlite
is structrally different fromssd
anddai.node.NeuralNetwork
supposes to be compatible with any openvino model. This example is showing how to decode thennData
ouput tensor. For thedai.node.MobileNetDetectionNetwork
, it returnsImgDetections
which contains[label, confidence, x1, y1, x2, y2]
in that example. Therefore, I was thinkingdai.node.NeuralNetwork
is more suitable for ssdlite in this case. correct me if I'm wrong here.To reproduce this, since both tensorflow and pytorch comes with the same output array with almost all zeros. I'm here tor provide the flow that reproduce the behaviour I have.
Firstly, I pull the pretrained model from the openvino model zoo - ssdlite_mobilenet_v2. To run the model on oak, I converted it with the following options. (from tensorflow to openvino firtst)
refer : conversion to openvino #194
After that, I converted it to blob format with the following options
python -m blobconverter \ --openvino-xml ssdlite_mobilenet_v2.xml \ --openvino-bin ssdlite_mobilenet_v2.bin \ --shaves 6 -dt FP16 -v 2022.1 Downloading /home/htang/.cache/blobconverter/ssdlite_mobilenet_v2_openvino_2022.1_6shave.blob... [==================================================] Done
To test the result, I simply modify the original tutorial code from the Video & MobilenetSSD
Testing Snippet:
Expected behavior
Suppose I was getting the decoded tensor output from the
nnData.getLayerFp16("DetectionOutput")
following the format mentioned in the openvino's repo i.ewith
np.array(lo_detectionOutput).reshape((100, 7))
, the detection will be :[image_id, label, conf, x_min, y_min, x_max, y_max]
Screenshots
I think most of the error can be revolved with only terminal prompt since I still cannot get the correct expected result...
Pipeline Graph
I haven't installed this plugin and my pipeline is relatively simple. Just link the input frame node to the
dai.node.NeuralNetwork
node.Attach system log
The PC I run the snippet script
Additional context
However, I compiled the models on another PC and I don' think that matters.
That's all I have...
Thank you in advance
The text was updated successfully, but these errors were encountered: