(self, ids, strip_extraneous=False)
return tmp_file_path
Transform a sequence of int IDs into an image file.

    Args:
      ids: list of integers to be converted.
      strip_extraneous: unused

    Returns:
      Path to the temporary file where the image was saved.

    Raises:
      ValueError: if the IDs are not of the appropriate size.
Transform a sequence of int IDs into an image file.
Transform a sequence of int IDs into an image file .
def decode(self, ids, strip_extraneous=False):
    """Transform a sequence of int IDs into an image file.

    Args:
      ids: list of integers to be converted.
      strip_extraneous: unused

    Returns:
      Path to the temporary file where the image was saved.

    Raises:
      ValueError: if the IDs are not of the appropriate size.
    """
    del strip_extraneous
    _, tmp_file_path = tempfile.mkstemp("_decode.png")
    if self._height is None or self._width is None:
      size = int(math.sqrt(len(ids) / self._channels))
      length = size * size * self._channels
    else:
      size = None
      length = self._height * self._width * self._channels
    if len(ids) != length:
      raise ValueError("Length of ids (%d) must be height (%d) x width (%d) x "
                       "channels (%d); %d != %d.\n Ids: %s" %
                       (len(ids), self._height, self._width, self._channels,
                        len(ids), length, " ".join([str(i) for i in ids])))
    with tf.Graph().as_default():
      raw = tf.constant(ids, dtype=tf.uint8)
      if size is None:
        img = tf.reshape(raw, [self._height, self._width, self._channels])
      else:
        img = tf.reshape(raw, [size, size, self._channels])
      png = tf.image.encode_png(img)
      op = tf.write_file(tmp_file_path, png)
      with tf.Session() as sess:
        sess.run(op)
    return tmp_file_path
def decode ( self , ids , strip_extraneous = False ) : del strip_extraneous _ , tmp_file_path = tempfile . mkstemp ( "_decode.png" ) if self . _height is None or self . _width is None : size = int ( math . sqrt ( len ( ids ) / self . _channels ) ) length = size * size * self . _channels else : size = None length = self . _height * self . _width * self . _channels if len ( ids ) != length : raise ValueError ( "Length of ids (%d) must be height (%d) x width (%d) x " "channels (%d); %d != %d.\n Ids: %s" % ( len ( ids ) , self . _height , self . _width , self . _channels , len ( ids ) , length , " " . join ( [ str ( i ) for i in ids ] ) ) ) with tf . Graph ( ) . as_default ( ) : raw = tf . constant ( ids , dtype = tf . uint8 ) if size is None : img = tf . reshape ( raw , [ self . _height , self . _width , self . _channels ] ) else : img = tf . reshape ( raw , [ size , size , self . _channels ] ) png = tf . image . encode_png ( img ) op = tf . write_file ( tmp_file_path , png ) with tf . Session ( ) as sess : sess . run ( op ) return tmp_file_path