Skip to content

Commit 0b51a70

Browse files
Mandy Lidmsuehir
authored andcommitted
Fix dummy data performance problem for RN50 FP32 and InceptionV3 FP32 (#204)
1 parent 8e64ea1 commit 0b51a70

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

models/image_recognition/tensorflow/inceptionv3/fp32/eval_image_classifier_inference.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ def run(self):
8989
tf.global_variables_initializer()
9090

9191
num_processed_images = 0
92+
num_remaining_images = IMAGENET_VALIDATION_IMAGES
9293

9394
if (self.args.data_location):
9495
print("Inference with real data.")
@@ -105,7 +106,8 @@ def run(self):
105106
- num_processed_images
106107
else:
107108
print("Inference with dummy data.")
108-
num_remaining_images = IMAGENET_VALIDATION_IMAGES
109+
input_shape = [self.args.batch_size, INCEPTION_V3_IMAGE_SIZE, INCEPTION_V3_IMAGE_SIZE, 3]
110+
images = tf.random.uniform(input_shape, 0.0, 255.0, dtype=tf.float32, name='synthetic_images')
109111

110112
if (not self.args.accuracy_only): # performance check
111113
iteration = 0
@@ -121,8 +123,7 @@ def run(self):
121123
preprocessed_images = sess.run([images[0]])
122124
image_np = preprocessed_images[0]
123125
else:
124-
image_np = np.random.rand(self.args.batch_size, INCEPTION_V3_IMAGE_SIZE, INCEPTION_V3_IMAGE_SIZE, 3) \
125-
.astype(np.uint8)
126+
image_np = sess.run(images)
126127

127128
num_processed_images += self.args.batch_size
128129
num_remaining_images -= self.args.batch_size

models/image_recognition/tensorflow/resnet50/fp32/eval_image_classifier_inference.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ def run(self):
114114
tf.global_variables_initializer()
115115

116116
num_processed_images = 0
117+
num_remaining_images = IMAGENET_VALIDATION_IMAGES
117118

118119
if (self.args.data_location):
119120
print("Inference with real data.")
@@ -129,7 +130,8 @@ def run(self):
129130
- num_processed_images
130131
else:
131132
print("Inference with dummy data.")
132-
num_remaining_images = IMAGENET_VALIDATION_IMAGES
133+
input_shape = [self.args.batch_size, RESNET_IMAGE_SIZE, RESNET_IMAGE_SIZE, 3]
134+
images = tf.random.uniform(input_shape, 0.0, 255.0, dtype=tf.float32, name='synthetic_images')
133135

134136
if (not self.args.accuracy_only): # performance check
135137
iteration = 0
@@ -145,7 +147,7 @@ def run(self):
145147
preprocessed_images = sess.run([images[0]])
146148
image_np = preprocessed_images[0]
147149
else:
148-
image_np = np.random.rand(self.args.batch_size, RESNET_IMAGE_SIZE, RESNET_IMAGE_SIZE, 3).astype(np.uint8)
150+
image_np = sess.run(images)
149151

150152
num_processed_images += self.args.batch_size
151153
num_remaining_images -= self.args.batch_size

0 commit comments

Comments
 (0)