Package ai.djl.modality.cv.translator
Class Sam2Translator
java.lang.Object
ai.djl.modality.cv.translator.Sam2Translator
- All Implemented Interfaces:
NoBatchifyTranslator<Sam2Translator.Sam2Input,,DetectedObjects> PostProcessor<DetectedObjects>,PreProcessor<Sam2Translator.Sam2Input>,Translator<Sam2Translator.Sam2Input,DetectedObjects>
public class Sam2Translator
extends Object
implements NoBatchifyTranslator<Sam2Translator.Sam2Input,DetectedObjects>
A
Translator that handles mask generation task.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA class represents the segment anything input. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprocessInput(TranslatorContext ctx, Sam2Translator.Sam2Input input) Processes the input and converts it to NDList.processOutput(TranslatorContext ctx, NDList list) Processes the output NDList to the corresponding output object.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ai.djl.translate.NoBatchifyTranslator
getBatchifierMethods inherited from interface ai.djl.translate.Translator
batchProcessInput, batchProcessOutput, getExpansions, prepare
-
Constructor Details
-
Sam2Translator
public Sam2Translator()Constructs aSam2Translatorinstance.
-
-
Method Details
-
processInput
Processes the input and converts it to NDList.- Specified by:
processInputin interfacePreProcessor<Sam2Translator.Sam2Input>- Parameters:
ctx- the toolkit for creating the input NDArrayinput- the input object- Returns:
- the
NDListafter pre-processing - Throws:
Exception- if an error occurs during processing input
-
processOutput
Processes the output NDList to the corresponding output object.- Specified by:
processOutputin interfacePostProcessor<DetectedObjects>- Parameters:
ctx- the toolkit used for post-processinglist- the output NDList after inference, usually immutable in engines like PyTorch. @see Issue 1774- Returns:
- the output object of expected type
- Throws:
Exception- if an error occurs during processing output
-