remove network initialization time from benchmark
@@ -69,7 +69,7 @@ def _save_images(output_dir, filename_images):
logger.info("save image: {}".format(output_file_name))
-def _run(model, image_data, config):
+def _init(model, config):
filename, file_extension = os.path.splitext(model)
supported_files = ['.so', '.pb']
@@ -92,10 +92,12 @@ def _run(model, image_data, config):
nn = TensorflowGraphRunner(model)
nn.init()
- # run the graph
- output = nn.run(image_data)
+ return nn
- return output
+
+def _run(nn, image_data):
+ # run the graph
+ return nn.run(image_data)
def _timerfunc(func, extraArgs, trial):
@@ -127,6 +129,9 @@ def run_prediction(input_image, model, config_file, max_percent_incorrect_values
image_data = load_image(input_image)
raw_image = image_data
+ # initialize Network
+ nn = _init(model, config)
+
# pre process for image
image_data, bench_pre = _timerfunc(_pre_process, (image_data, config.PRE_PROCESSOR, config.DATA_FORMAT), trial)
@@ -134,7 +139,7 @@ def run_prediction(input_image, model, config_file, max_percent_incorrect_values
image_data = np.expand_dims(image_data, axis=0)
# run the model to inference
- output, bench_inference = _timerfunc(_run, (model, image_data, config), trial)
+ output, bench_inference = _timerfunc(_run, (nn, image_data), trial)
logger.info('Output: (before post process)\n{}'.format(output))
