class_docstr: TFDS definition for ShapenetPretraining dataset
class_docstr_tok: ["TFDS","definition","for","ShapenetPretraining","dataset"]
docstr: Yields examples.
docstr_tok: ["Yields","examples","."]
code: def _generate_examples(self, directories: List[str]):
      """Yields examples."""
  
      def _process_example(image_path):
          image_path = tfds.core.as_path(image_path)
          image_dir = image_path.parent
          image_index = int(
              image_path.name[-9:-4]
          )  # int("rgba_00008.png"[-9:-4]) -> 8
          key = f"{image_dir.name}_{image_index:05d}"
  
          with tf.io.gfile.GFile(
              str(image_dir / "metadata.json"), "r"
          ) as fp:
              metadata = json.load(fp)
  
          bbox = metadata["instances"][0]["bboxes"][image_index]
          y_min, x_min, y_max, x_max = [int(v * 512) for v in bbox]
          img = read_png(image_path)
  
          return key, {
              "image_id": key,
              "asset_id": metadata["instances"][0]["asset_id"].replace(
                  "_", "/"
              ),
              "label": metadata["instances"][0]["category"],
              "camera_position": np.array(
                  metadata["camera"]["positions"][image_index],
                  np.float32,
              ),
              "image": img[y_min : y_max + 1, x_min : x_max + 1],
          }
  
      beam = tfds.core.lazy_imports.apache_beam
      return beam.Create(directories) | beam.Map(_process_example)
  
file_path: kubric/challenges/pretraining_visual/shapenet_pretraining.py
imports: import itertools
  import json
  import logging
  import numpy
  import png
  import tensorflow
  import tensorflow_datasets.public_api
  from typing import List
label_desc: Use image node_id 3 for calling the ShapenetPretraining obj's underlying member method code with example usage: obj._generate_examples(directories) and returns: unknown, key,  dict