Class SAM2
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.gui.visualization.object.tools.AbstractTool
-
- adams.gui.visualization.object.tools.AbstractToolWithParameterPanel
-
- adams.gui.visualization.object.tools.SAM2
-
- All Implemented Interfaces:
adams.core.CleanUpHandler
,adams.core.GlobalInfoSupporter
,adams.core.logging.LoggingLevelHandler
,adams.core.logging.LoggingSupporter
,adams.core.SizeOfHandler
,adams.gui.visualization.object.tools.CustomizableTool
,adams.gui.visualization.object.tools.Tool
,Serializable
public class SAM2 extends adams.gui.visualization.object.tools.AbstractToolWithParameterPanel
Uses SAN (via docker and redis) to aid human in annotating.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected SAM2Markers
m_Annotator
the internally used annotator.protected adams.gui.core.BaseComboBox<String>
m_ComboBoxModelName
the combobox for the model name.protected Color
m_MarkerColor
the marker color.protected int
m_MarkerSize
the marker size.protected int
m_MaxObjectSize
the maximum object size (width/height).protected int
m_MinObjectSize
the minimum object size (width/height).protected double
m_MinProbabilityDetection
the minimum probability for the detections.protected float
m_MinProbabilityMask
the minimum probability for the mask pixels.protected ai.djl.repository.zoo.ZooModel<ai.djl.modality.cv.translator.Sam2Translator.Sam2Input,ai.djl.modality.cv.output.DetectedObjects>
m_Model
the current model.protected String
m_ModelName
the model to use.protected adams.gui.core.BaseColorTextField
m_PanelColor
the marker color.protected List<Point>
m_Points
the points to send.protected ai.djl.inference.Predictor<ai.djl.modality.cv.translator.Sam2Translator.Sam2Input,ai.djl.modality.cv.output.DetectedObjects>
m_Predictor
the current predictor.protected adams.gui.core.NumberTextField
m_TextMarkerSize
the marker size.protected adams.gui.core.NumberTextField
m_TextMaxObjectSize
the maximum object size (width/height).protected adams.gui.core.NumberTextField
m_TextMinObjectSize
the minimum object size (width/height).protected adams.gui.core.NumberTextField
m_TextMinProbabilityDetection
the minimum detection probability.protected adams.gui.core.NumberTextField
m_TextMinProbabilityMask
the minimum mask pixel probability.protected adams.gui.core.NumberTextField
m_TextToleranceSimplification
the tolerance parameter for simplification.protected double
m_ToleranceSimplification
the tolerance for polygon simplification.-
Fields inherited from class adams.gui.visualization.object.tools.AbstractToolWithParameterPanel
m_ButtonApply, m_ButtonFavorites, m_IgnoreOptionsUpdate, m_InitialOptions, m_ParameterPanel
-
-
Constructor Summary
Constructors Constructor Description SAM2()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
activate()
Gets called to activate the tool.protected void
addOptions(adams.gui.core.ParameterPanel paramPanel)
Fills the parameter panel with the options.protected String
checkBeforeApply()
Checks the parameters before applying them.void
cleanUp()
Cleans up data structures, frees up memory.protected Cursor
createCursor()
Creates the mouse cursor to use.protected adams.gui.visualization.object.tools.ToolKeyAdapter
createKeyListener()
Creates the key listener to use.protected adams.gui.visualization.object.tools.ToolMouseAdapter
createMouseListener()
Creates the mouse listener to use.protected adams.gui.visualization.object.tools.ToolMouseMotionAdapter
createMouseMotionListener()
Creates the mouse motion listener to use.void
detect()
Gets called by the marker.protected void
doApply()
Icon
getIcon()
The icon of the tool.String
getName()
The name of the tool.List<Point>
getPoints()
Returns the points to send.String
globalInfo()
Returns a string describing the object.protected void
initialize()
Initializes the members.protected void
loadModel()
Loads the model, if necessary.void
setPoints(List<Point> value)
Sets the points to send.-
Methods inherited from class adams.gui.visualization.object.tools.AbstractToolWithParameterPanel
apply, applyOptions, applyOptionsQuietly, createOptionPanel, getCurrentOptions, getFavoritesOptions, getOption, getOptionPanel, postProcessCurrentOptions, retrieveCurrentOptions, setFavoritesOptions, setInitialOptions, setOption, showFavoritesMenu, updateOptions
-
Methods inherited from class adams.gui.visualization.object.tools.AbstractTool
createApplyButton, deactivate, getCanvas, getCursor, getImage, getKeyListener, getModifiedIcon, getMouseListener, getMouseMotionListener, getUnmodifiedIcon, getZoom, hasImage, isModified, setApplyButtonState, setCanvas, update
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Field Detail
-
m_TextMarkerSize
protected adams.gui.core.NumberTextField m_TextMarkerSize
the marker size.
-
m_PanelColor
protected adams.gui.core.BaseColorTextField m_PanelColor
the marker color.
-
m_ComboBoxModelName
protected adams.gui.core.BaseComboBox<String> m_ComboBoxModelName
the combobox for the model name.
-
m_TextMinProbabilityDetection
protected adams.gui.core.NumberTextField m_TextMinProbabilityDetection
the minimum detection probability.
-
m_TextMinProbabilityMask
protected adams.gui.core.NumberTextField m_TextMinProbabilityMask
the minimum mask pixel probability.
-
m_TextMinObjectSize
protected adams.gui.core.NumberTextField m_TextMinObjectSize
the minimum object size (width/height).
-
m_TextMaxObjectSize
protected adams.gui.core.NumberTextField m_TextMaxObjectSize
the maximum object size (width/height).
-
m_TextToleranceSimplification
protected adams.gui.core.NumberTextField m_TextToleranceSimplification
the tolerance parameter for simplification.
-
m_MarkerSize
protected int m_MarkerSize
the marker size.
-
m_MarkerColor
protected Color m_MarkerColor
the marker color.
-
m_ModelName
protected String m_ModelName
the model to use.
-
m_MinProbabilityDetection
protected double m_MinProbabilityDetection
the minimum probability for the detections.
-
m_MinProbabilityMask
protected float m_MinProbabilityMask
the minimum probability for the mask pixels.
-
m_MinObjectSize
protected int m_MinObjectSize
the minimum object size (width/height).
-
m_MaxObjectSize
protected int m_MaxObjectSize
the maximum object size (width/height).
-
m_ToleranceSimplification
protected double m_ToleranceSimplification
the tolerance for polygon simplification.
-
m_Annotator
protected SAM2Markers m_Annotator
the internally used annotator.
-
m_Model
protected transient ai.djl.repository.zoo.ZooModel<ai.djl.modality.cv.translator.Sam2Translator.Sam2Input,ai.djl.modality.cv.output.DetectedObjects> m_Model
the current model.
-
m_Predictor
protected transient ai.djl.inference.Predictor<ai.djl.modality.cv.translator.Sam2Translator.Sam2Input,ai.djl.modality.cv.output.DetectedObjects> m_Predictor
the current predictor.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Returns:
- a description suitable for displaying in the gui
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initialize
in classadams.gui.visualization.object.tools.AbstractToolWithParameterPanel
-
getName
public String getName()
The name of the tool.- Returns:
- the name
-
getIcon
public Icon getIcon()
The icon of the tool.- Returns:
- the icon
-
createCursor
protected Cursor createCursor()
Creates the mouse cursor to use.- Specified by:
createCursor
in classadams.gui.visualization.object.tools.AbstractTool
- Returns:
- the cursor
-
createMouseListener
protected adams.gui.visualization.object.tools.ToolMouseAdapter createMouseListener()
Creates the mouse listener to use.- Specified by:
createMouseListener
in classadams.gui.visualization.object.tools.AbstractTool
- Returns:
- the listener, null if not applicable
-
createMouseMotionListener
protected adams.gui.visualization.object.tools.ToolMouseMotionAdapter createMouseMotionListener()
Creates the mouse motion listener to use.- Specified by:
createMouseMotionListener
in classadams.gui.visualization.object.tools.AbstractTool
- Returns:
- the listener, null if not applicable
-
createKeyListener
protected adams.gui.visualization.object.tools.ToolKeyAdapter createKeyListener()
Creates the key listener to use.- Overrides:
createKeyListener
in classadams.gui.visualization.object.tools.AbstractTool
- Returns:
- the listener, null if not applicable
-
checkBeforeApply
protected String checkBeforeApply()
Checks the parameters before applying them.- Overrides:
checkBeforeApply
in classadams.gui.visualization.object.tools.AbstractTool
- Returns:
- null if checks passed, otherwise error message (gets displayed in GUI)
-
doApply
protected void doApply()
- Specified by:
doApply
in classadams.gui.visualization.object.tools.AbstractTool
-
addOptions
protected void addOptions(adams.gui.core.ParameterPanel paramPanel)
Fills the parameter panel with the options.- Specified by:
addOptions
in classadams.gui.visualization.object.tools.AbstractToolWithParameterPanel
- Parameters:
paramPanel
- for adding the options to
-
setPoints
public void setPoints(List<Point> value)
Sets the points to send.- Parameters:
value
- the points
-
getPoints
public List<Point> getPoints()
Returns the points to send.- Returns:
- the point, null if none set
-
activate
public void activate()
Gets called to activate the tool.- Specified by:
activate
in interfaceadams.gui.visualization.object.tools.Tool
- Overrides:
activate
in classadams.gui.visualization.object.tools.AbstractTool
-
loadModel
protected void loadModel() throws Exception
Loads the model, if necessary.- Throws:
Exception
- if model loading fails
-
detect
public void detect()
Gets called by the marker.
-
cleanUp
public void cleanUp()
Cleans up data structures, frees up memory.- Specified by:
cleanUp
in interfaceadams.core.CleanUpHandler
- Overrides:
cleanUp
in classadams.gui.visualization.object.tools.AbstractTool
-
-