savedmodel convert to tflite and merge labels.  tx to new tflite model,but resulte is error by Xcode,  use python api is correct
Hi @fndppx 

Can you please check if the preprocessing is done properly as I can see that the python api as well as model metadata normalize the values between [0,1].

Thanks. > Hi @fndppx 
> 
> Can you please check if the preprocessing is done properly as I can see that the python api as well as model metadata normalize the values between [0,1].
> 
> Thanks.

![251931780-c3618d30-3dae-4a85-a3d2-dcf0f340afe3.png](https://github.com/tensorflow/tensorflow/assets/7971897/ece83d68-6762-4ea8-b6a6-a33f0a824406)

but i use TensorFlowLiteTaskVision  this framework ，not found  model metadata normalize the values between [0,1]. only could set option 😂😂 Hi @fndppx 

The ImageClassifier API expects a TFLite model with mandatory [TFLite Model Metadata](https://www.tensorflow.org/lite/models/convert/metadata). [TensorFlow Lite Task Library](https://www.tensorflow.org/lite/inference_with_metadata/overview) can handle normalization for you if you set up NormalizationOptions in metadata.

The downloaded [tflite model](https://tfhub.dev/google/lite-model/imagenet/mobilenet_v3_large_100_224/classification/5/metadata/1) contains the metadata and a file containing all the class labels.

Can you try [this](https://www.tensorflow.org/lite/models/convert/metadata_writer_tutorial#image_classifiers) steps with 

```
_INPUT_NORM_MEAN = 0
_INPUT_NORM_STD = 255
```
Thanks.
 > Hi @fndppx
> 
> The ImageClassifier API expects a TFLite model with mandatory [TFLite Model Metadata](https://www.tensorflow.org/lite/models/convert/metadata). [TensorFlow Lite Task Library](https://www.tensorflow.org/lite/inference_with_metadata/overview) can handle normalization for you if you set up NormalizationOptions in metadata.
> 
> The downloaded [tflite model](https://tfhub.dev/google/lite-model/imagenet/mobilenet_v3_large_100_224/classification/5/metadata/1) contains the metadata and a file containing all the class labels.
> 
> Can you try [this](https://www.tensorflow.org/lite/models/convert/metadata_writer_tutorial#image_classifiers) steps with
> 
> ```
> _INPUT_NORM_MEAN = 0
> _INPUT_NORM_STD = 255
> ```
> 
> Thanks.

thank you very mach！！this way solve this issue！ Hi @fndppx 

Glad the issue is solved. Please feel free to close the issue.

Thanks. Are you satisfied with the resolution of your issue?
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=Yes&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/61219">Yes</a>
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=No&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/61219">No</a>

### Issue type

Bug

### Have you reproduced the bug with TensorFlow Nightly?

No

### Source

binary

### TensorFlow version

2.13.0

### Custom code

Yes

### OS platform and distribution

mac os 12.6

### Mobile device

ios 16.1

### Python version

3.10.0

### Bazel version

_No response_

### GCC/compiler version

_No response_

### CUDA/cuDNN version

_No response_

### GPU model and memory

_No response_

### Current behavior?

convert savedmodel to tflite in ios is error

model download  url  https://tfhub.dev/google/imagenet/mobilenet_v3_large_100_224/classification/5

convert steps

1.
<img width="996" alt="image" src="https://github.com/tensorflow/tensorflow/assets/7971897/1a8312fc-7d45-4e6e-97c2-d5ef02979082">

2.
<img width="530" alt="image" src="https://github.com/tensorflow/tensorflow/assets/7971897/5116798e-cb0d-40f5-b937-f964bb15e284">

script is use  offical
metadata_writer_for_image_classifier.py


use convert savedmodel to convert tflite （merge  labels.txt and  tflite）

python api  result  is correct
<img width="569" alt="image" src="https://github.com/tensorflow/tensorflow/assets/7971897/6b4ebb76-99a9-4d8f-8bcf-e87192bf80a8">

ios is error  （self-converted）

<img width="925" alt="image" src="https://github.com/tensorflow/tensorflow/assets/7971897/0bfe3490-c3bf-4a49-9696-1b3be7363e30">

ios is correct （download tflite is correct ）

<img width="796" alt="image" src="https://github.com/tensorflow/tensorflow/assets/7971897/c974e3d1-6582-4818-b50e-ec62548fc7e5">




### Standalone code to reproduce the issue

```shell
ios code：

<img width="1075" alt="image" src="https://github.com/tensorflow/tensorflow/assets/7971897/c3618d30-3dae-4a85-a3d2-dcf0f340afe3">


python code：


def classify_image_tflite_no_sin(model_path, predicted_image_path, labels_path):


    TF_MODEL_FILE_PATH = model_path
    interpreter = tf.lite.Interpreter(model_path=TF_MODEL_FILE_PATH)
    interpreter.allocate_tensors()
    
    # 加载标签文件
    with open(labels_path, 'r') as f:
        labels = f.read().splitlines()

    # 读取和预处理图像
    image_path = predicted_image_path
    image = Image.open(image_path).resize((224, 224))  # 调整图像大小
    image = np.array(image)  # 将图像转换为NumPy数组
    image = image / 255.0  # 归一化图像
    image = np.expand_dims(image, axis=0).astype(np.float32)  # 添加批次维度并转换为float32

    # 设置模型输入和输出张量
    input_tensor_index = interpreter.get_input_details()[0]['index']
    output_tensor_index = interpreter.get_output_details()[0]['index']

    # 设置输入张量的值
    interpreter.set_tensor(input_tensor_index, image)

    # 执行推断
    interpreter.invoke()

    # 获取输出张量的结果
    output_data = interpreter.get_tensor(output_tensor_index)
    
    score_lite = tf.nn.softmax(output_data)

    # 获取预测类别索引
    class_index = np.argmax(score_lite)
    predicted_label = labels[class_index]
    confidence = score_lite[0][class_index]

    # 输出预测结果
    print('预测类别：', predicted_label)
    print('预测准确度：', confidence)
```
```


### Relevant log output

_No response_