I used the following example to create tensorflow model: http://cv-tricks.com/tensorflow-tutorial/training-convolutional-neural-network-for-image-classification/ You can download the code from here: https://github.com/sankit1/cv-tricks.com/tree/master/Tensorflow-tutorials/tutorial-2-image-classifier Also I used "2. Freezing the graph" section from http://cv-tricks.com/how-to/freeze-tensorflow-models/ to create a *.pb file of my model. I'm tried to convert *.pb file with toco command line tool, as describe on "Convert a TensorFlow SavedModel to TensorFlow Lite" at https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/lite/toco/g3doc/cmdline_examples.md#savedmodel and got he following error:
(venv) user@user-desktop:~/PycharmProjects/tensorflow_tutorial/tensorflow$ bazel run -c opt tensorflow/contrib/lite/toco:toco -- --savedmodel_directory=/home/user/PycharmProjects/tensorflow_tutorial/tutorial-2-image-classifier --output_file=/home/user/PycharmProjects/tensorflow_tutorial/tutorial-2-image-classifier/dogs-cats-model.tflite WARNING: /home/user/.cache/bazel/_bazel_user/e21a56d90e65395c94952f8aa3d0c4bc/external/protobuf_archive/WORKSPACE:1: Workspace name in /home/user/.cache/bazel/_bazel_user/e21a56d90e65395c94952f8aa3d0c4bc/external/protobuf_archive/WORKSPACE (@com_google_protobuf) does not match the name given in the repository's definition (@protobuf_archive); this will cause a build error in future versions INFO: Analysed target //tensorflow/contrib/lite/toco:toco (0 packages loaded). INFO: Found 1 target... WARNING: failed to create one or more convenience symlinks for prefix 'bazel-': cannot create symbolic link bazel-out -> /home/user/.cache/bazel/_bazel_user/e21a56d90e65395c94952f8aa3d0c4bc/execroot/org_tensorflow/bazel-out: /home/user/PycharmProjects/tensorflow_tutorial/tensorflow/bazel-out (File exists) cannot create symbolic link bazel-out -> /home/user/.cache/bazel/_bazel_user/e21a56d90e65395c94952f8aa3d0c4bc/execroot/org_tensorflow/bazel-out: /home/user/PycharmProjects/tensorflow_tutorial/tensorflow/bazel-out (File exists) cannot create symbolic link bazel-tensorflow -> /home/user/.cache/bazel/_bazel_user/e21a56d90e65395c94952f8aa3d0c4bc/execroot/org_tensorflow: /home/user/PycharmProjects/tensorflow_tutorial/tensorflow/bazel-tensorflow (File exists) cannot create symbolic link bazel-bin -> /home/user/.cache/bazel/_bazel_user/e21a56d90e65395c94952f8aa3d0c4bc/execroot/org_tensorflow/bazel-out/k8-opt/bin: /home/user/PycharmProjects/tensorflow_tutorial/tensorflow/bazel-bin (File exists) cannot create symbolic link bazel-testlogs -> /home/user/.cache/bazel/_bazel_user/e21a56d90e65395c94952f8aa3d0c4bc/execroot/org_tensorflow/bazel-out/k8-opt/testlogs: /home/user/PycharmProjects/tensorflow_tutorial/tensorflow/bazel-testlogs (File exists) cannot create symbolic link bazel-genfiles -> /home/user/.cache/bazel/_bazel_user/e21a56d90e65395c94952f8aa3d0c4bc/execroot/org_tensorflow/bazel-out/k8-opt/genfiles: /home/user/PycharmProjects/tensorflow_tutorial/tensorflow/bazel-genfiles (File exists) Target //tensorflow/contrib/lite/toco:toco up-to-date: /home/user/.cache/bazel/_bazel_user/e21a56d90e65395c94952f8aa3d0c4bc/execroot/org_tensorflow/bazel-out/k8-opt/bin/tensorflow/contrib/lite/toco/toco INFO: Elapsed time: 0.271s, Critical Path: 0.00s INFO: 0 processes. INFO: Build completed successfully, 1 total action INFO: Running command line: /home/user/.cache/bazel/_bazel_user/e21a56d90e65395c94952f8aa3d0c4bc/execroot/org_tensorflow/bazel-out/k8-opt/bin/tensorflow/contrib/lite/toco/toco '--savedmodel_directory=/home/user/PycharmProjects/tensorflow_tutorial/tutorial-2-image-classifier' '--output_file=/home/user/PycharmProjects/tensorflow_tutorial/tutorial-2-image-classifier/dogs-cats-model.tflite' 2018-05-07 01:33:13.776954: F tensorflow/contrib/lite/toco/toco_saved_model.cc:34] Check failed: tensorflow::MaybeSavedModelDirectory(model_path) Model is not saved in the supported SavedModel format.
The function which throw this error is MaybeSavedModelDirectory at https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/lite/toco/toco_saved_model.cc, I took a look at the implementation of it on https://github.com/tensorflow/tensorflow/blob/master/tensorflow/cc/saved_model/loader.cc Actually it looking for *.pb or *.pbtxt file on the model directory and I got this file on requested location, so why I get this error?
Machine details: OS Platform and Distribution - ubuntu x64, TensorFlow installed from - pip, TensorFlow version - cpu version 1.8.0, Bazel version - 0.13.0, CUDA/cuDNN version - no cuda, GPU model and memory - no gpu, Exact command to reproduce - no need, python version - 3.5.2