How to generate SSD model for object detection sample?

How to generate SSD model for object detection sample?

Hi,

inference_engine has a object_detection_sample_ssd. I tried to generate the IR representation by downloading the VOC 07+12 SSD300 model from objehttps://github.com/weiliu89/caffe/tree/ssd.

./ModelOptimizer -w $SAMPLE_DIR/models/VGGNet/VOC0712Plus/SSD_300x300/VGG_VOC0712Plus_SSD_300x300_iter_240000.caffemodel -d $SAMPLE_DIR/models/VGGNet/VOC0712Plus/SSD_300x300/deploy.prototxt -p FP32 -f 1 -b 1 --target APLK -o $SAMPLE_DIR/models/VGGNet/VOC0712Plus/SSD_300x300/generated_ir -i --network LOCALIZATION
Start working...

Framework plugin: CAFFE
Target type: APLK
Network type: LOCALIZATION
Batch size: 1
Precision: FP32
Layer fusion: false
Horizontal layer fusion: PARTIAL
Output directory: /home/ubuntu/workspace/intel_sdk_samples/models/VGGNet/VOC0712Plus/SSD_300x300/generated_ir
Custom kernels directory: 
Network input normalization: 1
[libprotobuf ERROR google/protobuf/text_format.cc:245] Error parsing text-format caffe.NetParameter: 814:14: Message type "caffe.LayerParameter" has no field named "norm_param".
F0824 16:24:37.618919 23037 upgrade_proto.cpp:88] Check failed: ReadProtoFromTextFile(param_file, param) Failed to parse NetParameter file: /home/ubuntu/workspace/intel_sdk_samples/models/VGGNet/VOC0712Plus/SSD_300x300/deploy.prototxt
*** Check failure stack trace: ***
    @     0x7fd7c9462daa  (unknown)
    @     0x7fd7c9462ce4  (unknown)
    @     0x7fd7c94626e6  (unknown)
    @     0x7fd7c9465687  (unknown)
    @     0x7fd7c9967aee  caffe::ReadNetParamsFromTextFileOrDie()
    @     0x7fd7c9920dbb  readTopology_
    @     0x7fd7cb4955f7  Model2OpenVX::CaffeNetworkDescriptor::CaffeNetworkDescriptor()
    @     0x7fd7cb490ef1  Model2OpenVX::CaffeNet::init()
    @     0x7fd7cc2847b4  Model2OpenVX::FrameworkManager::GenerateIRFile()
    @     0x556b0d4f1370  main
    @     0x7fd7cb9edf45  (unknown)
    @     0x556b0d4f3867  (unknown)
    @              (nil)  (unknown)
Aborted (core dumped)

Best regards,

Dong

7 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
Best Reply

Hi,
1) Since the SSD features layers that are not in the master Caffe (including specific variation of Normalize layer that drives the conversion tool crazy in your example), first you need to use the SSD branch:
    $ git clone https://github.com/weiliu89/caffe.git && cd ./caffe && git checkout ssd

2) Patch the code of the DetectionOutput layer. Currently, the ModelOPtimizer tool has limitation of not allowing the dynamic tensor sizing.
Specifically, add the following change to the DetectionOutputLayer<Dtype>::Reshape method:
   vector<int> top_shape2(2, 1);
   top_shape2.push_back(keep_top_k_);
   top_shape2.push_back(7);
   top[0]->Reshape(top_shape2);

3) Add the ModelOptimizer wrappers to the Caffe code, from <INSTALL_DIR>/mo/adapters folder, to the “caffe/include/caffe/” and  “caffe/src/caffe/” of your local Caffe respectively
4) Recompile the Caffe
5) Set path to the dir with resulting libCaffe.so as FRAMEWORK_HOME env, e.g.
   $export FRAMEWORK_HOME=<PATH_TO_YOUR_LOCAL_CAFFE>/build/lib

https://software.intel.com/en-us/model-optimizer-devguide-getting-starte...

Hi Maxim,

Thanks very much for the detailed instructions. It worked perfectly: ssd model IR generated and object_detection_sample_ssd worked!

Best regards,

Dong

 

Hi,

i'm trying the same as well. i've got the proper caffe for SSD from Weiliu89 git. But i'm getting different strange error.

i'm trying to get the SSD IR model generated for Inference Engine.

Try 1:

./ModelOptimizer --target APLK --fuse false -w ~/caffe_ssd/caffe/models/VGGNet/VOC0712/SSD_300x300/VGG_VOC0712_SSD_300x300_iter_120000.caffemodel -p FP32 -d ~/caffe_ssd/caffe/models/VGGNet/VOC0712/SSD_300x300/deploy.prototxt -f 1 -i -o ~/ml/model_optimizer_projects/
Start working...

Framework plugin: CAFFE
Target type: APLK
Network type: CLASSIFICATION
Batch size: 8
Precision: FP32
Layer fusion: false
Horizontal layer fusion: PARTIAL
Output directory: /home/kasi/ml/model_optimizer_projects/
Custom kernels directory:
Network input normalization: 1
dlopen failed: :/home/kasi/caffe_ssd/caffe/build/lib/libcaffe.so: cannot open shared object file: No such file or directory
Could not load librarycaffe from: :/home/kasi/caffe_ssd/caffe/build/lib

Try 2: (with Sudo)

./ModelOptimizer --target APLK --fuse false -w ~/caffe_ssd/caffe/models/VGGNet/VOC0712/SSD_300x300/VGG_VOC0712_SSD_300x300_iter_120000.caffemodel -p FP32 -d ~/caffe_ssd/caffe/models/VGGNet/VOC0712/SSD_300x300/deploy.prototxt -f 1 -i -o ~/ml/model_optimizer_projects/
./ModelOptimizer: error while loading shared libraries: libCommonInterfaces.so: cannot open shared object file: No such file or directory

Not sure how to resolve this. In try 2, i'm having the libCommonInterfaces.so in the same working directory (binary of model optimizer)

PATH and LD_LIBRARY_PATH are updated as well.

kasi@kasi:/opt/intel/computer_vision_sdk_2017.0.113/mo/bin$ echo $PATH
/home/kasi/bin:/home/kasi/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/opt/intel/computer_vision_sdk_2017.0.113/mo/bin
kasi@kasi:/opt/intel/computer_vision_sdk_2017.0.113/mo/bin$ echo $LD_LIBRARY_PATH
:/home/kasi/caffe_ssd/caffe/build/lib:/opt/intel/computer_vision_sdk_2017.0.113/mo/bin:/usr/local/bin

Kindly let me know how to solve this problem. Plz find attached log for more details.

 

Attachments: 

AttachmentSize
Downloadtext/plain log.txt7.17 KB

Hi, 

Seems like you have some missing environmental (FAMEWORK_HOME)

Please refer to this document to start working with caffe:

https://software.intel.com/en-us/model-optimizer-devguide-getting-starte...

 

Regards,

Stav

 

Hi,

i've got output from modeloptimizer and trying to run inference engine with object_detection_sample_ssd() example.

working-directory> bin\intel64\Debug\object_detection_sample_ssd.exe -i samples\object_detection_sample_ssd\siamese_cat.bmp -m samples\object_detection_sample_ssd\VGG_VOC0712_SSD_300x300_deploy\VGG_VOC0712_SSD_300x300_deploy.xml -d GPU

i get the following error.

InferenceEngine:
API version ............ 1.0
Build .................. 4463

API version ............ 0.1
Build .................. prod-01909
Description ....... clDNNPlugin
Debug Options:
Debug Layer Content: 0
Debug Layer Content Indexed: 0
Debug Layers Format: 0
Plugin Performance Prints: 0
Print Size: 3
Infer() time of one iteration: 425 ms
Scoring failed! Critical error: Output blob size is not equal network output size (7!=1400).

Not sure what was the error. i've attached my xml and bin files herewith. Also i needed to give an input image of 300x300 only as input, hence attached that image bmp file as well.

regards,
Kasi.

Attachments: 

Hi Kasi,

Did you do these steps before IR generation?

Quote:

Maxim Shevtsov (Intel) wrote:

Hi,
1) Since the SSD features layers that are not in the master Caffe (including specific variation of Normalize layer that drives the conversion tool crazy in your example), first you need to use the SSD branch:
    $ git clone https://github.com/weiliu89/caffe.git && cd ./caffe && git checkout ssd

2) Patch the code of the DetectionOutput layer. Currently, the ModelOPtimizer tool has limitation of not allowing the dynamic tensor sizing.
Specifically, add the following change to the DetectionOutputLayer<Dtype>::Reshape method:
   vector<int> top_shape2(2, 1);
   top_shape2.push_back(keep_top_k_);
   top_shape2.push_back(7);
   top[0]->Reshape(top_shape2);

3) Add the ModelOptimizer wrappers to the Caffe code, from <INSTALL_DIR>/mo/adapters folder, to the “caffe/include/caffe/” and  “caffe/src/caffe/” of your local Caffe respectively
4) Recompile the Caffe
5) Set path to the dir with resulting libCaffe.so as FRAMEWORK_HOME env, e.g.
   $export FRAMEWORK_HOME=<PATH_TO_YOUR_LOCAL_CAFFE>/build/lib

https://software.intel.com/en-us/model-optimizer-devguide-getting-starte...

 

It looks like you got incorrect dimensions for the DetectionOutput layer.

Leave a Comment

Please sign in to add a comment. Not a member? Join today