tflite-support icon indicating copy to clipboard operation
tflite-support copied to clipboard

Running ObjectDetectorWriter.create_for_inference received KeyError: 701

Open nelsontseng0704 opened this issue 3 years ago • 6 comments

Model I use: ssd_mobilenet_v2_fpnlite_320x320_coco17_tpu-8

Running

writer = ObjectDetectorWriter.create_for_inference( writer_utils.load_file(_MODEL_PATH), [127.5], [127.5], [_LABEL_FILE])writer_utils.save_file(writer.populate(), _SAVE_TO_PATH), received following error

KeyError                                  Traceback (most recent call last)
[<ipython-input-60-0a9a5c3c8853>](https://localhost:8080/#) in <module>()
      9 
     10 writer = ObjectDetectorWriter.create_for_inference(
---> 11     writer_utils.load_file(_MODEL_PATH), [127.5], [127.5], [_LABEL_FILE])
     12 writer_utils.save_file(writer.populate(), _SAVE_TO_PATH)
     13 

2 frames
[/usr/local/lib/python3.7/dist-packages/tensorflow_lite_support/metadata/python/metadata_writers/object_detector.py](https://localhost:8080/#) in <listcomp>(.0)
    210 
    211     # Output metadata according to output_tensor_indices.
--> 212     output_metadata = [indices_to_tensors[i] for i in output_tensor_indices]
    213 
    214     # Create subgraph info.

KeyError: 701

nelsontseng0704 avatar Feb 11 '22 10:02 nelsontseng0704

Does your model has the expected four tensor outputs? Do you have the error message other than the stack track log?

lu-wang-g avatar Feb 11 '22 18:02 lu-wang-g

I have the same problem with exactly the same model and error. but with key error 2235

naarkhoo avatar Aug 18 '22 20:08 naarkhoo

May you please share the model? I can help to take a look.

lu-wang-g avatar Aug 18 '22 21:08 lu-wang-g

cell 28 https://drive.google.com/file/d/1QUgvVhG9DMxo4hpIpImQNuR_nk16iGjx/view?usp=sharing and here is the folder for my fine-tuned ssd model https://drive.google.com/drive/folders/1YMH8yVRCRy3LPek4HIleYe1EqSUYmDc_?usp=sharing

naarkhoo avatar Aug 18 '22 21:08 naarkhoo

It seems that you already have the metadata successfully populated (I saw the file model_with_metadata.tflite in your drive folder). If not, please point me to the tflite model that you want to add metadata.

lu-wang-g avatar Aug 23 '22 16:08 lu-wang-g

you are right now it works - I don't know what was the solution but I appreciate your support and time looking into it.

On Tue, Aug 23, 2022 at 6:34 PM lu-wang-g @.***> wrote:

It seems that you already have the metadata successfully populated (I saw the file model_with_metadata.tflite in your drive folder). If not, please point me to the tflite model that you want to add metadata.

— Reply to this email directly, view it on GitHub https://github.com/tensorflow/tflite-support/issues/745#issuecomment-1224317799, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABWWO7UPZIPABKVF72VVXTV2T4QLANCNFSM5ODYUQLQ . You are receiving this because you commented.Message ID: @.***>

naarkhoo avatar Aug 23 '22 19:08 naarkhoo