class_docstr: TFDS definition for ShapenetPretraining dataset
class_docstr_tok: ["TFDS","definition","for","ShapenetPretraining","dataset"]
docstr: Returns SplitGenerators.
docstr_tok: ["Returns","SplitGenerators","."]
code: def _split_generators(
      self, unused_dl_manager: tfds.download.DownloadManager
  ):
      """Returns SplitGenerators."""
      del unused_dl_manager
  
      # find all available directories
      path = tfds.core.as_path(
          "gs://research-brain-kubric-xgcp/jobs/shapenet_demo_7/"
      )
      all_subdirs = list(
          path.glob("*")
      )  # if (d / "metadata.json").exists()]
      # figure out how many images per directory exist
      nr_images_per_dir = len(list(all_subdirs[0].glob("rgba_*.png")))
      logging.info(
          "Found %d sub-folders with %d images each in master path: %s",
          len(all_subdirs),
          nr_images_per_dir,
          path,
      )
  
      # we pick one view for each object for validation and the others for train
      # views are random so we can just pick the first one for validation
      val_all_image_paths = [
          str(d / "rgba_00000.png") for d in all_subdirs
      ]
      train_all_image_paths = [
          str(d / "rgba_{:05d}.png".format(i))
          for d, i in itertools.product(
              all_subdirs, range(1, nr_images_per_dir)
          )
      ]
      # directories are sorted by categories, so we shuffle
      np.random.shuffle(train_all_image_paths)
  
      logging.info(
          "Using 1 image per object for validation for a total of %d images",
          len(val_all_image_paths),
      )
      logging.info(
          "Using the other %d images for train",
          len(train_all_image_paths),
      )
  
      return {
          tfds.Split.TRAIN: self._generate_examples(
              train_all_image_paths
          ),
          tfds.Split.VALIDATION: self._generate_examples(
              val_all_image_paths
          ),
      }
  
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 2 for calling the ShapenetPretraining obj's underlying member method code with example usage: obj._split_generators(unused_dl_manager) and returns: dict