inputs.py 文件源码

python
阅读 38 收藏 0 点赞 0 评论 0

项目:tf_classification 作者: visipedia 项目源码 文件源码
def prepare_image(image, input_height=299, input_width=299):
  """ Prepare an image to be passed through a network.
  Arguments:
    image (numpy.ndarray): An uint8 RGB image
  Returns:
    list: the image resized, centered and raveled
  """

  # We assume an uint8 RGB image
  assert image.dtype == np.uint8
  assert image.ndim == 3
  assert image.shape[2] == 3

  resized_image = imresize(image, (input_height, input_width, 3))
  float_image = resized_image.astype(np.float32)
  centered_image = ((float_image / 255.) - 0.5) * 2.0

  return centered_image.ravel().tolist()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号