reader.py 文件源码

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

项目:SpikeFlow 作者: deeperic 项目源码 文件源码
def _read_pngs_from(path):
  """Reads directory of images.
  Args:
    path: path to the directory

  Returns:
    A list of all images in the directory in the TF format (You need to call sess.run() or .eval() to get the value).
  """
  images = []
  png_files_path = glob.glob(os.path.join(path, '*.[pP][nN][gG]'))
  for filename in png_files_path:
    im = Image.open(filename)
    im = np.asarray(im, np.uint8)

    # get only images name, not path
    image_name = filename.split('/')[-1].split('.')[0]
    images.append([int(image_name), im])

  images = sorted(images, key=lambda image: image[0])

  images_only = [np.asarray(image[1], np.uint8) for image in images]  # Use unint8 or you will be !!!
  images_only = np.array(images_only)

  #print(images_only.shape)
  return images_only
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号