Class FileTranslator<T>
- java.lang.Object
-
- ai.djl.modality.cv.translator.wrapper.FileTranslator<T>
-
- Type Parameters:
T
- the output object type
- All Implemented Interfaces:
PostProcessor<T>
,PreProcessor<java.nio.file.Path>
,Translator<java.nio.file.Path,T>
public class FileTranslator<T> extends java.lang.Object implements Translator<java.nio.file.Path,T>
Built-inTranslator
that provides image pre-processing from file path.
-
-
Constructor Summary
Constructors Constructor Description FileTranslator(Translator<Image,T> translator)
Creates aFileTranslator
instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Batchifier
getBatchifier()
Gets theBatchifier
.void
prepare(TranslatorContext ctx)
Prepares the translator with the manager and model to use.NDList
processInput(TranslatorContext ctx, java.nio.file.Path input)
Processes the input and converts it to NDList.T
processOutput(TranslatorContext ctx, NDList list)
Processes the output NDList to the corresponding output object.
-
-
-
Constructor Detail
-
FileTranslator
public FileTranslator(Translator<Image,T> translator)
Creates aFileTranslator
instance.- Parameters:
translator
- aTranslator
that can process image
-
-
Method Detail
-
processInput
public NDList processInput(TranslatorContext ctx, java.nio.file.Path input) throws java.lang.Exception
Processes the input and converts it to NDList.- Specified by:
processInput
in interfacePreProcessor<T>
- Parameters:
ctx
- the toolkit for creating the input NDArrayinput
- the input object- Returns:
- the
NDList
after pre-processing - Throws:
java.lang.Exception
- if an error occurs during processing input
-
processOutput
public T processOutput(TranslatorContext ctx, NDList list) throws java.lang.Exception
Processes the output NDList to the corresponding output object.- Specified by:
processOutput
in interfacePostProcessor<T>
- Parameters:
ctx
- the toolkit used for post-processinglist
- the output NDList after inference- Returns:
- the output object of expected type
- Throws:
java.lang.Exception
- if an error occurs during processing output
-
getBatchifier
public Batchifier getBatchifier()
Gets theBatchifier
.- Specified by:
getBatchifier
in interfaceTranslator<java.nio.file.Path,T>
- Returns:
- the
Batchifier
-
prepare
public void prepare(TranslatorContext ctx) throws java.lang.Exception
Prepares the translator with the manager and model to use.- Specified by:
prepare
in interfaceTranslator<java.nio.file.Path,T>
- Parameters:
ctx
- the context for thePredictor
.- Throws:
java.lang.Exception
- if there is an error for preparing the translator
-
-