Class Sam2Translator.Sam2Input

java.lang.Object
ai.djl.modality.cv.translator.Sam2Translator.Sam2Input
Enclosing class:
Sam2Translator

public static final class Sam2Translator.Sam2Input extends Object
A class represents the segment anything input.
  • Constructor Details

    • Sam2Input

      public Sam2Input(Image image, List<Point> points, List<Integer> labels)
      Constructs a Sam2Input instance.
      Parameters:
      image - the image
      points - the locations on the image
      labels - the labels for the locations (0: background, 1: foreground)
  • Method Details

    • getImage

      public Image getImage()
      Returns the image.
      Returns:
      the image
    • getPoints

      public List<Point> getPoints()
      Returns the locations.
      Returns:
      the locations
    • newInstance

      public static Sam2Translator.Sam2Input newInstance(String url, int x, int y) throws IOException
      Creates a new Sam2Input instance with the image and a location.
      Parameters:
      url - the image url
      x - the X of the location
      y - the Y of the location
      Returns:
      a new Sam2Input instance
      Throws:
      IOException - if failed to read image
    • newInstance

      public static Sam2Translator.Sam2Input newInstance(Path path, int x, int y) throws IOException
      Creates a new Sam2Input instance with the image and a location.
      Parameters:
      path - the image file path
      x - the X of the location
      y - the Y of the location
      Returns:
      a new Sam2Input instance
      Throws:
      IOException - if failed to read image