def load_image_from_file(self, filename, shape):
    'Given a filename, try to open the file. If failed, return None.\n\n    Args:\n      filename: location of the image file\n      shape: the shape of the image file to be scaled\n\n    Returns:\n      the image if succeeds, None if fails.\n\n    Rasies:\n      exception if the image was not the right shape.\n    '
    if (not tf.gfile.Exists(filename)):
        tf.logging.error('Cannot find file: {}'.format(filename))
        return None
    try:
        img = np.array(PIL.Image.open(tf.gfile.Open(filename, 'rb')).convert('RGB').resize(shape, PIL.Image.BILINEAR))
        img = (np.float32(img) / 255.0)
        if (not ((len(img.shape) == 3) and (img.shape[2] == 3))):
            return None
        else:
            return img
    except Exception as e:
        tf.logging.info(e)
        return None
    return img
Given a filename, try to open the file. If failed, return None.

Args:
  filename: location of the image file
  shape: the shape of the image file to be scaled

Returns:
  the image if succeeds, None if fails.

Rasies:
  exception if the image was not the right shape.
def load_image_from_file(self, filename, shape):
    'Given a filename, try to open the file. If failed, return None.\n\n    Args:\n      filename: location of the image file\n      shape: the shape of the image file to be scaled\n\n    Returns:\n      the image if succeeds, None if fails.\n\n    Rasies:\n      exception if the image was not the right shape.\n    '
    if (not tf.gfile.Exists(filename)):
        tf.logging.error('Cannot find file: {}'.format(filename))
        return None
    try:
        img = np.array(PIL.Image.open(tf.gfile.Open(filename, 'rb')).convert('RGB').resize(shape, PIL.Image.BILINEAR))
        img = (np.float32(img) / 255.0)
        if (not ((len(img.shape) == 3) and (img.shape[2] == 3))):
            return None
        else:
            return img
    except Exception as e:
        tf.logging.info(e)
        return None
    return img