From 0b51a70b8313c524c558552a38d09bf63f1129f1 Mon Sep 17 00:00:00 2001 From: Mandy Li Date: Thu, 28 Feb 2019 15:33:31 -0800 Subject: [PATCH] Fix dummy data performance problem for RN50 FP32 and InceptionV3 FP32 (#204) --- .../inceptionv3/fp32/eval_image_classifier_inference.py | 7 ++++--- .../resnet50/fp32/eval_image_classifier_inference.py | 6 ++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/models/image_recognition/tensorflow/inceptionv3/fp32/eval_image_classifier_inference.py b/models/image_recognition/tensorflow/inceptionv3/fp32/eval_image_classifier_inference.py index c4880ef58..92454dbb1 100644 --- a/models/image_recognition/tensorflow/inceptionv3/fp32/eval_image_classifier_inference.py +++ b/models/image_recognition/tensorflow/inceptionv3/fp32/eval_image_classifier_inference.py @@ -89,6 +89,7 @@ def run(self): tf.global_variables_initializer() num_processed_images = 0 + num_remaining_images = IMAGENET_VALIDATION_IMAGES if (self.args.data_location): print("Inference with real data.") @@ -105,7 +106,8 @@ def run(self): - num_processed_images else: print("Inference with dummy data.") - num_remaining_images = IMAGENET_VALIDATION_IMAGES + input_shape = [self.args.batch_size, INCEPTION_V3_IMAGE_SIZE, INCEPTION_V3_IMAGE_SIZE, 3] + images = tf.random.uniform(input_shape, 0.0, 255.0, dtype=tf.float32, name='synthetic_images') if (not self.args.accuracy_only): # performance check iteration = 0 @@ -121,8 +123,7 @@ def run(self): preprocessed_images = sess.run([images[0]]) image_np = preprocessed_images[0] else: - image_np = np.random.rand(self.args.batch_size, INCEPTION_V3_IMAGE_SIZE, INCEPTION_V3_IMAGE_SIZE, 3) \ - .astype(np.uint8) + image_np = sess.run(images) num_processed_images += self.args.batch_size num_remaining_images -= self.args.batch_size 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 4cfe4881e..1bab552fc 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 @@ -114,6 +114,7 @@ def run(self): tf.global_variables_initializer() num_processed_images = 0 + num_remaining_images = IMAGENET_VALIDATION_IMAGES if (self.args.data_location): print("Inference with real data.") @@ -129,7 +130,8 @@ def run(self): - num_processed_images else: print("Inference with dummy data.") - num_remaining_images = IMAGENET_VALIDATION_IMAGES + input_shape = [self.args.batch_size, RESNET_IMAGE_SIZE, RESNET_IMAGE_SIZE, 3] + images = tf.random.uniform(input_shape, 0.0, 255.0, dtype=tf.float32, name='synthetic_images') if (not self.args.accuracy_only): # performance check iteration = 0 @@ -145,7 +147,7 @@ def run(self): preprocessed_images = sess.run([images[0]]) image_np = preprocessed_images[0] else: - image_np = np.random.rand(self.args.batch_size, RESNET_IMAGE_SIZE, RESNET_IMAGE_SIZE, 3).astype(np.uint8) + image_np = sess.run(images) num_processed_images += self.args.batch_size num_remaining_images -= self.args.batch_size