Package ai.djl.basicdataset.cv
Class CocoUtils
- java.lang.Object
-
- ai.djl.basicdataset.cv.CocoUtils
-
public class CocoUtils extends java.lang.ObjectA utility class that assists in loading and parsing the annotations in Coco.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CocoMetadata.AnnotationgetAnnotationById(long annotationId)Returns anCocoMetadata.Annotationthat corresponds to a given annotation id.java.util.List<java.lang.Long>getAnnotationIdByImageId(long imageId)Returns all ids of the annotation that correspond to a given image id.java.util.List<java.lang.Long>getImageIds()Returns all image ids in the annotation file.java.nio.file.PathgetRelativeImagePath(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 Detail
-
prepare
public void prepare() throws java.io.IOExceptionPrepares and indexes the annotation file in memory.- Throws:
java.io.IOException- if reading the annotation file fails
-
getImageIds
public java.util.List<java.lang.Long> getImageIds()
Returns all image ids in the annotation file.- Returns:
- all image ids in the annotation file
-
getRelativeImagePath
public java.nio.file.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 java.util.List<java.lang.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 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
-
-