1

I used

import tensorflow as tf
model = tf.keras.models.load_model('model.h5')
tf.saved_model.save(model,'model')

for saving my image classification model (tensorflow version on google colab = 2.9.2, intel open vino version[Development Tools] = 2021.4.2 LTS)

---------------------------------------------------------------------------------------
C:\Program Files (x86)\Intel\openvino_2021.4.752\deployment_tools\model_optimizer>python mo_tf.py --saved_model_dir C:\Users\dchoi\CNNProejct_Only_saved_English\saved_model --input_shape [1,32,320,240,3] --output_dir C:\Users\dchoi\CNNproject_only_output_English\output_model
Model Optimizer arguments:
Common parameters:
        - Path to the Input Model:      None
        - Path for generated IR:        C:\Users\dchoi\CNNproject_only_output_English\output_model
        - IR output name:       saved_model
        - Log level:    ERROR
        - Batch:        Not specified, inherited from the model
        - Input layers:         Not specified, inherited from the model
        - Output layers:        Not specified, inherited from the model
        - Input shapes:         [1,32,320,240,3]
        - Mean values:  Not specified
        - Scale values:         Not specified
        - Scale factor:         Not specified
        - Precision of IR:      FP32
        - Enable fusing:        True
        - Enable grouped convolutions fusing:   True
        - Move mean values to preprocess section:       None
        - Reverse input channels:       False
TensorFlow specific parameters:
        - Input model in text protobuf format:  False
        - Path to model dump for TensorBoard:   None
        - List of shared libraries with TensorFlow custom layers implementation:        None
        - Update the configuration file with input/output node names:   None
        - Use configuration file used to generate the model with Object Detection API:  None
        - Use the config file:  None
        - Inference Engine found in:    C:\Users\dchoi\AppData\Local\Programs\Python\Python38\lib\site-packages\openvino
Inference Engine version:       2021.4.0-3839-cd81789d294-releases/2021/4
Model Optimizer version:        2021.4.2-3974-e2a469a3450-releases/2021/4
[ WARNING ] Model Optimizer and Inference Engine versions do no match.
[ WARNING ] Consider building the Inference Engine Python API from sources or reinstall OpenVINO (TM) toolkit using "pip install openvino==2021.4"
2022-11-19 01:34:44.207311: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found
2022-11-19 01:34:44.207542: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
C:\Users\dchoi\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\autograph\impl\api.py:22: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import imp
2022-11-19 01:34:46.961002: I tensorflow/compiler/jit/xla_cpu_device.cc:41] Not creating XLA devices, tf_xla_enable_xla_devices not set
2022-11-19 01:34:46.961949: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'nvcuda.dll'; dlerror: nvcuda.dll not found
2022-11-19 01:34:46.962904: W tensorflow/stream_executor/cuda/cuda_driver.cc:326] failed call to cuInit: UNKNOWN ERROR (303)
2022-11-19 01:34:46.969471: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:169] retrieving CUDA diagnostic information for host: DESKTOP-SCBPOUA
2022-11-19 01:34:46.969727: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:176] hostname: DESKTOP-SCBPOUA
2022-11-19 01:34:46.970663: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2022-11-19 01:34:46.971135: I tensorflow/compiler/jit/xla_gpu_device.cc:99] Not creating XLA devices, tf_xla_enable_xla_devices not set
[ FRAMEWORK ERROR ]  Cannot load input model: SavedModel format load failure: NodeDef mentions attr 'validate_shape' not in Op<name=AssignVariableOp; signature=resource:resource, value:dtype -> ; attr=dtype:type; is_stateful=true>; NodeDef: {{node AssignNewValue}}. (Check whether your GraphDef-interpreting binary is up to date with your GraphDef-generating binary.).
------------------------------------------------------------------------------------------

I am getting this kind of error even after I downloaded

install_prerequirement/install_prerequisites_tf2.bat

need help

CADENTIC
  • 55
  • 1
  • 3
  • 14
newbieLife
  • 39
  • 5

1 Answers1

1

Your error seems to indicate the mismatch between the TensorFlow version used to load GraphDef file. From my replication, I am able to generate the Intermediate Representation (IR) files using TensorFlow 2.5.3 version. Here is the full Model Optimizer command used:

mo_tf.py --saved_model_dir <path_to_model\IMGC.h5_to_saved_model.pb> --input_shape [1,320,240,3] --output_dir <path_for_output_files>

enter image description here

Aznie_Intel
  • 101
  • 3
  • So, I used TensorFlow on google Colab( default version of tensorflow = 2.9.2). I tried to resave my model with tensorflow version 2.5.2 in google colab after I installed tensorflow 2.5.3 version on google colab. However, it gives me error: TypeError: __init__() got an unexpected keyword argument 'axis' after I ran these two codes beolow: model = tf.keras.models.load_model tf.saved_model.save(model, 'model_fixed') maybe because I used tf.keras.utils.image_dataset_from_directory which is not available in tensorflow 2.5.3? <-- it seems like this is not a problem after seeing ur pic – newbieLife Nov 22 '22 at 15:47
  • oh nvm, I think what u meant is tensorflow version after installing tensorflow installing prerequisites\install_prerequisites_tf2.bat (tensorflow version 2.4.4 from this file). However, how can I upgrade this to tensorflow 2.5.3 with maintaing open vino version 2021.4.2 LTS.... – newbieLife Nov 22 '22 at 16:25
  • You may install using this command: pip install tensorflow==2.5.3 or you may try with 2.4.4 first and see if that version is compatible. – Aznie_Intel Nov 24 '22 at 03:42
  • sorry for late notice, i had huge surgery so i will comeback in a week and let u know what i got – newbieLife Nov 27 '22 at 05:30
  • https://drive.google.com/drive/folders/1szrqenvavLA-wMXfTIEaUshaSODufp0b?usp=share_link I am getting this I see many W and I, but this means it worked right? also, is it okay for you to show me how to use this xml and bin with intel open model zoo? do we have to run them in open cv or with intel open vino (etc similar to the way how we used model optimizer in openvino file) – newbieLife Dec 07 '22 at 11:34
  • You may refer to the [Open Model Zoo Demos](https://github.com/openvinotoolkit/open_model_zoo/blob/master/demos/README.md) on how to use the XML and bin file. – Aznie_Intel Dec 22 '22 at 02:32