Package ai.djl.modality.cv.translator
Class ImageServingTranslator
- java.lang.Object
-
- ai.djl.modality.cv.translator.ImageServingTranslator
-
- All Implemented Interfaces:
PostProcessor<Output>,PreProcessor<Input>,Translator<Input,Output>
public class ImageServingTranslator extends java.lang.Object implements Translator<Input,Output>
-
-
Constructor Summary
Constructors Constructor Description ImageServingTranslator(Translator<Image,?> translator)Constructs a newImageServingTranslatorinstance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BatchifiergetBatchifier()Returns theBatchifier.voidprepare(TranslatorContext ctx)Prepares the translator with the manager and model to use.NDListprocessInput(TranslatorContext ctx, Input input)Processes the input and converts it to NDList.OutputprocessOutput(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
getExpansions, toBatchTranslator, toBatchTranslator
-
-
-
-
Constructor Detail
-
ImageServingTranslator
public ImageServingTranslator(Translator<Image,?> translator)
Constructs a newImageServingTranslatorinstance.- Parameters:
translator- aTranslatorprocesses Image input
-
-
Method Detail
-
getBatchifier
public Batchifier getBatchifier()
Returns theBatchifier.- Specified by:
getBatchifierin interfaceTranslator<Input,Output>- Returns:
- the
Batchifier
-
processOutput
public Output processOutput(TranslatorContext ctx, NDList list) throws java.lang.Exception
Processes the output NDList to the corresponding output object.- Specified by:
processOutputin 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:
java.lang.Exception- if an error occurs during processing output
-
processInput
public NDList processInput(TranslatorContext ctx, Input input) throws java.lang.Exception
Processes the input and converts it to NDList.- Specified by:
processInputin interfacePreProcessor<Input>- Parameters:
ctx- the toolkit for creating the input NDArrayinput- the input object- Returns:
- the
NDListafter pre-processing - Throws:
java.lang.Exception- if an error occurs during processing input
-
prepare
public void prepare(TranslatorContext ctx) throws java.lang.Exception
Prepares the translator with the manager and model to use.- Specified by:
preparein interfaceTranslator<Input,Output>- Parameters:
ctx- the context for thePredictor.- Throws:
java.lang.Exception- if there is an error for preparing the translator
-
-