Intel® Distribution of OpenVINO™ Toolkit
Community assistance about the Intel® Distribution of OpenVINO™ toolkit, OpenCV, and all aspects of computer vision-related on Intel® platforms.

Wrong Conversion with ModelOptimizer?

Stefano_M_
Beginner
393 Views

I've trained my SSD network from scratch using caffe on Ubuntu 16.04.
Running the detection on the ipython notebook on Linux with this parameters, it detects almost correctly
    
    model_def = 'models/deploy.prototxt'
    model_weights = 'models/model.caffemodel'

    net = caffe.Net(model_def,      # defines the structure of the model
                    model_weights,  # contains the trained weights
                    caffe.TEST)     # use test mode (e.g., don't perform dropout)

    #input preprocessing: 'data' is the name of the input blob == net.inputs[0]
    transformer = caffe.io.Transformer({'data': net.blobs['data'].data.shape})
    transformer.set_transpose('data', (2, 0, 1))
    transformer.set_mean('data', np.array([104,117,123])) # mean pixel
    transformer.set_raw_scale('data', 255)  # the reference model operates on images in [0,255] range instead of [0,1]
    transformer.set_channel_swap('data', (2,1,0))  # the reference model has channels in BGR order instead of RGB"
    
Now, I've tried to convert the prototxt e the caffemodel into IR (with Model Optimizer) in order to use with OpenVino.
I used the .bin e the .xml with the example "object_detection_demo_ssd_async" the but the detection seems not working (wrong output position, objects not detected, etc)


I think that I have converted the models with Model Optimizer in the wrong way..

What are the parameters that I have to use to run ModelOptimizer given the above parameters?

0 Kudos
5 Replies
Monique_J_Intel
Employee
393 Views

Hi Stefano,

I've converted your models but before that I renamed both models to deploy2 so that i'd only have to specify the .caffemodel file using the following command:

python3 mo.py --input_model ~/Downloads/caffe\ SSD/deploy2.caffemodel 

Then I ran the object_detection_sample_ssd to verify output of model using this command:

sudo ./object_detection_sample_ssd -i ~/car_1.bmp -m /opt/intel
/computer_vision_sdk/deployment_tools/model_optimizer/deploy2.xml

What is your model optimizer command?

Kind Regards,

Monique Jones

0 Kudos
Stefano_M_
Beginner
393 Views

Hi,

my Model Optimizer command is:

"python mo_caffe.py --input_model model.caffemodel --input_proto deploy.prototxt"

I tryed also with:

"python mo_caffe.py --input_model model.caffemodel --input_proto deploy.prototxt --mean_values (104,117,123) --scale 255"

I was using the OpenVino R2.

 

0 Kudos
Monique_J_Intel
Employee
393 Views

Hi Stefano,

I'd recommend that you upgrade to R3 as that's what i've validated your model on and it seems to work.

Let me know if there are any issues after you've upgraded.

Kind Regards,

Monique Jones

0 Kudos
Stefano_M_
Beginner
393 Views

Hi Monique,

I checked again my code and I found an error, now it's working.

Thank you very much for your support

0 Kudos
Khan__Saad
Beginner
393 Views

Hi @stefano i am unable to convert the caffe model. I have tried everything you people recommended above but it shows this error:

 

Shape is not defined for output 0 of "detection_out".

My original code is as follows:

net.blobs['data'].reshape(1, 3, process_frame.shape[0], process_frame.shape[1])

transformer = caffe.io.Transformer({'data': net.blobs['data'].data.shape})
transformer.set_transpose('data', (2, 0, 1))
transformer.set_mean('data', np.array([104, 117, 123])) # mean pixel
transformer.set_raw_scale('data', 255)  # the reference model operates on images in [0,255] range instead of [0,1]
transformer.set_channel_swap('data', (2, 1, 0))  # the reference model has channels in BGR order instead of RGB
transformed_image = transformer.preprocess('data', process_frame)
net.blobs['data'].data[...] = transformed_image

 

I am attaching the model file so kindly check and let me know. Stuck for 7 hours on this problem. please help

0 Kudos
Reply