Skip to content

Instantly share code, notes, and snippets.

bazel-bin/tensorflow/tools/graph_transforms/transform_graph \
--in_graph=/tmp/model/quantized_graph.pb \
--out_graph=/tmp/model/logged_quantized_graph.pb \
--inputs=Mul \
--outputs=softmax \
--transforms='insert_logging(op=RequantizationRange, show_name=true, message="__requant_min_max:")'
bazel build tensorflow/examples/label_image:label_image
bazel-bin/tensorflow/examples/label_image/label_image \
--input_mean=128 --input_std=128 --input_layer=Mul \
--output_layer=softmax --graph=/tmp/model/quantized_graph.pb \
--labels=/tmp/model/imagenet_comp_graph_label_strings.txt
bazel build tensorflow/tools/graph_transforms:transform_graph
bazel-bin/tensorflow/tools/graph_transforms/transform_graph \
--in_graph="/tmp/model/tensorflow_inception_graph.pb" \
--out_graph="/tmp/model/quantized_graph.pb" --inputs='Mul:0' \
--outputs='softmax:0' \
--transforms='add_default_attributes strip_unused_nodes(type=float, shape="1,299,299,3") remove_nodes(op=Identity, op=CheckNumerics) fold_old_batch_norms quantize_weights quantize_nodes strip_unused_nodes'
mkdir /tmp/model/
curl\
"https://storage.googleapis.com/download.tensorflow.org/ \
models/inception_dec_2015.zip" \
-o /tmp/model/inception_dec_2015.zip
unzip /tmp/model/inception_dec_2015.zip -d /tmp/model/
bazel build tensorflow/tools/quantization:graph_to_dot
bazel-bin/tensorflow/tools/quantization/graph_to_dot \
--graph=/tmp/tensorflow_inception_graph.pb \
--dot_output=/tmp/tensorflow_inception_graph.dot
bazel build -c opt --config=android_arm64 \
tensorflow/tools/benchmark:benchmark_model
adb push bazel-bin/tensorflow/tools/benchmark/benchmark_model \
/data/local/tmp
adb push /tmp/tensorflow_inception_graph.pb /data/local/tmp/
adb shell '/data/local/tmp/benchmark_model \
--graph=/data/local/tmp/tensorflow_inception_graph.pb \
--input_layer="Mul" --input_layer_shape="1,299,299,3" \
--input_layer_type="float" --output_layer="softmax:0" \
--show_run_order=false --show_time=false
bazel build -c opt tensorflow/tools/benchmark:benchmark_model \
&& bazel-bin/tensorflow/tools/benchmark/benchmark_model \
--graph=/tmp/tensorflow_inception_graph.pb \
--input_layer="Mul" --input_layer_shape="1,299,299,3" \
--input_layer_type="float" --output_layer="softmax:0" \
--show_run_order=false --show_time=false \
--show_memory=false --show_summary=true \
--show_flops=true --logtostderr
bazel build -c opt tensorflow/tools/benchmark:benchmark_model \
&& bazel-bin/tensorflow/tools/benchmark/benchmark_model \
--graph=/tmp/inception_graph.pb --input_layer="Mul:0" \
--input_layer_shape="1,299,299,3" --input_layer_type="float" \
--output_layer="softmax:0" \
--show_run_order=false --show_time=false \
--show_memory=false --show_summary=true --show_flops=true \
--logtostderr
bazel build tensorflow/tools/graph_transforms:transform_graph \
&& blaze-bin/tensorflow/tools/graph_transforms/transform_graph \
--in_graph=/tmp/tensorflow_inception_optimized.pb \
--out_graph=/tmp/tensorflow_inception_quantized.pb \
--inputs='Mul:0' \
--outputs='softmax:0' \
--transforms='quantize_weights'
bazel build tensorflow/tools/graph_transforms:summarize_graph \
&& bazel-bin/tensorflow/tools/graph_transforms/summarize_graph \
--in_graph=/tmp/tensorflow_inception_graph.pb