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.
6404 Discussions

CNN-LSTM model performs poor in OpenVINO environment when pre-processing is applied

nat98
New Contributor I
1,097 Views

Hello,

 

I have two deep learning models, that is a CNN model and a hybrid CNN-LSTM model, both are used for image classification tasks. Note that CNN has no pre-processing required and CNN-LSTM requires pre-processing.

 

TensorFlow environment: The training performance of the CNN model is about 98% accuracy; the CNN-LSTM model is about 96% accuracy with pre-processing applied.

 

TensorFlow environment: The inference performance of the CNN model is about 100% accuracy; the CNN-LSTM model is about 75% accuracy without pre-processing, and 100% accuracy with pre-processing applied.

 

OpenVINO environment: The inference performance of the CNN model is about 100% accuracy; the CNN-LSTM model is about 75% accuracy without pre-processing, and 6% accuracy with pre-processing applied.

 

The pre-processing is a simple code as shown below:

if(np.max(image)>1):
image = image/255.0

 

Why does the CNN-LSTM model accuracy in the OpenVINO environment drops significantly once the pre-processing is applied?

 

Regards,

nat98

1 Solution
nat98
New Contributor I
1,037 Views

Hi Wan,

 

Thanks for your reply.

 

I found out that the problem is the pre-processing code:

 

if(np.max(image)>1):
image = image/255.0

 

The pre-processing code is simply to make the input images in the range of 0 to 1 instead of 0 to 255. Not sure why I can't use it.

 

The solution is to implement this pre-processing code during conversion, which uses the "Use Scales" of the Model Optimizer command. (Screenshot attached).

 

Now I'm able to get 100% accuracy in the OpenVINO environment.

 

Regards,

nat98

View solution in original post

3 Replies
Wan_Intel
Moderator
1,066 Views

Hi Nat98,

Thanks for reaching out to us.

 

Please share the following information with us for investigation purposes:

  • Steps to set up TensorFlow environment
  • Steps to set up OpenVINO environment
  • CNN and CNN-LSTM model in TensorFlow and Intermediate Representation
  • Model Optimizer command used to convert TensorFlow model into Intermediate Representation.
  • Scripts to check accuracy for both TensorFlow and Intermediate Representation model

 

 

Regards,

Wan

 

0 Kudos
nat98
New Contributor I
1,038 Views

Hi Wan,

 

Thanks for your reply.

 

I found out that the problem is the pre-processing code:

 

if(np.max(image)>1):
image = image/255.0

 

The pre-processing code is simply to make the input images in the range of 0 to 1 instead of 0 to 255. Not sure why I can't use it.

 

The solution is to implement this pre-processing code during conversion, which uses the "Use Scales" of the Model Optimizer command. (Screenshot attached).

 

Now I'm able to get 100% accuracy in the OpenVINO environment.

 

Regards,

nat98

Wan_Intel
Moderator
997 Views

Hi Nat98,

Thanks for sharing your solution in OpenVINO™ toolkit community!

 

This thread will no longer be monitored since the issue has been resolved.

If additional information is required, please submit a new question.

 

 

Regards,

Wan

 

0 Kudos
Reply