stMind

about Tech, Computer vision and Machine learning

Tensorflow Object Detection APIのCPU処理時間 on MacBook Pro

計測環境

  • MacBook Pro Late 2013モデル
    • CPU: 2.8GHz Corei7
    • Mem: 8GB 1600MHz DDR3
  • デフォルトで指定されているssd_mobilenet_v1_coco_2017_11_17

計測はTensorflowのtimelineを使用。

def run_inference_for_single_image(image, graph):
  with graph.as_default():
    with tf.Session() as sess:
      # timeline
      options = tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE)
      run_metadata = tf.RunMetadata()

      # 他の処理...

      # Run inference
      output_dict = sess.run(tensor_dict,
                             feed_dict={image_tensor: np.expand_dims(image, 0)}, options=options, run_metadata=run_metadata)

      # 他の処理...

      # Save timeline
      fetched_timeline = timeline.Timeline(run_metadata.step_stats)
      chrome_trace = fetched_timeline.generate_chrome_trace_format()
      with open('timeline.json', 'w') as f:
        f.write(chrome_trace)

  return output_dict     

計測結果

chrome://tracingで確認。読み取れる情報は

  • 全体で130ms程度
  • 最も時間がかかっているのは、TensorArrayScatterV3

Tensorflow Object Detection API、CPUでも十分速い。

f:id:satojkovic:20180930221255p:plain