diff --git a/tensorflow/lite/examples/python/BUILD b/tensorflow/lite/examples/python/BUILD index e1321ec6f16..c1c0ac85b55 100644 --- a/tensorflow/lite/examples/python/BUILD +++ b/tensorflow/lite/examples/python/BUILD @@ -10,6 +10,6 @@ py_binary( python_version = "PY3", srcs_version = "PY2AND3", deps = [ - "//tensorflow/lite/python:lite", + "//tensorflow:tensorflow_py", ], ) diff --git a/tensorflow/lite/examples/python/label_image.py b/tensorflow/lite/examples/python/label_image.py index 0e288deb99e..6c753389831 100644 --- a/tensorflow/lite/examples/python/label_image.py +++ b/tensorflow/lite/examples/python/label_image.py @@ -23,7 +23,7 @@ import numpy as np from PIL import Image -from tensorflow.lite.python.interpreter import Interpreter +import tensorflow as tf # TF2 def load_labels(filename): @@ -58,7 +58,7 @@ if __name__ == '__main__': help='input standard deviation') args = parser.parse_args() - interpreter = Interpreter(model_path=args.model_file) + interpreter = tf.lite.Interpreter(model_path=args.model_file) interpreter.allocate_tensors() input_details = interpreter.get_input_details() diff --git a/tensorflow/lite/g3doc/guide/python.md b/tensorflow/lite/g3doc/guide/python.md index cb9cc09172f..545c80c1b76 100644 --- a/tensorflow/lite/g3doc/guide/python.md +++ b/tensorflow/lite/g3doc/guide/python.md @@ -78,16 +78,28 @@ For example, after you install the package above, copy and run the [`label_image.py`]( https://github.com/tensorflow/tensorflow/tree/master/tensorflow/lite/examples/python/) file. It will (probably) fail because you don't have the `tensorflow` library -installed. To fix it, simply edit this line of the file: +installed. To fix it, edit this line of the file: ```python -from tensorflow.lite.python.interpreter import Interpreter +import tensorflow as tf ``` So it instead reads: ```python -from tflite_runtime.interpreter import Interpreter +import tflite_runtime.interpreter as tflite +``` + +And then change this line: + +```python +interpreter = tf.lite.Interpreter(model_path=args.model_file) +``` + +So it reads: + +```python +interpreter = tflite.Interpreter(model_path=args.model_file) ``` Now run `label_image.py` again. That's it! You're now executing TensorFlow Lite