code: def iterate(self):
      for image_id in self._get_record_names():
          if self._stop_iteration():
              return
  
          if self._should_skip(image_id):
              continue
  
          try:
              annotation_path = self._get_image_annotation(image_id)
              image_path = self._get_image_path(image_id)
              # Read both the image and the annotation into memory.
              annotation = read_xml(annotation_path)
              image = read_image(image_path)
          except tf.errors.NotFoundError:
              tf.logging.debug(
                  'Error reading image or annotation for "{}".'.format(
                      image_id
                  )
              )
              self.errors += 1
              continue
  
          objects = annotation.get("object")
          if objects is None:
              # If there's no bounding boxes, we don't want it.
              continue
  
          image_pil = Image.open(six.BytesIO(image))
          width = image_pil.width
          height = image_pil.height
  
          gt_boxes = []
          for b in annotation["object"]:
              try:
                  label_id = self.classes.index(self._wnids[b["name"]])
              except ValueError:
                  continue
  
              (xmin, ymin, xmax, ymax) = self._adjust_bbox(
                  xmin=int(b["bndbox"]["xmin"]),
                  ymin=int(b["bndbox"]["ymin"]),
                  xmax=int(b["bndbox"]["xmax"]),
                  ymax=int(b["bndbox"]["ymax"]),
                  old_width=int(annotation["size"]["width"]),
                  old_height=int(annotation["size"]["height"]),
                  new_width=width,
                  new_height=height,
              )
  
              gt_boxes.append(
                  {
                      "label": label_id,
                      "xmin": xmin,
                      "ymin": ymin,
                      "xmax": xmax,
                      "ymax": ymax,
                  }
              )
  
          if len(gt_boxes) == 0:
              continue
  
          record = {
              "width": width,
              "height": height,
              "depth": 3,
              "filename": annotation["filename"],
              "image_raw": image,
              "gt_boxes": gt_boxes,
          }
  
          self._will_add_record(record)
          self.yielded_records += 1
  
          yield record
  
file_path: luminoth/luminoth/tools/dataset/readers/object_detection/imagenet.py
imports: import json
  import os
  import six
  import tensorflow
  from PIL import Image
  from luminoth.tools.dataset.readers import InvalidDataDirectory
  from luminoth.tools.dataset.readers.object_detection import ObjectDetectionReader
  from luminoth.utils.dataset import read_xml, read_image
label_desc: Use image node_id 4 for calling the ImageNetReader obj's underlying member method code with example usage: obj.iterate() without return types