diff --git a/README.md b/README.md index 900d7b588..529de54dd 100644 --- a/README.md +++ b/README.md @@ -3,4 +3,4 @@ This repository contains a number of models optimized by Intel to run machine learning workloads on Intel® Xeon® Scalable processors. For information on how to run key benchmarks, see the [README](/benchmarks) -in the benchmarks folder. How-tos and tutorials can be found in the [docs](/docs) folder. \ No newline at end of file +in the benchmarks folder. How-tos and tutorials can be found in the [docs](/docs) folder. diff --git a/docs/README.md b/docs/README.md index 4a2a820e5..4d421d881 100644 --- a/docs/README.md +++ b/docs/README.md @@ -15,4 +15,4 @@ * Intel-Optimized TensorFlow Serving: * [Image Recognition](/docs/image_recognition/tensorflow_serving/Tutorial.md) (ResNet50 and InceptionV3) * Object Detection (*coming soon*) - \ No newline at end of file + diff --git a/models/image_recognition/tensorflow/resnet50/fp32/eval_image_classifier_inference.py b/models/image_recognition/tensorflow/resnet50/fp32/eval_image_classifier_inference.py index da320c0c4..7613db6f3 100644 --- a/models/image_recognition/tensorflow/resnet50/fp32/eval_image_classifier_inference.py +++ b/models/image_recognition/tensorflow/resnet50/fp32/eval_image_classifier_inference.py @@ -72,12 +72,16 @@ def __init__(self): 'the benchmark will use random/dummy data.', dest="data_location", default=None) + arg_parser.add_argument('-s', "--steps", + help='Specify the number of inference steps.', + dest="steps", default=40) + arg_parser.add_argument('-r', "--accuracy-only", help='For accuracy measurement only.', dest='accuracy_only', action='store_true') # parse the arguments self.args = arg_parser.parse_args() - # validate the arguements + # validate the arguments self.validate_args() def run(self): @@ -92,7 +96,7 @@ def run(self): with tf.Session(config=config) as sess: - # convert the freezed graph to optimized graph + # convert the frozen graph to optimized graph graph_def = tf.GraphDef() with tf.gfile.FastGFile(self.args.input_graph, 'rb') as input_file: input_graph_content = input_file.read() @@ -127,13 +131,12 @@ def run(self): num_remaining_images = IMAGENET_VALIDATION_IMAGES if (not self.args.accuracy_only): # performance check - iteration = 0 + step = 0 warm_up_iteration = 10 - total_run = 40 total_time = 0 - while num_remaining_images >= self.args.batch_size and iteration < total_run: - iteration += 1 + while num_remaining_images >= self.args.batch_size and step < self.args.steps: + step += 1 # Reads and preprocess data if (self.args.data_location): @@ -149,11 +152,11 @@ def run(self): (predicts) = sess.run([output_tensor], feed_dict={input_tensor: image_np}) time_consume = time.time() - start_time - print('Iteration %d: %.3f sec' % (iteration, time_consume)) - if iteration > warm_up_iteration: + print('Iteration %d: %.3f sec' % (step, time_consume)) + if step > warm_up_iteration: total_time += time_consume - time_average = total_time / (iteration - warm_up_iteration) + time_average = total_time / (step - warm_up_iteration) print('Average time: %.3f sec' % (time_average)) print('Batch size = %d' % self.args.batch_size)