Class CocoUtils

java.lang.Object
ai.djl.basicdataset.cv.CocoUtils

public class CocoUtils extends Object
A utility class that assists in loading and parsing the annotations in Coco.
  • Method Details

    • prepare

      public void prepare() throws IOException
      Prepares and indexes the annotation file in memory.
      Throws:
      IOException - if reading the annotation file fails
    • getImageIds

      public List<Long> getImageIds()
      Returns all image ids in the annotation file.
      Returns:
      all image ids in the annotation file
    • getRelativeImagePath

      public Path getRelativeImagePath(long imageId)
      Returns the relative path of an image given an image id.
      Parameters:
      imageId - the image id to retrieve the path for
      Returns:
      the relative path of an image
    • getAnnotationIdByImageId

      public List<Long> getAnnotationIdByImageId(long imageId)
      Returns all ids of the annotation that correspond to a given image id.
      Parameters:
      imageId - the image id to retrieve annotations for
      Returns:
      all ids of the annotation
    • getAnnotationById

      public CocoMetadata.Annotation getAnnotationById(long annotationId)
      Returns an CocoMetadata.Annotation that corresponds to a given annotation id.
      Parameters:
      annotationId - the annotation id to retrieve an annotation for
      Returns:
      an CocoMetadata.Annotation
    • mapCategoryId

      public int mapCategoryId(long originalCategoryId)
      Returns the continuous category id given an original category id.
      Parameters:
      originalCategoryId - the original category id to retrieve the continuous category id for
      Returns:
      the continuous category id