class_docstr: LSUN Bedrooms.
class_docstr_tok: ["LSUN","Bedrooms","."]
docstr: Downloads the datasets, extracts from zip and yields in PNG format.
docstr_tok: ["Downloads","the","datasets",",","extracts","from","zip","and","yields","in","PNG","format","."]
code: def read_and_convert_to_png(self, tmp_dir, split_name):
      """Downloads the datasets, extracts from zip and yields in PNG format."""
      category = "bedroom"
      _get_lsun(tmp_dir, category, split_name)
      filename = _LSUN_DATA_FILENAME % (category, split_name)
      data_path = os.path.join(tmp_dir, filename)
      print("Extracting zip file.")
      zip_ref = zipfile.ZipFile(data_path, "r")
      zip_ref.extractall(tmp_dir)
      zip_ref.close()
  
      print("Opening database.")
      data_file = os.path.join(
          tmp_dir, "%s_%s_lmdb/data.mdb" % (category, split_name)
      )
  
      filename_queue = tf.train.string_input_producer(
          [data_file], num_epochs=1
      )
      reader = tf.LMDBReader()
      _, webp_image_tensor = reader.read(filename_queue)
  
      object_count = 0
      with tf.train.MonitoredTrainingSession() as session:
          while True:
              webp_image = session.run(webp_image_tensor)
              object_count += 1
              if object_count % 1000 == 0:
                  print("Extracted %d objects." % object_count)
              # Unfortunately Tensorflow doesn't support reading or parsing
              # WebP images, so we have to do it via Image PIL library.
              image = pil_image().open(io.BytesIO(webp_image))
              buf = io.BytesIO()
              width, height = image.size
              image.save(buf, "PNG")
              yield {
                  "image/encoded": [buf.getvalue()],
                  "image/format": ["png"],
                  "image/class/label": [0],
                  "image/height": [height],
                  "image/width": [width],
              }
  
file_path: tensor2tensor/tensor2tensor/data_generators/image_lsun.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import io
  import os
  import zipfile
  from tensor2tensor.data_generators import generator_utils
  from tensor2tensor.data_generators import image_utils
  from tensor2tensor.utils import registry
  import tensorflow.compat.v1
label_desc: Use image node_id 3 for calling the ImageLsunBedrooms obj's underlying member method code with example usage: obj.read_and_convert_to_png(tmp_dir, split_name) without return types