Package ai.djl.translate
Class DeferredTranslatorFactory
java.lang.Object
ai.djl.translate.DeferredTranslatorFactory
- All Implemented Interfaces:
TranslatorFactory
A
TranslatorFactory that creates the Translator based on serving.properties file.
The Criteria API cannot access serving.properties files before it's downloaded. A
DeferredTranslatorFactory assumes serving.properties will provide proper Translator. If no translatorFactory is provided in serving.properties, a TranslateException will be thrown.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns supported input/output classes.booleanisSupported(Class<?> input, Class<?> output) Returns if the input/output is supported by theTranslatorFactory.<I,O> Translator<I, O> Returns a new instance of theTranslatorclass.
-
Constructor Details
-
DeferredTranslatorFactory
public DeferredTranslatorFactory()
-
-
Method Details
-
getSupportedTypes
Returns supported input/output classes.- Specified by:
getSupportedTypesin interfaceTranslatorFactory- Returns:
- a set of supported input/output classes
-
isSupported
Returns if the input/output is supported by theTranslatorFactory.- Specified by:
isSupportedin interfaceTranslatorFactory- Parameters:
input- the input classoutput- the output class- Returns:
trueif the input/output type is supported
-
newInstance
public <I,O> Translator<I,O> newInstance(Class<I> input, Class<O> output, Model model, Map<String, ?> arguments) throws TranslateExceptionReturns a new instance of theTranslatorclass.- Specified by:
newInstancein interfaceTranslatorFactory- Type Parameters:
I- the input data typeO- the output data type- Parameters:
input- the input classoutput- the output classmodel- theModelthat uses theTranslatorarguments- the configurations for a newTranslatorinstance- Returns:
- a new instance of the
Translatorclass - Throws:
TranslateException- if failed to create Translator instance
-