如何为多输入TensorFlow SavedModel转换OpenVino IR格式指定输入层名称?
When dealing with a multi-input SavedModel, the Model Optimizer (MO) can’t map input shapes to the correct layers unless you explicitly pair each shape with its corresponding input layer name—that’s exactly why you’re seeing the [ ERROR ] Please provide input layer names for input layer shapes error. Here’s how to fix this:
Step 1: Get your input layer names first
You need to know the exact names of your model’s input layers. There are two easy ways to get this info:
Option 1: Use TensorFlow code to inspect the SavedModel
Run this snippet to load the model and print input names:
import tensorflow as tf # Load the SavedModel saved_model = tf.saved_model.load("C:/path_to/model_saved") # Access the default serving signature (adjust if your model uses a different signature) infer_signature = saved_model.signatures["serving_default"] # Extract input layer names input_names = list(infer_signature.structured_input_signature[1].keys()) print("Your model's input layer names:", input_names)
Option 2: Use the saved_model_cli command line tool
Open a terminal and run:
saved_model_cli show --dir C:/path_to/model_saved --all
Look for the section labeled Inputs in the output—this will list all input layer names and their shapes.
Step 2: Update your Model Optimizer command
Once you have the input names, pair each name with its corresponding shape in the --input parameter. You can do this in two formats:
Format 1: Single --input parameter with comma-separated name-shape pairs
Suppose your input names are input_1 and input_2 (replace with your actual names). Your command becomes:
python mo_tf.py --saved_model_dir C:/path_to/model_saved --input "input_1[1,128,128,3],input_2[1,1,1,64]"
Format 2: Separate --input parameters for each input layer
You can also specify each input individually for clarity:
python mo_tf.py --saved_model_dir C:/path_to/model_saved --input input_1[1,128,128,3] --input input_2[1,1,1,64]
Quick Note
If your SavedModel uses a non-default signature definition (not serving_default), add the --signature_def_name flag to your command to specify it, e.g., --signature_def_name my_custom_signature.
内容的提问来源于stack exchange,提问作者YScharf

