def read_object(objects, image_id):
  """Read R-CNN object data from HDF5 file."""
  # Super slow but oh well.
  should_close = False
  if isinstance(objects, str):
    should_close = True
    objects = h5py.File(objects, "r")
  image_id = str(image_id)
  image_features = objects["features-" + image_id][:]
  image_bboxes = objects["bboxes-" + image_id]
  image_dims = objects["dims-" + image_id]
  positions = image_utils.quantize_bbox(
      bboxes=image_bboxes, height=image_dims[0], width=image_dims[1])
  if should_close:
    objects.close()
  return image_features, positions
Read R-CNN object data from HDF5 file.
language/capwap/utils/io_utils.py