Commit 991f75e2 authored by Karim Nosir's avatar Karim Nosir Committed by TF Object Detection Team
Browse files

Update instructions to reference tflite_convert and not toco. TOCO is deprecated.

PiperOrigin-RevId: 369749466
parent e3774f8c
......@@ -56,7 +56,7 @@
"id": "awjrpqy-6MaQ"
},
"source": [
"Important: If you're running on a local machine, be sure to follow the [installation instructions](https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/tf2.md). This notebook includes only what's necessary to run in Colab."
"Important: If you're running on a local machine, be sure to follow the [installation instructions](https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md). This notebook includes only what's necessary to run in Colab."
]
},
{
......@@ -79,7 +79,6 @@
},
"outputs": [],
"source": [
"!pip install --upgrade pip\n",
"!pip install -U --pre tensorflow==\"2.*\"\n",
"!pip install tf_slim"
]
......@@ -159,12 +158,23 @@
"outputs": [],
"source": [
"%%bash\n",
"cd models/research/\n",
"protoc object_detection/protos/*.proto --python_out=."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "s62yJyQUcYbp"
},
"outputs": [],
"source": [
"%%bash \n",
"cd models/research\n",
"# Compile protos.\n",
"protoc object_detection/protos/*.proto --python_out=.\n",
"# Install TensorFlow Object Detection API.\n",
"cp object_detection/packages/tf2/setup.py .\n",
"python -m pip install --use-feature=2020-resolver ."
"pip install ."
]
},
{
......@@ -611,7 +621,7 @@
},
"outputs": [],
"source": [
"masking_model.signatures['serving_default'].output_shapes"
"masking_model.output_shapes"
]
},
{
......
......@@ -14,5 +14,5 @@ jupyter notebook
```
The notebook should open in your favorite web browser. Click the
[`object_detection_tutorial.ipynb`](../colab_tutorials/object_detection_tutorial.ipynb) link to
[`object_detection_tutorial.ipynb`](../object_detection_tutorial.ipynb) link to
open the demo.
......@@ -51,22 +51,23 @@ will output the frozen graph that we can input to TensorFlow Lite directly and
is the one we’ll be using.
Next we’ll use TensorFlow Lite to get the optimized model by using
[TOCO](https://github.com/tensorflow/tensorflow/tree/master/tensorflow/lite/toco),
[TfLite Converter](https://www.tensorflow.org/lite/convert),
the TensorFlow Lite Optimizing Converter. This will convert the resulting frozen
graph (tflite_graph.pb) to the TensorFlow Lite flatbuffer format (detect.tflite)
via the following command. For a quantized model, run this from the tensorflow/
directory:
```shell
bazel run -c opt tensorflow/lite/toco:toco -- \
--input_file=$OUTPUT_DIR/tflite_graph.pb \
bazel run -c opt tensorflow/lite/python:tflite_convert -- \
--enable_v1_converter \
--graph_def_file=$OUTPUT_DIR/tflite_graph.pb \
--output_file=$OUTPUT_DIR/detect.tflite \
--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' \
--inference_type=QUANTIZED_UINT8 \
--mean_values=128 \
--std_values=128 \
--std_dev_values=128 \
--change_concat_input_ranges=false \
--allow_custom_ops
```
......@@ -84,8 +85,9 @@ parameters and can be run via the TensorFlow Lite interpreter on the Android
device. For a floating point model, run this from the tensorflow/ directory:
```shell
bazel run -c opt tensorflow/lite/toco:toco -- \
--input_file=$OUTPUT_DIR/tflite_graph.pb \
bazel run -c opt tensorflow/lite/python:tflite_convert -- \
--enable_v1_converter \
--graph_def_file=$OUTPUT_DIR/tflite_graph.pb \
--output_file=$OUTPUT_DIR/detect.tflite \
--input_shapes=1,300,300,3 \
--input_arrays=normalized_input_image_tensor \
......
......@@ -822,7 +822,7 @@ def reframe_box_masks_to_image_masks(box_masks, boxes, image_height,
A tensor of size [num_masks, image_height, image_width] with the same dtype
as `box_masks`.
"""
resize_method = 'nearest' if tf.uint8 == box_masks.dtype else resize_method
resize_method = 'nearest' if box_masks.dtype == tf.uint8 else resize_method
# TODO(rathodv): Make this a public function.
def reframe_box_masks_to_image_masks_default():
"""The default function when there are more than 0 box masks."""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment