title: How to convert ssd_resnet_50 tensorflow checkpoint to .tflite?
body: <p>I'm trying to convert the ssd_resnet_50 model from the tensorflow <a href="https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/detection_model_zoo.md" rel="nofollow noreferrer">Object Detection API</a> to .tflite format but it doesn't work.</p>
  
  <p><strong>Some background</strong>:</p>
  
  <ol>
  <li><p>I'm able to successfully convert the out of the box and retrained <code>ssd_mobilenet_v2_quantized</code> model to <code>.tflite</code> and run the .<code>tflite</code> model.</p></li>
  <li><p>Because the s<code>sd_resnet_50</code> model is not quantized, I've added the following to the <code>ssd_resnet_50</code> <code>pipeline.config</code> file and retrained the model:</p></li>
  </ol>
  
  <pre><code>graph_rewriter {
    quantization {
      delay: 48000
      weight_bits: 8
      activation_bits: 8
    }
  }
  </code></pre>
  
  <p>After retraining <code>ssd_resnet_50</code>, I try to convert the model to <code>.tflite</code> format with the following commands:</p>
  
  <pre><code># Produces tflite_graph.pb
  python3 object_detection/export_tflite_ssd_graph.py \
          --pipeline_config_path=pipeline.config \
          --trained_checkpoint_prefix=model.ckpt-50000 \
          --output_directory=$OUTPUT_DIR \
          --add_postprocessing_op=true
  
  # Produces detect.tflite
  bazel run -c 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=QUANTIZED_UINT8 \
      --mean_values=128 \
      --std_values=128 \
      --change_concat_input_ranges=false \
      --allow_custom_ops
  </code></pre>
  
  <p>Normally, <code>TOCO</code> would produce a valid <code>detect.tflite</code> that could be run. However, <code>TOCO</code> runs into the following error regarding quantization and Relu6. </p>
  
  <p>Can anyone help?</p>
  
  <hr>
  
  <p><strong>Error :</strong> </p>
  
  <pre><code>2019-05-21 10:41:07.885065: F tensorflow/lite/toco/tooling_util.cc:1718] Array WeightSharedConvolutionalBoxPredictor_2/BoxPredictionTower/conv2d_0/BatchNorm/feature_2/FusedBatchNorm_mul_0, which is an input to the Add operator producing the output array WeightSharedConvolutionalBoxPredictor_2/Relu6, is lacking min/max data, which is necessary for quantization. If accuracy matters, either target a non-quantized output format, or run quantized training with your model from a floating point checkpoint to change the input graph to contain min/max information. If you don't care about accuracy, you can pass --default_ranges_min= and --default_ranges_max= for easy experimentation.
  run_toco.sh: line 25:  3280 Aborted                 (core dumped) bazel run -c 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=QUANTIZED_UINT8 --mean_values=128 --std_values=128 --change_concat_input_ranges=false --allow_custom_ops
  </code></pre>