Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TFlite] unable to bazel build tensorflow/contrib/lite/toco:toco #19521

Closed
gustavz opened this issue May 24, 2018 · 7 comments
Closed

[TFlite] unable to bazel build tensorflow/contrib/lite/toco:toco #19521

gustavz opened this issue May 24, 2018 · 7 comments

Comments

@gustavz
Copy link

gustavz commented May 24, 2018

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): Yes and No
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux Ubuntu 16.04)
  • TensorFlow installed from (source or binary): Source
  • TensorFlow version (use command below): 1.7
  • Python version: 2.7
  • Bazel version (if compiling from source): 0.13.0
  • GCC/Compiler version (if compiling from source): gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
  • CUDA/cuDNN version: 9 / 7
  • GPU model and memory: 4GB GTX 1050
  • Exact command to reproduce:

i trained a mask r-cnn model with mobilenet as backbone and i try to quantize it according to this guide: https://www.tensorflow.org/performance/quantization

My code looks like this:

MODEL_NAME="mask_rcnn_mobilenet_v1_400_coco_117k"

INPUT_FILE="models/${MODEL_NAME}/frozen_inference_graph.pb"
OUTPUT_FILE="models/${MODEL_NAME}/frozen_inference_graph.tflite"
INPUT_SHAPE="1,400,400,3"
INPUT_ARRAY=['image_tensor']
OUTPUT_ARRAY=['num_detections','detection_boxes','detection_scores','detection_classes','detection_masks']
STD_VALUE=127.5
MEAN_VALUE=127.5


bazel build tensorflow/contrib/lite/toco:toco && \
  ./bazel-bin/third_party/tensorflow/contrib/lite/toco/toco \
  --input_file=${INPUT_FILE} \
  --output_file=${OUTPU_FILE} \
  --input_format=TENSORFLOW_GRAPHDEF --output_format=TFLITE \
  --inference_type=QUANTIZED_UINT8 \
  --input_shape=${INPUT_SHAPE} \
  --input_array=${INPUT_ARRAY} \
  --output_array=${OUTPUT_ARRAY} \
  --std_value=${STD_VALUE} --mean_value=${MEAN_VALUE}

and this error i get:

ERROR: Skipping 'tensorflow/contrib/lite/toco:toco': no such package 'tensorflow/contrib/lite/toco': BUILD file not found on package path
WARNING: Target pattern parsing failed.
ERROR: no such package 'tensorflow/contrib/lite/toco': BUILD file not found on package path
INFO: Elapsed time: 1.132s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)

Another thing i don't understand is that when i try to run this code in my custom model folder i see this error:
ERROR: The 'build' command is only supported from within a workspace.

What is this supposed to mean?

So i tried it in the tensorflow/models

@gustavz gustavz changed the title [tflite] [TFlite] unable to bazel build tensorflow/contrib/lite/toco:toco May 24, 2018
@gustavz
Copy link
Author

gustavz commented May 24, 2018

#19525

@gustavz gustavz closed this as completed May 24, 2018
@rorlich
Copy link

rorlich commented May 24, 2018

Perhaps add 'exports_files(["toco"])' to tensorflow/contrib/lite/BUILD

@duyanfang123
Copy link

Perhaps add 'exports_files(["toco"])' to tensorflow/contrib/lite/BUILD

why add this ? I have got a same probilem such as GuatavZ ,what should I do ?

@duyanfang123
Copy link

#19525

excuse me ?Do you slove this problem ?

@defaultUser3214
Copy link

No, it appears in the current master version as well if you execute (from #15633 )

Strip out problematic nodes before even letting TOCO see the graphdef

bazel run -c opt tensorflow/python/tools/optimize_for_inference --
--input=$DETECT_PB --output=$STRIPPED_PB --frozen_graph=True
--input_names=Preprocessor/sub --output_names=concat,concat_1
--alsologtostderr

Run TOCO conversion.

bazel run tensorflow/contrib/lite/toco:toco --
--input_file=$STRIPPED_PB --output_file=$DETECT_FB
--input_format=TENSORFLOW_GRAPHDEF --output_format=TFLITE
--input_shapes=1,300,300,3 --input_arrays=Preprocessor/sub
--output_arrays=concat,concat_1 --inference_type=FLOAT --logtostderr

@KapoorHitesh
Copy link

The toco target has been moved from //tensorflow/contrib/lite/toco to //tensorflow/lite/toco

@yixunzhou
Copy link

The toco target has been moved from //tensorflow/contrib/lite/toco to //tensorflow/lite/toco

useful comment. thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants