Description
System information
- What is the top-level directory of the model you are using: object_detection
- Have I written custom code (as opposed to using a stock example script provided in TensorFlow): No.
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Amazon Linux AMI 2018.03
- TensorFlow installed from (source or binary): source
- TensorFlow version (use command below): v1.12.1-698-g1495d2a47c 1.13.1
- Bazel version (if compiling from source): 0.24.1
- CUDA/cuDNN version: N/A
- GPU model and memory: N/A (not using tensorflow-gpu)
- Exact command to reproduce: See Below
Describe the problem
Summary: When I convert any FPN-SSD model to *.tflite, the *.tflite model crashes upon calling interpreter.invoke().
Steps to reproduce:
I downloaded the ssd_resnet_50_fpn_coco model from the Tensorflow detection model zoo
I followed the instructions for Running on Mobile with TensorFlow Lite to convert the pretrained checkpoint to a floating-point model.
Specifically, I used the commands:
object_detection/export_tflite_ssd_graph.py \
--pipeline_config_path=$CONFIG_FILE \
--trained_checkpoint_prefix=$CHECKPOINT_PATH \
--output_directory=$OUTPUT_DIR \
--add_postprocessing_op=true
bazel run --config=opt tensorflow/lite/toco:toco -- \
--input_file=$OUTPUT_DIR/tflite_graph.pb \
--output_file=$OUTPUT_DIR/detect.tflite \
--input_shapes=1,640,640,3 \
--input_arrays=normalized_input_image_tensor \
--output_arrays='TFLite_Detection_PostProcess','TFLite_Detection_PostProcess:1','TFLite_Detection_PostProcess:2','TFLite_Detection_PostProcess:3' \
--inference_type=FLOAT \
--allow_custom_ops
I then ran the following python code (taken from here), with TFLITE_FILENAME being defined as $OUTPUT_DIR/detect.tflite
:
import numpy as np
import tensorflow as tf
# Load TFLite model and allocate tensors.
interpreter = tf.lite.Interpreter(model_path=TFLITE_FILENAME)
interpreter.allocate_tensors()
# Get input and output tensors.
input_details = interpreter.get_input_details()
output_details = interpreter.get_output_details()
# Test model on random input data.
input_shape = input_details[0]['shape']
input_data = np.array(np.random.random_sample(input_shape), dtype=np.float32)
interpreter.set_tensor(input_details[0]['index'], input_data)
interpreter.invoke()
The last line results in an Aborted
error.
I likewise got a SIGABRT
error when I tried to use this *.tflite model in the example iOS app from here.
I got similar behavior with the ssd_mobilenet_v1_fpn_coco model from the zoo. On the other hand, ssd_mobilenet_v1_0.75_depth_coco and ssd_inception_v2_coco worked just fine. I haven’t yet tested the other models from the zoo.
These problems are happening with pretrained checkpoints straight from the zoo (i.e. I haven’t touched them at all). I’m wondering if I’m doing something wrong with the conversion commands, or if the TFLite converter doesn’t actually support SSD models that use FPN. Can you please advise? Thanks!