title: Reducing .tflite model size
body: <p>Any of the zoo .tflite models I see are no more than 3MB in size. On an edgetpu they run fine. However, when I train my own object detection model the .pb file is 60MB and the .tflite is also huge at 20MB! It's also quantized as per below. The end result is segmentation faults on an edgetpu object_detection model. What's causing this file to be so large? Do non-resized images being fed into the model cause the model to be large (some photos were 4096×2160 and not resized)? </p>
  
  <p>From object_detection</p>
  
  <p><strong>Train the model</strong></p>
  
  <pre><code>python train.py \
  --logtostderr \
  --train_dir=training \
  --pipeline_config_path=training/ssd_mobilenet_v1_coco.config
  </code></pre>
  
  <p><strong>Freeze the graph</strong> - creates 60MB .pb file </p>
  
  <pre><code>python export_tflite_ssd_graph.py \
  --pipeline_config_path=training/ssd_mobilenet_v2_coco.config \
  --trained_checkpoint_prefix=training/model.ckpt-2020 \
  --output_directory=inference_graph \
  --add_postprocessing_op=true 
  </code></pre>
  
  <p><strong>Convert to .tflite</strong> - creates 20MB .tflite file</p>
  
  <pre><code>tflite_convert 
  --graph_def_file=inference_graph/tflite_graph.pb \
  --output_file=inference_graph/detect.tflite \
  --inference_type=QUANTIZED_UINT8 \
  --input_shapes=1,300,300,3 \
  --input_arrays=normalized_input_image_tensor \
  --output_arrays=TFLite_Detection_PostProcess,TFLite_Detection_PostProcess:1,TFLite_Detection_PostProcess:2,TFLite_Detection_PostProcess:3 \
  --mean_values=128 \
  --std_dev_values=127 \
  --allow_custom_ops \
  --default_ranges_min=0 \
  --default_ranges_max=6
  </code></pre>
  
  <p>At this stage the .tflite file is pushed to the google coral edgetpu and the model is trialed on a USB camera attached to the TPU. </p>
  
  <pre><code>export DISPLAY=:0 &amp;&amp; edgetpu_detect \
  --source /dev/video1:YUY2:1280x720:20/1  \
  --model ${DEMO_FILES}/detect.tflite
  </code></pre>
  
  <p>End result is Segmentation Error.</p>
  
  <pre><code>INFO: Initialized TensorFlow Lite runtime.
  glvideomixer name=mixer background=black ! glimagesink sync=False name=glsink qos=False
  v4l2src device=/dev/video1 ! video/x-raw,height=720,framerate=20/1,format=YUY2,width=1280 ! glupload ! tee name=t
  t. ! glupload ! queue ! mixer.
  overlaysrc name=overlay ! video/x-raw,height=720,width=1280,format=BGRA ! glupload ! queue max-size-buffers=1 ! mixer.
  t. ! queue max-size-buffers=1 leaky=downstream ! glfilterbin filter=glcolorscale ! video/x-raw,height=168,width=300,format=RGBA ! videoconvert ! video/x-raw,height=168,width=300,format=RGB ! videobox autocrop=True ! video/x-raw,height=300,width=300 ! appsink max-buffers=1 sync=False emit-signals=True drop=True name=appsink
  Segmentation fault
  </code></pre>