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, Point[] points, int[] 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)
    • Sam2Input

      public Sam2Input(Image image, Point[] points, int[] labels, boolean visualize)
      Constructs a Sam2Input instance.
      Parameters:
      image - the image
      points - the locations on the image
      labels - the labels for the locations (0: background, 1: foreground)
      visualize - true if output visualized image
  • Method Details

    • getImage

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

      public boolean isVisualize()
      Returns true if output visualized image.
      Returns:
      true if output visualized image
    • getPoints

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

      public List<Rectangle> getBoxes()
      Returns the box.
      Returns:
      the box
    • fromJson

      public static Sam2Translator.Sam2Input fromJson(String input) throws IOException
      Constructs a Sam2Input instance from json string.
      Parameters:
      input - the json input
      Returns:
      a Sam2Input instance
      Throws:
      IOException - if failed to load the image
    • builder

      public static Sam2Translator.Sam2Input.Builder builder(Image image)
      Creates a builder to build a Sam2Input with the image.
      Parameters:
      image - the image
      Returns:
      a new builder