Forums - MobileNetSSD on SNPE v1.33

6 posts / 0 new
Last post
MobileNetSSD on SNPE v1.33
zainmsud
Join Date: 5 Dec 19
Posts: 1
Posted: Mon, 2019-12-16 14:07

Hi,

Trying to run the MobilenetSSD models for inference. I was able to successfully convert the caffe mobilenetSSD model to DLC.
But when I use "spne-net-run", it outputs an empty detection_out.raw file. 

Model Conversion:

snpe-caffe-to-dlc --input_network caffe/deploy.prototxt -b caffe/model.caffemodel -o dlc/model.dlc
libdc1394 error: Failed to initialize libdc1394
2019-12-16 22:03:13,549 - 169 - INFO - INFO_DLC_SAVE_LOCATION: Saving model at dlc/model.dlc
/root/snpe/lib/python/snpe/converters/common/converter_ir/ir_to_dlc.py:323: RuntimeWarning: info_code=1000; message=Layer is not supported. Layer detection_out of type SsdDetectionOutput not supported by GPU runtime; component=Model Validation; line_no=345; thread_id=140634264520512
  node.op.confidence_threshold
2019-12-16 22:03:14,862 - 169 - INFO - INFO_CONVERSION_SUCCESS: Conversion completed successfully

Inference:

snpe-net-run --container dlc/model.dlc --input_list data/cropped/raw_list.txt --runtime_order cpu_float32 --enable_cpu_fallback
-------------------------------------------------------------------------------
Model String: N/A
SNPE v1.33.1.608
-------------------------------------------------------------------------------
Processing DNN input(s):
/root/snpe/models/mobilenet_ssd/data/cropped/img1.raw
Processing DNN input(s):
/root/snpe/models/mobilenet_ssd/data/cropped/img2.raw
When I check the output/Result_0/detection_out.raw  it is empty

Any idea what I might be doing wrong?
  • Up0
  • Down0
dangvhb
Join Date: 19 Dec 19
Posts: 1
Posted: Thu, 2019-12-19 23:31

Hi zainmsud, 

I had been converted the SSD model to DLC successfully in the link below

https://github.com/zeusees/Mobilenet-SSD-License-Plate-Detection

snpe-caffe-to-dlc --input_network mssd512_voc.prototxt --caffe_bin mssd512_voc.prototxt --output_path dlc/mssd512.dlc
2019-12-20 14:26:35,431 - 169 - INFO - INFO_DLC_SAVE_LOCATION: Saving model at dlc/mssd512.dlc
/home/dangvhb/AIQualcomm/snpe-1.33.1.608/lib/python/snpe/converters/common/converter_ir/ir_to_dlc.py:323: RuntimeWarning: info_code=1000; message=Layer is not supported. Layer detection_out of type SsdDetectionOutput not supported by GPU runtime; component=Model Validation; line_no=345; thread_id=139768128546560
  node.op.confidence_threshold
2019-12-20 14:26:35,479 - 169 - INFO - INFO_CONVERSION_SUCCESS: Conversion completed successfully
 
And run the snpe-sample
 
$SNPE_ROOT/examples/NativeCpp/SampleCode/obj/local/x86_64-linux-clang/snpe-sample -b ITENSOR -d /home/dangvhb/AIQualcomm/Mobilenet-SSD-License-Plate-Detection/dlc/mssd512.dlc -i target_raw_list.txt -o output
Batch size for the container is 1
Processing DNN Input: cropped/chairs.raw
Processing DNN Input: cropped/plastic_cup.raw
Processing DNN Input: cropped/4.raw
Processing DNN Input: cropped/3.raw
Processing DNN Input: cropped/5.raw
Processing DNN Input: cropped/2.raw
Processing DNN Input: cropped/notice_sign.raw
Processing DNN Input: cropped/trash_bin.raw
 
But  I can't find how to show the result.
Anyone help me please?
 
Thanks
dangvhb

 

  • Up0
  • Down0
piyalgeorge
Join Date: 29 Apr 20
Posts: 5
Posted: Thu, 2020-05-07 01:37

Hi dangvhb,

Did you get the output for this? Is it possible to show the mobilnet-ssd's Result? I too am stuck at this point. Is it possible to get bounding boxes?

 

  • Up0
  • Down0
piyalgeorge
Join Date: 29 Apr 20
Posts: 5
Posted: Thu, 2020-05-07 01:40

Hi zainmsud, 

Is it possible to get bounding boxes from Mobilenet-ssd on snpe? i got some .raw files as output. 

  • Up0
  • Down0
gesqdn-forum
Join Date: 4 Nov 18
Posts: 184
Posted: Wed, 2020-05-13 00:29

Hi piyalgeorge,

Kindly read the date from the raw file generated with the following python code and find the explanation below on how to parse the output.

$ python3.5
>>import numpy as np
>>res = np.fromfile('detection_out.raw', dtype="float32")
>>print(res)
[[0.,         6.,         0.99923944, 0.05772871 0.1193189,  0.9643268, 0.8045521 ]

Explanation:
res[0, 1] will be ID for the label, as it was trained on VOC Label 6 which belongs to the bus.
res[0, 2] represents the probability of the predicted object, it is 0.9992 here
res[0, 3:7] are the scaled X1, Y1 & X2, Y2 Values respectively.
For re-scaling it Multiply X1 & X2 with Width of image & Y1 & Y2 with the Height of the image and cast it to the Integer.
This gives the bounding box for the object predicted.

Command to convert the caffe model to dlc:
$ snpe-caffe-to-dlc --input_network MobileNetSSD_deploy.prototxt --caffe_bin MobileNetSSD_deploy.caffemodel --output_path caffe_mobilenet_ssd.dlc

  • Up0
  • Down0
gesqdn-forum
Join Date: 4 Nov 18
Posts: 184
Posted: Mon, 2020-05-18 22:07

Hi zainmsud,
Kindly download the model file from this link and use the following for converting to DLC file.
Observing the error you posted, it seems to be an issue with the image to raw conversion, find the instructions set to convert am image to raw type

$ snpe-caffe-to-dlc --input_network MobileNetSSD_deploy.prototxt --caffe_bin MobileNetSSD_deploy.caffemodel --output_path caffe_mobilenet_ssd.dlc

Image to raw conversion using python
$ python
>>  img_name = "test.jpg"
>>  img = cv2.imread(img_name, 1)
>>  img = cv2.resize(img, (X_SIZE, Y_SIZE))
>>  img = np.array(img, dtype="float32")
>>  img = np.reshape(img,(1,X_SIZE,Y_SIZE,3))
 >> ofile = (img_name.split(".")[0])+".raw"
>>  fp = open(ofile, 'wb')
>>  img.tofile(fp)

 

  • Up0
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.