I don't get the label.txt when training the model.txt which causes me to fail to convert to tflite
@Cranky-cat,
Could you please provide the complete code and the dependencies to reproduce the issue in the effective way and helps us to debug the issue and also provide the tensorflow version you are using. Thank you! [train_mobilenet.zip](https://github.com/tensorflow/tensorflow/files/10966111/train_mobilenet.zip)
I used this py to train the model, and converting the trained H5 model file to a tflite model file caused the loss of metadata @tilakrayal [test.zip](https://github.com/tensorflow/tensorflow/files/10966144/test.zip)
This is the py of converting the file format I am using the tensorflow 2-11 version
 I convert file format without label .txt file, so my conversion will fail.
So I would like to ask how to get the label .txt file of the model. @tilakrayal I can train the model file, but I need the model file to be used on Android, so I need to convert to tflite format.
Thank you for your reply Hi @Cranky-cat 

I have observed that in https://github.com/tensorflow/tensorflow/files/10966111/train_mobilenet.zip, the model conversion into tflite is not done.

Also, please refer to the model compatability [requirements](https://www.tensorflow.org/lite/inference_with_metadata/task_library/object_detector#model_compatibility_requirements), which has example lable.txt for pretrained mobile net model. You can create a similar one for your case with class names according to your training dataset.

I have tried metadata tutorial for [object detector](https://www.tensorflow.org/lite/models/convert/metadata_writer_tutorial#object_detectors) and I was able to run without any error. Please find the gist [here](https://colab.research.google.com/gist/pjpratik/841aaa2471d1e75deafd253266c0be20/59968.ipynb). 

Thanks. This issue is stale because it has been open for 7 days with no activity. It will be closed if no further activity occurs. Thank you. This issue was closed because it has been inactive for 7 days since being marked as stale. Please reopen if you'd like to work on this further. 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/59968">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/59968">No</a>

D:\Anaconda\lib\site-packages\tensorflow_lite_support\metadata\python\metadata.py:395: UserWarning: File, 'label.txt', does not exist in the metadata. But packing it to tflite model is still allowed.
  warnings.warn(


from tflite_support.metadata_writers import object_detector
from tflite_support.metadata_writers import writer_utils

ObjectDetectorWriter = object_detector.MetadataWriter

_MODEL_PATH = "D:/android files/8_Car2022_Example_v1.1/app/src/main/assets/test2_mobilenet.tflite"
# Task Library expects label files that are in the same format as the one below.
_LABEL_FILE = "D:/android files/8_Car2022_Example_v1.1/app/src/main/assets/label.txt"
_SAVE_TO_PATH = "D:/android files/8_Car2022_Example_v1.1/app/src/main/assets/test_mobilenet_meta.tflite"
# Normalization parameters is required when reprocessing the image. It is
# optional if the image pixel values are in range of [0, 255] and the input
# tensor is quantized to uint8. See the introduction for normalization and
# quantization parameters below for more details.
# https://www.tensorflow.org/lite/models/convert/metadata#normalization_and_quantization_parameters
_INPUT_NORM_MEAN = 127.5
_INPUT_NORM_STD = 127.5

# Create the metadata writer.
writer = ObjectDetectorWriter.create_for_inference(
    writer_utils.load_file(_MODEL_PATH), [_INPUT_NORM_MEAN], [_INPUT_NORM_STD],
    [_LABEL_FILE])

# Verify the metadata generated by metadata writer.
print(writer.get_metadata_json())

# Populate the metadata into the model.
writer_utils.save_file(writer.populate(), _SAVE_TO_PATH)

