tensorflow / tensorflow/models

Issues exporting ssdlite_mobilenet_v2 to tensorflow-lite

Open
#5,019 10 comments 1 reaction 2 assignees View on GitHub

@achowdhery is already working on this.

Since Aug 8, 2018.

models:research type:support
Dominant language
Python
Stars
77.7k
Forks
44.8k
PR merge metrics
No merged PRs in 30d

Description

System information
  • What is the top-level directory of the model you are using:

    • ssdlite_mobilenet_v2_coco_2018_05_09 pretrained model
  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow):

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04):
    Linux ubuntu 16.04

  • TensorFlow installed from binary (CPU):

  • TensorFlow version (use command below):

    • 1.5
Describe the problem

Hi:

I am trying to export ssdlite_Mobilenet_v2 model to tf-lite:
I downloaded from this path
I tried with these two ways:

1.- following this tutorial with export_tflite_ssd_graph.py, using the checkpoint
  • I use export_tflite_ssd_graph.py like this:

  export CHECKPOINT_PATH=/home/VICOMTECH/uelordi/projects/tflite_models/ssdlite_mobilenet_v2_coco_2018_05_09/model.ckpt

  export OUTPUT_DIR=/home/VICOMTECH/uelordi/projects/tflite_models/ssdlite_mobilenet_v2_coco_2018_05_09/tflite

    python /home/VICOMTECH/uelordi/SDK/tensorflow1/models/models/research/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
  • then I created toco script:
toco \
--input_file=tflite_graph.pb \
--output_file=latest_ssdlite_mobilenetv2.tflite \
  --input_format=TENSORFLOW_GRAPHDEF \
--input_shapes=1,300,300,3 \
  --output_format=TFLITE \
--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 \
--mean_values=128 \
--std_values=128 \
--change_concat_input_ranges=false \

and I got this errors:

Some of the operators in the model are not supported by the standard TensorFlow Lite runtime. If you have a custom implementation for them you can disable this error with --allow_custom_ops. Here is a list of operators for which you will need custom implementations: DIV, Squeeze, TFLite_Detection_PostProcess.

So I added allow-custom-ops, and when I use the tf-lite interperter in android:

d.tfLite = new Interpreter(loadModelFile(assetManager, modelFilename));

And as I supposed I have custom operation error.

Internal error: Cannot create interpreter: Didn't find custom op for name 'DIV' with version 1
Didn't find custom op for name 'Squeeze' with version 1
Registration failed.

2.- using toco with the pretrained model.

my toco script is:

toco \
--input_file=frozen_inference_graph.pb \
--output_file=ssd_lite_v2.tflite \
  --input_format=TENSORFLOW_GRAPHDEF \
--input_shapes=1,300,300,3 \
  --output_format=TFLITE \
--input_arrays=normalized_input_image_tensor \
--output_arrays='detection_boxes,detection_scores,detection_classes,num_detections' \
--inference_type=FLOAT \
--mean_values=128 \
--std_values=128 \
--change_concat_input_ranges=false \

As I have some errors with the operators I added allow-custom-ops, and when I use the tf-lite interperter in android:

d.tfLite = new Interpreter(loadModelFile(assetManager, modelFilename));

But as I supposed I have custom operation error.

Internal error: Cannot create interpreter: Didn't find custom op for name 'DIV' with version 1
Didn't find custom op for name 'Squeeze' with version 1
Registration failed.

So my questions are:

  • What makes different export_tflite_ssd_graph.py (with the checkpoint) from a common toco script with pretrained model? It creates custom operations? complementary postprocessing operations?
    *In case of toco pretrained problems: *
  • This means that I have to create my custom operation of DIV and Squeeze operations?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.