Package ai.djl.basicdataset.cv
Class CocoUtils
java.lang.Object
ai.djl.basicdataset.cv.CocoUtils
A utility class that assists in loading and parsing the annotations in Coco.
-
Method Summary
Modifier and TypeMethodDescriptiongetAnnotationById(long annotationId) Returns anCocoMetadata.Annotationthat corresponds to a given annotation id.getAnnotationIdByImageId(long imageId) Returns all ids of the annotation that correspond to a given image id.Returns all image ids in the annotation file.getRelativeImagePath(long imageId) Returns the relative path of an image given an image id.intmapCategoryId(long originalCategoryId) Returns the continuous category id given an original category id.voidprepare()Prepares and indexes the annotation file in memory.
-
Method Details
-
prepare
Prepares and indexes the annotation file in memory.- Throws:
IOException- if reading the annotation file fails
-
getImageIds
Returns all image ids in the annotation file.- Returns:
- all image ids in the annotation file
-
getRelativeImagePath
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
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
Returns anCocoMetadata.Annotationthat 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
-