Class UrlTranslator<T>
- java.lang.Object
-
- ai.djl.modality.cv.translator.wrapper.UrlTranslator<T>
-
- Type Parameters:
T- the output object type
- All Implemented Interfaces:
PostProcessor<T>,PreProcessor<java.net.URL>,Translator<java.net.URL,T>
public class UrlTranslator<T> extends java.lang.Object implements Translator<java.net.URL,T>
Built-inTranslatorthat provides image pre-processing from URL.
-
-
Constructor Summary
Constructors Constructor Description UrlTranslator(Translator<Image,T> translator)Creates aUrlTranslatorinstance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BatchifiergetBatchifier()Gets theBatchifier.voidprepare(TranslatorContext ctx)Prepares the translator with the manager and model to use.NDListprocessInput(TranslatorContext ctx, java.net.URL input)Processes the input and converts it to NDList.TprocessOutput(TranslatorContext ctx, NDList list)Processes the output NDList to the corresponding output object.
-
-
-
Constructor Detail
-
UrlTranslator
public UrlTranslator(Translator<Image,T> translator)
Creates aUrlTranslatorinstance.- Parameters:
translator- aTranslatorthat can process image
-
-
Method Detail
-
processInput
public NDList processInput(TranslatorContext ctx, java.net.URL input) throws java.lang.Exception
Processes the input and converts it to NDList.- Specified by:
processInputin interfacePreProcessor<T>- 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
-
processOutput
public T processOutput(TranslatorContext ctx, NDList list) throws java.lang.Exception
Processes the output NDList to the corresponding output object.- Specified by:
processOutputin 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:
getBatchifierin interfaceTranslator<java.net.URL,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:
preparein interfaceTranslator<java.net.URL,T>- Parameters:
ctx- the context for thePredictor.- Throws:
java.lang.Exception- if there is an error for preparing the translator
-
-