<hr>
<h3 dir="auto">System information</h3>
<ul dir="auto">
<li><strong>The following is output of tf_env_collect.sh</strong>:<br>
== cat /etc/issue ===============================================<br>
Linux ubuntu 4.4.0-31-generic <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="115996914" data-permission-text="Title is private" data-url="https://github.com/tensorflow/tensorflow/issues/50" data-hovercard-type="issue" data-hovercard-url="/tensorflow/tensorflow/issues/50/hovercard" href="https://github.com/tensorflow/tensorflow/issues/50">#50</a>~14.04.1-Ubuntu SMP Wed Jul 13 01:07:32 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux<br>
VERSION="14.04.5 LTS, Trusty Tahr"<br>
VERSION_ID="14.04"</li>
</ul>
<p dir="auto">== are we in docker =============================================<br>
No</p>
<p dir="auto">== compiler =====================================================<br>
c++ (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4<br>
Copyright (C) 2013 Free Software Foundation, Inc.<br>
This is free software; see the source for copying conditions.  There is NO<br>
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.</p>
<p dir="auto">== uname -a =====================================================<br>
Linux ubuntu 4.4.0-31-generic <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="115996914" data-permission-text="Title is private" data-url="https://github.com/tensorflow/tensorflow/issues/50" data-hovercard-type="issue" data-hovercard-url="/tensorflow/tensorflow/issues/50/hovercard" href="https://github.com/tensorflow/tensorflow/issues/50">#50</a>~14.04.1-Ubuntu SMP Wed Jul 13 01:07:32 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux</p>
<p dir="auto">== check pips ===================================================<br>
numpy (1.13.3)<br>
protobuf (3.4.0)<br>
tensorflow (1.4.0)<br>
tensorflow-tensorboard (0.4.0rc2)</p>
<p dir="auto">== check for virtualenv =========================================<br>
True</p>
<p dir="auto">== tensorflow import ============================================<br>
tf.VERSION = 1.4.0<br>
tf.GIT_VERSION = v1.4.0-rc1-11-g130a514<br>
tf.COMPILER_VERSION = v1.4.0-rc1-11-g130a514<br>
Sanity check: array([1], dtype=int32)</p>
<p dir="auto">== env ==========================================================<br>
LD_LIBRARY_PATH is unset<br>
DYLD_LIBRARY_PATH is unset</p>
<p dir="auto">== nvidia-smi ===================================================<br>
tensorflow/tools/tf_env_collect.sh: line 105: nvidia-smi: command not found</p>
<p dir="auto">== cuda libs  ===================================================</p>
<h3 dir="auto">Describe the problem</h3>
<p dir="auto">The DecodeBmpOp class is the decoder of bmp file. The class is in<br>
tensorflow/core/kernels/decode_bmp_op.cc. When dealling with a bmp file, the decoder doesn't invalidate the meta info of bmp file, such as header_size, width, height. It causes a Out-of-Bound Read in DecodeBmpOp::Decode func or DecodeBmpOp ::Compute func. If given an evil bmp file, the program using this API will crash.</p>
<h3 dir="auto">Source code / logs</h3>
<ul dir="auto">
<li><strong>Here is the crash call stack of program</strong>:<br>
The bmp file  in the attachment causes a crash.</li>
</ul>
<p dir="auto">Program received signal SIGSEGV, Segmentation fault.<br>
0x0000000004200bc0 in tensorflow::DecodeBmpOp::Decode (this=this@entry=0x602400032a40, input=input@entry=0x601c000214ce "33", output=0x7fffcefcf800 "", width=width@entry=2336, height=height@entry=61727, channels=channels@entry=3, top_down=top_down@entry=false) at tensorflow/core/kernels/decode_bmp_op.cc:122<br>
Program received signal SIGSEGV (fault address 0x601c19caaa10)<br>
pwndbg&gt; bt<br>
#0  0x0000000004200bc0 in tensorflow::DecodeBmpOp::Decode (this=this@entry=0x602400032a40, input=input@entry=0x601c000214ce "33", output=0x7fffcefcf800 "", width=width@entry=2336, height=height@entry=61727, channels=channels@entry=3, top_down=top_down@entry=false) at tensorflow/core/kernels/decode_bmp_op.cc:122<br>
<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="115886302" data-permission-text="Title is private" data-url="https://github.com/tensorflow/tensorflow/issues/1" data-hovercard-type="issue" data-hovercard-url="/tensorflow/tensorflow/issues/1/hovercard" href="https://github.com/tensorflow/tensorflow/issues/1">#1</a>  0x0000000004202d3b in tensorflow::DecodeBmpOp::Compute (this=0x602400032a40, context=) at tensorflow/core/kernels/decode_bmp_op.cc:88<br>
<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="115894138" data-permission-text="Title is private" data-url="https://github.com/tensorflow/tensorflow/issues/2" data-hovercard-type="issue" data-hovercard-url="/tensorflow/tensorflow/issues/2/hovercard" href="https://github.com/tensorflow/tensorflow/issues/2">#2</a>  0x00007ffff3ed8880 in tensorflow::ThreadPoolDevice::Compute (this=, op_kernel=0x602400032a40, context=0x7fffffff8320) at tensorflow/core/common_runtime/threadpool_device.cc:59<br>
<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="115896656" data-permission-text="Title is private" data-url="https://github.com/tensorflow/tensorflow/issues/3" data-hovercard-type="issue" data-hovercard-url="/tensorflow/tensorflow/issues/3/hovercard" href="https://github.com/tensorflow/tensorflow/issues/3">#3</a>  0x00007ffff3d47110 in tensorflow::(anonymous namespace)::ExecutorState::Process (this=, tagged_node=..., scheduled_usec=) at tensorflow/core/common_runtime/executor.cc:1652<br>
<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="115898449" data-permission-text="Title is private" data-url="https://github.com/tensorflow/tensorflow/issues/4" data-hovercard-type="issue" data-hovercard-url="/tensorflow/tensorflow/issues/4/hovercard" href="https://github.com/tensorflow/tensorflow/issues/4">#4</a>  0x00007ffff3d4cc0c in operator() (__closure=) at tensorflow/core/common_runtime/executor.cc:2055<br>
<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="115910900" data-permission-text="Title is private" data-url="https://github.com/tensorflow/tensorflow/issues/5" data-hovercard-type="issue" data-hovercard-url="/tensorflow/tensorflow/issues/5/hovercard" href="https://github.com/tensorflow/tensorflow/issues/5">#5</a>  std::_Function_handler&lt;void(), tensorflow::(anonymous namespace)::ExecutorState::ScheduleReady(const TaggedNodeSeq&amp;, tensorflow::(anonymous namespace)::ExecutorState::TaggedNodeReadyQueue*)::__lambda3&gt;::_M_invoke(const std::_Any_data &amp;) (__functor=...) at /usr/include/c++/4.8/functional:2071<br>
<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="115911735" data-permission-text="Title is private" data-url="https://github.com/tensorflow/tensorflow/issues/6" data-hovercard-type="issue" data-hovercard-url="/tensorflow/tensorflow/issues/6/hovercard" href="https://github.com/tensorflow/tensorflow/issues/6">#6</a>  0x00007ffff3db2351 in operator() (this=0x7fffffff8790) at /usr/include/c++/4.8/functional:2471<br>
<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="115912111" data-permission-text="Title is private" data-url="https://github.com/tensorflow/tensorflow/issues/7" data-hovercard-type="issue" data-hovercard-url="/tensorflow/tensorflow/issues/7/hovercard" href="https://github.com/tensorflow/tensorflow/issues/7">#7</a>  operator() (__closure=, c=...) at tensorflow/core/common_runtime/graph_runner.cc:146<br>
<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="115914495" data-permission-text="Title is private" data-url="https://github.com/tensorflow/tensorflow/issues/8" data-hovercard-type="issue" data-hovercard-url="/tensorflow/tensorflow/issues/8/hovercard" href="https://github.com/tensorflow/tensorflow/issues/8">#8</a>  std::_Function_handler&lt;void(std::function&lt;void()&gt;), tensorflow::GraphRunner::Run(tensorflow::Graph*, tensorflow::FunctionLibraryRuntime*, const NamedTensorList&amp;, const std::vector&lt;std::basic_string &gt;&amp;, std::vectortensorflow::Tensor*)::__lambda2&gt;::_M_invoke(const std::_Any_data &amp;, std::function&lt;void()&gt;) (__functor=..., __args#0=...) at /usr/include/c++/4.8/functional:2071<br>
<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="115914691" data-permission-text="Title is private" data-url="https://github.com/tensorflow/tensorflow/issues/9" data-hovercard-type="issue" data-hovercard-url="/tensorflow/tensorflow/issues/9/hovercard" href="https://github.com/tensorflow/tensorflow/issues/9">#9</a>  0x00007ffff3ce0258 in operator() (__args#0=..., this=) at /usr/include/c++/4.8/functional:2471<br>
<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="115914766" data-permission-text="Title is private" data-url="https://github.com/tensorflow/tensorflow/issues/10" data-hovercard-type="issue" data-hovercard-url="/tensorflow/tensorflow/issues/10/hovercard" href="https://github.com/tensorflow/tensorflow/issues/10">#10</a> tensorflow::(anonymous namespace)::ExecutorState::ScheduleReady (this=0x6026000fd1a0, ready=..., inline_ready=0x0) at tensorflow/core/common_runtime/executor.cc:2055<br>
<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="115914813" data-permission-text="Title is private" data-url="https://github.com/tensorflow/tensorflow/issues/11" data-hovercard-type="issue" data-hovercard-url="/tensorflow/tensorflow/issues/11/hovercard" href="https://github.com/tensorflow/tensorflow/issues/11">#11</a> 0x00007ffff3d00a0c in ScheduleReady (inline_ready=0x0, ready=..., this=) at tensorflow/core/common_runtime/executor.cc:2046<br>
<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="115915395" data-permission-text="Title is private" data-url="https://github.com/tensorflow/tensorflow/issues/12" data-hovercard-type="issue" data-hovercard-url="/tensorflow/tensorflow/issues/12/hovercard" href="https://github.com/tensorflow/tensorflow/issues/12">#12</a> RunAsync (done=, this=) at tensorflow/core/common_runtime/executor.cc:1439<br>
<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="115918299" data-permission-text="Title is private" data-url="https://github.com/tensorflow/tensorflow/issues/13" data-hovercard-type="pull_request" data-hovercard-url="/tensorflow/tensorflow/pull/13/hovercard" href="https://github.com/tensorflow/tensorflow/pull/13">#13</a> tensorflow::(anonymous namespace)::ExecutorImpl::RunAsync (this=this@entry=0x602400032f40, args=..., done=...) at tensorflow/core/common_runtime/executor.cc:2564<br>
<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="115918464" data-permission-text="Title is private" data-url="https://github.com/tensorflow/tensorflow/issues/14" data-hovercard-type="issue" data-hovercard-url="/tensorflow/tensorflow/issues/14/hovercard" href="https://github.com/tensorflow/tensorflow/issues/14">#14</a> 0x00007ffff3db999f in Run (args=..., this=0x602400032f40) at ./tensorflow/core/common_runtime/executor.h:117<br>
<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="115922135" data-permission-text="Title is private" data-url="https://github.com/tensorflow/tensorflow/issues/15" data-hovercard-type="issue" data-hovercard-url="/tensorflow/tensorflow/issues/15/hovercard" href="https://github.com/tensorflow/tensorflow/issues/15">#15</a> tensorflow::GraphRunner::Run (this=this@entry=0x6004002d08f0, graph=graph@entry=0x603a00003140, function_library=function_library@entry=0x602400033800, inputs=std::vector of length 0, capacity 0, output_names=std::vector of length 1, capacity 1 = {...}, outputs=outputs@entry=0x7fffffffa810) at tensorflow/core/common_runtime/graph_runner.cc:174<br>
<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="115925923" data-permission-text="Title is private" data-url="https://github.com/tensorflow/tensorflow/issues/16" data-hovercard-type="issue" data-hovercard-url="/tensorflow/tensorflow/issues/16/hovercard" href="https://github.com/tensorflow/tensorflow/issues/16">#16</a> 0x00007ffff3c4f36d in tensorflow::ConstantFold (opts=..., function_library=function_library@entry=0x602400033800, env=env@entry=0x60060000e140, partition_device=partition_device@entry=0x6024000395c0, graph=graph@entry=0x603a00003480, was_mutated=was_mutated@entry=0x7fffffffb260) at tensorflow/core/common_runtime/constant_folding.cc:603<br>
<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="115925964" data-permission-text="Title is private" data-url="https://github.com/tensorflow/tensorflow/issues/17" data-hovercard-type="issue" data-hovercard-url="/tensorflow/tensorflow/issues/17/hovercard" href="https://github.com/tensorflow/tensorflow/issues/17">#17</a> 0x00007ffff3db02bd in tensorflow::GraphOptimizer::Optimize (this=this@entry=0x7fffffffbe90, runtime=runtime@entry=0x602400033800, env=0x60060000e140, device=0x6024000395c0, graph=graph@entry=0x60060038d2f0, shape_map=shape_map@entry=0x0) at tensorflow/core/common_runtime/graph_optimizer.cc:66<br>
<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="115926208" data-permission-text="Title is private" data-url="https://github.com/tensorflow/tensorflow/issues/18" data-hovercard-type="issue" data-hovercard-url="/tensorflow/tensorflow/issues/18/hovercard" href="https://github.com/tensorflow/tensorflow/issues/18">#18</a> 0x000000000ad04984 in tensorflow::DirectSession::GetOrCreateExecutors (this=this@entry=0x604000007080, inputs=..., outputs=..., target_nodes=..., executors_and_keys=executors_and_keys@entry=0x7fffffffc4f0, run_state_args=run_state_args@entry=0x7fffffffc730) at tensorflow/core/common_runtime/direct_session.cc:1208<br>
<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="115926362" data-permission-text="Title is private" data-url="https://github.com/tensorflow/tensorflow/issues/19" data-hovercard-type="issue" data-hovercard-url="/tensorflow/tensorflow/issues/19/hovercard" href="https://github.com/tensorflow/tensorflow/issues/19">#19</a> 0x000000000ad0d0f7 in tensorflow::DirectSession::Run (this=, run_options=..., inputs=std::vector of length 0, capacity 0, output_names=std::vector of length 1, capacity 1 = {...}, target_nodes=std::vector of length 0, capacity 0, outputs=0x0, run_metadata=0x0) at tensorflow/core/common_runtime/direct_session.cc:472<br>
<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="115927762" data-permission-text="Title is private" data-url="https://github.com/tensorflow/tensorflow/issues/20" data-hovercard-type="issue" data-hovercard-url="/tensorflow/tensorflow/issues/20/hovercard" href="https://github.com/tensorflow/tensorflow/issues/20">#20</a> 0x000000000ad6fa95 in tensorflow::ClientSession::Run (this=this@entry=0x7fffffffdc30, run_options=..., inputs=std::unordered_map with 0 elements, fetch_outputs=std::vector of length 1, capacity 1 = {...}, run_outputs=std::vector of length 0, capacity 0, outputs=outputs@entry=0x0, run_metadata=run_metadata@entry=0x0) at tensorflow/cc/client/client_session.cc:127<br>
<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="115927987" data-permission-text="Title is private" data-url="https://github.com/tensorflow/tensorflow/issues/21" data-hovercard-type="issue" data-hovercard-url="/tensorflow/tensorflow/issues/21/hovercard" href="https://github.com/tensorflow/tensorflow/issues/21">#21</a> 0x000000000ad74b6d in Run (outputs=0x0, run_outputs=std::vector of length 0, capacity 0, fetch_outputs=std::vector of length 1, capacity 1 = {...}, inputs=std::unordered_map with 0 elements, this=0x7fffffffdc30) at tensorflow/cc/client/client_session.cc:90<br>
<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="115928097" data-permission-text="Title is private" data-url="https://github.com/tensorflow/tensorflow/issues/22" data-hovercard-type="issue" data-hovercard-url="/tensorflow/tensorflow/issues/22/hovercard" href="https://github.com/tensorflow/tensorflow/issues/22">#22</a> tensorflow::ClientSession::Run (this=this@entry=0x7fffffffdc30, fetch_outputs=std::vector of length 1, capacity 1 = {...}, outputs=outputs@entry=0x0) at tensorflow/cc/client/client_session.cc:76<br>
<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="115928832" data-permission-text="Title is private" data-url="https://github.com/tensorflow/tensorflow/issues/23" data-hovercard-type="issue" data-hovercard-url="/tensorflow/tensorflow/issues/23/hovercard" href="https://github.com/tensorflow/tensorflow/issues/23">#23</a> 0x000000000048042a in main (argc=1, argc@entry=2, argv=argv@entry=0x7fffffffe2e8) at tensorflow/examples/decode_image/main.cc:99<br>
<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="115932607" data-permission-text="Title is private" data-url="https://github.com/tensorflow/tensorflow/issues/24" data-hovercard-type="issue" data-hovercard-url="/tensorflow/tensorflow/issues/24/hovercard" href="https://github.com/tensorflow/tensorflow/issues/24">#24</a> 0x00007ffff03c1f45 in __libc_start_main (main=0x47e4b0 &lt;main(int, char**)&gt;, argc=2, argv=0x7fffffffe2e8, init=, fini=, rtld_fini=, stack_end=0x7fffffffe2d8) at libc-start.c:287<br>
<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="115938248" data-permission-text="Title is private" data-url="https://github.com/tensorflow/tensorflow/issues/25" data-hovercard-type="issue" data-hovercard-url="/tensorflow/tensorflow/issues/25/hovercard" href="https://github.com/tensorflow/tensorflow/issues/25">#25</a> 0x0000000000737eca in _start ()</p>
<ul dir="auto">
<li><strong>source code of c++ program</strong>:<br>
#include <br>
#include <br>
#include </li>
</ul>
<p dir="auto">#include "tensorflow/cc/ops/const_op.h"<br>
#include "tensorflow/cc/ops/image_ops.h"<br>
#include "tensorflow/cc/ops/standard_ops.h"<br>
#include "tensorflow/core/framework/graph.pb.h"<br>
#include "tensorflow/core/framework/tensor.h"<br>
#include "tensorflow/core/graph/default_device.h"<br>
#include "tensorflow/core/graph/graph_def_builder.h"<br>
#include "tensorflow/core/lib/core/errors.h"<br>
#include "tensorflow/core/lib/core/stringpiece.h"<br>
#include "tensorflow/core/lib/core/threadpool.h"<br>
#include "tensorflow/core/lib/io/path.h"<br>
#include "tensorflow/core/lib/strings/stringprintf.h"<br>
#include "tensorflow/core/platform/env.h"<br>
#include "tensorflow/core/platform/init_main.h"<br>
#include "tensorflow/core/platform/logging.h"<br>
#include "tensorflow/core/platform/types.h"<br>
#include "tensorflow/core/public/session.h"<br>
#include "tensorflow/core/util/command_line_flags.h"<br>
#include "tensorflow/cc/client/client_session.h"</p>
<p dir="auto">// These are all common classes it's handy to reference with no namespace.<br>
using tensorflow::Flag;<br>
using tensorflow::Tensor;<br>
using tensorflow::Status;<br>
using tensorflow::string;<br>
using tensorflow::int32;</p>
<p dir="auto">int main(int argc, char* argv[]) {<br>
string image = "tensorflow/examples/label_image/data/grace_hopper.jpg";<br>
std::vector flag_list = {<br>
Flag("image", &amp;image, "image to be processed"),<br>
};<br>
string usage = tensorflow::Flags::Usage(argv[0], flag_list);<br>
const bool parse_result = tensorflow::Flags::Parse(&amp;argc, argv, flag_list);<br>
if (!parse_result) {<br>
LOG(ERROR) &lt;&lt; usage;<br>
return -1;<br>
}</p>
<p dir="auto">// We need to call this to set up global state for TensorFlow.<br>
tensorflow::port::InitMain(argv[0], &amp;argc, &amp;argv);<br>
if (argc &gt; 1) {<br>
LOG(ERROR) &lt;&lt; "Unknown argument " &lt;&lt; argv[1] &lt;&lt; "\n" &lt;&lt; usage;<br>
return -1;<br>
}</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="    using namespace ::tensorflow::ops;"><pre class="notranslate"><code class="notranslate">    using namespace ::tensorflow::ops;
</code></pre></div>
<p dir="auto">auto root = tensorflow::Scope::NewRootScope();<br>
tensorflow::Output file_reader = ReadFile(root.WithOpName("input_image"), image);<br>
tensorflow::Output gif_reader = DecodeGif(root.WithOpName("gif_reader"), file_reader);<br>
tensorflow::Output bmp_reader = DecodeBmp(root.WithOpName("bmp_reader"), file_reader);<br>
tensorflow::Output jpeg_reader = DecodeJpeg(root.WithOpName("jpeg_reader"), file_reader);<br>
tensorflow::Output png_reader = DecodePng(root.WithOpName("png_reader"), file_reader);</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="    std::vector&lt;tensorflow::Tensor&gt; outputs;
    tensorflow::ClientSession session(root);"><pre class="notranslate"><code class="notranslate">    std::vector&lt;tensorflow::Tensor&gt; outputs;
    tensorflow::ClientSession session(root);
</code></pre></div>
<p dir="auto">session.Run({gif_reader}, nullptr);<br>
session.Run({bmp_reader}, nullptr);<br>
session.Run({jpeg_reader}, nullptr);<br>
session.Run({png_reader}, nullptr);</p>
<p dir="auto">return 0;<br>
}</p>
<ul dir="auto">
<li><strong>source code of python program</strong>:<br>
import argparse<br>
import tensorflow as tf</li>
</ul>
<p dir="auto">if <strong>name</strong> == "<strong>main</strong>":<br>
file_name = "tensorflow/examples/label_image/data/grace_hopper.jpg"<br>
parser = argparse.ArgumentParser()<br>
parser.add_argument("--image", help="image to be processed")<br>
args = parser.parse_args()<br>
if args.image:<br>
file_name = args.image<br>
file_reader = tf.read_file(file_name, "file_reader")<br>
image_reader = tf.image.decode_bmp(file_reader, name='bmp_reader')<br>
sess = tf.Session()<br>
sess.run(image_reader)</p>
<p dir="auto"><a href="https://github.com/tensorflow/tensorflow/files/1512398/evil.zip">evil.zip</a></p>
<p dir="auto">Related to <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="193922951" data-permission-text="Title is private" data-url="https://github.com/tensorflow/tensorflow/issues/6134" data-hovercard-type="issue" data-hovercard-url="/tensorflow/tensorflow/issues/6134/hovercard" href="https://github.com/tensorflow/tensorflow/issues/6134">#6134</a>. Right now, the users of the <code class="notranslate">tensorflow/python/tools</code> scripts have these options:</p>
<ul dir="auto">
<li>Download and save a copy of the individual <code class="notranslate">.py</code> file with whatever model/project they are working on, so that it is bundled with their code. This causes tons of code duplication across projects.</li>
<li>Import the tools programmatically and use them there. Being able to do this is extremely handy, but often the most convenient way to use the tool (and the way they are generally designed to be used) are as ad-hoc command-line calls.</li>
<li>Build a binary using Bazel. This is extremely inconvenient, and doesn't really solve the problem of code-reuse from above. I'd also argue that building a binary for what amounts to a Python script is overkill.</li>
<li>Create a custom CLI/module/alias that bundles these tools together (or allows for a single tool to be called from anywhere). This is convenient, but complicates setting up a development environment, and leads to divergent patterns across the user base.</li>
</ul>
<p dir="auto">I think having some sort of unified tool that is able to provide uniform access to the CLI of frequently used tools, such as <code class="notranslate">freeze_graph.py</code> and <code class="notranslate">saved_model_cli.py</code> would greatly improve UX, as well as make it much easier to explain how to use these tools. Additionally, it would help prevent version mismatches of tooling, as the correct version of the tool would already be at their fingertips (instead of fumbling through GitHub branches).</p>
<p dir="auto">I think having some sort of simple umbrella module, let's call it <code class="notranslate">tftools</code>, which provides access to the underlying python files would suffice. E.g.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ tftools freeze_graph --input_graph=... --output_graph=...

$ tftools saved_model_cli show --dir /tmp/saved_model_dir"><pre class="notranslate"><code class="notranslate">$ tftools freeze_graph --input_graph=... --output_graph=...

$ tftools saved_model_cli show --dir /tmp/saved_model_dir
</code></pre></div>
<p dir="auto">This would be a little bit of legwork, but I think the benefit-out to effort-in ratio is pretty large, at least from a user perspective. Not sure if the TensorFlow team would want to handle this or leave it to the community (if I can get company approval, I'd be happy to take a crack at it).</p>