when I import yolov7.tflite into android studio,it show have to add metadata. and I use this to add metadata:
from tflite_support.metadata_writers import object_detector
from tflite_support.metadata_writers import writer_utils
ObjectDetectorWriter = object_detector.MetadataWriter
_MODEL_PATH = "D:/yolov7/Andriod_test/colab_yolov7_best_totalplates.tflite"
# Task Library expects label files that are in the same format as the one below.
_LABEL_FILE = "D:/yolov7/Andriod_test/plate_labels.txt"
_SAVE_TO_PATH = "D:/yolov7/Andriod_test/colab_yolov7_best_totalplates_fer_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.
_INPUT_NORM_MEAN = 127.5
_INPUT_NORM_STD = 127.5
# _INPUT_NORM_MEAN = 0
# _INPUT_NORM_STD = 1
# 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("************************************")
print(writer.get_metadata_json())
print("************************************")
# Populate the metadata into the model.
writer_utils.save_file(writer.populate(), _SAVE_TO_PATH)
but app can't run,and my model's output only show "location" in android studio. enter image description here
I think it must have "loaction" "category" "score" "number of detction",because tensorflow example alway have 4 outputs. enter image description here
this problem cost me much time,please help me,thanks everybody.