aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/examples/label_image
diff options
context:
space:
mode:
authorGravatar Peter Hawkins <phawkins@google.com>2017-05-09 09:14:16 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-05-10 16:29:47 -0700
commit1d0b8c007b8bc7f77dd63c74f02d87185071f038 (patch)
treeb72df4064224d66c62bb4a126efb06fa214fa439 /tensorflow/examples/label_image
parentb9845c6d0d5dc601fb3b58206a7070aa8937af4f (diff)
Remove unnecessary copies of value parameters.
PiperOrigin-RevId: 155511618
Diffstat (limited to 'tensorflow/examples/label_image')
-rw-r--r--tensorflow/examples/label_image/main.cc9
1 files changed, 5 insertions, 4 deletions
diff --git a/tensorflow/examples/label_image/main.cc b/tensorflow/examples/label_image/main.cc
index 8e3f69a6d6..ad032f93fd 100644
--- a/tensorflow/examples/label_image/main.cc
+++ b/tensorflow/examples/label_image/main.cc
@@ -32,6 +32,7 @@ limitations under the License.
// The googlenet_graph.pb file included by default is created from Inception.
#include <fstream>
+#include <utility>
#include <vector>
#include "tensorflow/cc/ops/const_op.h"
@@ -62,7 +63,7 @@ using tensorflow::int32;
// Takes a file name, and loads a list of labels from it, one per line, and
// returns a vector of the strings. It pads with empty strings so the length
// of the result is a multiple of 16, because our model expects that.
-Status ReadLabelsFile(string file_name, std::vector<string>* result,
+Status ReadLabelsFile(const string& file_name, std::vector<string>* result,
size_t* found_label_count) {
std::ifstream file(file_name);
if (!file) {
@@ -84,7 +85,7 @@ Status ReadLabelsFile(string file_name, std::vector<string>* result,
// Given an image file name, read in the data, try to decode it as an image,
// resize it to the requested size, and then scale the values as desired.
-Status ReadTensorFromImageFile(string file_name, const int input_height,
+Status ReadTensorFromImageFile(const string& file_name, const int input_height,
const int input_width, const float input_mean,
const float input_std,
std::vector<Tensor>* out_tensors) {
@@ -138,7 +139,7 @@ Status ReadTensorFromImageFile(string file_name, const int input_height,
// Reads a model graph definition from disk, and creates a session object you
// can use to run it.
-Status LoadGraph(string graph_file_name,
+Status LoadGraph(const string& graph_file_name,
std::unique_ptr<tensorflow::Session>* session) {
tensorflow::GraphDef graph_def;
Status load_graph_status =
@@ -185,7 +186,7 @@ Status GetTopLabels(const std::vector<Tensor>& outputs, int how_many_labels,
// Given the output of a model run, and the name of a file containing the labels
// this prints out the top five highest-scoring values.
Status PrintTopLabels(const std::vector<Tensor>& outputs,
- string labels_file_name) {
+ const string& labels_file_name) {
std::vector<string> labels;
size_t label_count;
Status read_labels_status =