Package ai.djl.modality.cv.translator
Class Sam2ServingTranslator
java.lang.Object
ai.djl.modality.cv.translator.Sam2ServingTranslator
- All Implemented Interfaces:
PostProcessor<Output>
,PreProcessor<Input>
,Translator<Input,
Output>
A
Translator
that can serve SAM2 model.-
Constructor Summary
ConstructorsConstructorDescriptionSam2ServingTranslator
(Sam2Translator translator) Constructs a newSam2ServingTranslator
instance. -
Method Summary
Modifier and TypeMethodDescriptionReturns theBatchifier
.void
prepare
(TranslatorContext ctx) Prepares the translator with the manager and model to use.processInput
(TranslatorContext ctx, Input 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, wait
Methods inherited from interface ai.djl.translate.Translator
batchProcessInput, batchProcessOutput, getExpansions
-
Constructor Details
-
Sam2ServingTranslator
Constructs a newSam2ServingTranslator
instance.- Parameters:
translator
- aSam2Translator
-
-
Method Details
-
getBatchifier
Returns theBatchifier
.- Specified by:
getBatchifier
in interfaceTranslator<Input,
Output> - Returns:
- the
Batchifier
-
processOutput
Processes the output NDList to the corresponding output object.- Specified by:
processOutput
in interfacePostProcessor<Output>
- 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:
IOException
-
processInput
Processes the input and converts it to NDList.- Specified by:
processInput
in interfacePreProcessor<Input>
- Parameters:
ctx
- the toolkit for creating the input NDArrayinput
- the input object- Returns:
- the
NDList
after pre-processing - Throws:
Exception
- if an error occurs during processing input
-
prepare
Prepares the translator with the manager and model to use.- Specified by:
prepare
in interfaceTranslator<Input,
Output> - Parameters:
ctx
- the context for thePredictor
.- Throws:
Exception
- if there is an error for preparing the translator
-