class_docstr: Object detection reader for data tagged using Taggerine:
  https://github.com/tryolabs/taggerine/
class_docstr_tok: ["Object","detection","reader","for","data","tagged","using","Taggerine",":","https",":","\/\/github.com\/tryolabs\/taggerine\/"]
code: def iterate(self):
      for annotation in self.annotations:
          # Checks that we don't yield more records than necessary.
          if self._stop_iteration():
              return
  
          image_id = annotation["image_id"]
  
          if self._should_skip(image_id):
              continue
  
          try:
              image = read_image(annotation["path"])
          except tf.errors.NotFoundError:
              tf.logging.debug(
                  'Error reading image or annotation for "{}".'.format(
                      image_id
                  )
              )
              self.errors += 1
              continue
  
          # Parse image bytes with PIL to get width and height.
          image_pil = Image.open(six.BytesIO(image))
          img_width = image_pil.width
          img_height = image_pil.height
  
          gt_boxes = []
          for b in annotation["gt_boxes"]:
              try:
                  label_id = self.classes.index(
                      b.get("label", self._default_class)
                  )
              except ValueError:
                  continue
  
              if (
                  "height" in b
                  and "width" in b
                  and "x" in b
                  and "y" in b
              ):
                  gt_boxes.append(
                      {
                          "label": label_id,
                          "xmin": b["x"] * img_width,
                          "ymin": b["y"] * img_height,
                          "xmax": b["x"] * img_width
                          + b["width"] * img_width,
                          "ymax": b["y"] * img_height
                          + b["height"] * img_height,
                      }
                  )
              else:
                  gt_boxes.append(
                      {
                          "label": label_id,
                          "xmin": b["x_min"] * img_width,
                          "ymin": b["y_min"] * img_height,
                          "xmax": b["x_max"] * img_width,
                          "ymax": b["y_max"] * img_height,
                      }
                  )
  
          if len(gt_boxes) == 0:
              tf.logging.debug(
                  'Image "{}" has zero valid gt_boxes.'.format(image_id)
              )
              self.errors += 1
              continue
  
          record = {
              "width": img_width,
              "height": img_height,
              "depth": 3,
              "filename": image_id,
              "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/taggerine.py
imports: import collections
  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_image
label_desc: Use image node_id 5 for calling the TaggerineReader obj's underlying member method code with example usage: obj.iterate() without return types