- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, i have been trying to convert my custom classification model (5 layers) to run on the openvino target. I have generated the ir file and was trying to do inference with classification sample from inference samples. I am getting the result(class id) as always 0 and the probability of 1.0 and the throughput of 540 fps for all sets of images. Whereas while i checked the model results by infering the keras model i am getting valid results. Expecting help from your side on this.
Thanks in advance.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi kalaiselvan,
Could you provide additional information about your setup?
- Which version of OpenVINO are you using?
- What command did you use with the model optimizer?
- Are you testing your model with one of our sample applications?
- Could you share your model?
Regards,
Jesus
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
the openvino version which i am using is 2019.1.144
The command i used with model optimizer is
python3 mo.py --input_model '/home/ign-blr-84/kalai/test/tyq-i/latest_model/tf_model.pb' --output_dir /home/ign-blr-84/kalai/new/FP16 --input_shape [1,50,50,1] --data_type FP16
And yes, as i have mentioned earlier, i am testing my custom classification model on the intel sample named "classification_sample"
And here is my model structure
model = Sequential()
model.add(Conv2D(16, (10, 10), input_shape=(img_width, img_height,3),padding='valid'))
model.add(BatchNormalization())
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(32, (3, 3),padding='valid'))
model.add(BatchNormalization())
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(64, (3, 3),padding='valid'))
model.add(BatchNormalization())
model.add(Activation('relu'))
model.add(Conv2D(128, (3, 3),padding='valid'))
model.add(BatchNormalization())
model.add(Activation('relu'))
model.add(Flatten())
model.add(Dense(200))
model.add(Dropout(0.5))
model.add(Activation('relu'))
model.add(Dense(100))
model.add(Dropout(0.5))
model.add(Activation('relu'))
model.add(Dense(1))
model.add(Activation('sigmoid'))
Hope to get a solution.
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi kalaiselvan,
There may be an issue when converting from Keras (.h5) to Tensorflow frozen model (.pb) or Tensorflow frozen model to IR format. Take a look at this thread, another user was having issue when saving the Keras model.
Let me know if you are able to share your model with me and I will send you a message for you to share privately.
Regards,
Jesus
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello, hope you doing good.
I still have the problem persisting, as described above
I'm running a custom 2 layer CNN classification model on images on Openvino target using ncs2. My results are always class id ="0" irrespective of all the images. The model is giving expected results in the backend(when i load the h5 file and predict), whereas it fails while i do it on inference samples called "classification sample". Hope you can help me out.
Here is the model structure
model = Sequential()
model.add(Conv2D(4, (3, 3), strides=(2, 2), input_shape=(img_width, img_width,1), padding='valid'))
model.add(BatchNormalization())
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(1, (3, 3),padding='valid'))
#model.add(BatchNormalization())
model.add(Activation('relu'))
#model.add(MaxPooling2D(pool_size=(2, 2)))
#model.add(GlobalMaxPooling2D())
model.add(Flatten()) # this converts our 3D feature maps to 1D feature vectors
#model.add(GlobalMaxPooling2D())
model.add(Dense(1))
model.add(Activation('sigmoid'))
The openvino version im using is 2019.1.144
The model optimizer command is
python3 mo.py --input_model 'weights/2layer_tyqi.pb' --output_dir /ir_files --input_shape [1,100,100,1] --data_type FP16
Here is the h5 file containing the model, and pb file and the script i used to convert from h5 to pb in the attatchment. Hope to get a quick response. Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
And adding to my above discussion, running this same model on mnist dataset with last layer modeified to 10 classes works. Any idea about that?
I suspect that binary classification needs some special configuration to be done. Is it something like that. My dataset consists of two classes and sigmoid layer at the end. Please provide your opinion on this. Any help is appreciated.
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi P, kalaiselvan,
Assuming you trained your model on images loaded with the RGB channels order, you may be missing the --reverse_input_channels flag. This is needed as the Inference Engine samples load input images in BGR channels order. Please see documentation here for more information about such flag.
The command may look something like this:
python3 mo.py --input_model 'weights/2layer_tyqi.pb' --output_dir /ir_files --input_shape [1,100,100,1] --data_type FP16 --reverse_input_channels
Please give it a try and let me know if the issue persists. Also if you can please provide input test images so we can test the classification, also let me know their corresponding classid.
Regards,
Luis

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page