Package ai.djl.translate
Class ExpansionTranslatorFactory<IbaseT,ObaseT>
java.lang.Object
ai.djl.translate.ExpansionTranslatorFactory<IbaseT,ObaseT>
- Type Parameters:
IbaseT
- the input type for the base translatorObaseT
- the output type for the base translator
- All Implemented Interfaces:
TranslatorFactory
- Direct Known Subclasses:
BaseImageTranslatorFactory
public abstract class ExpansionTranslatorFactory<IbaseT,ObaseT>
extends Object
implements TranslatorFactory
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
A function from a base translator to an expanded translator. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract Translator<IbaseT,
ObaseT> buildBaseTranslator
(Model model, Map<String, ?> arguments) Builds the base translator that can be expanded.Returns the input type for the base translator.Returns the output type for the base translator.protected Map<ai.djl.util.Pair<Type,
Type>, ExpansionTranslatorFactory.TranslatorExpansion<IbaseT, ObaseT>> Returns the possible expansions of this factory.protected Map<Type,
Function<PostProcessor<ObaseT>, PostProcessor<?>>> Returns the possible expansions of this factory.protected Map<Type,
Function<PreProcessor<IbaseT>, PreProcessor<?>>> Returns the possible expansions of this factory.Returns supported input/output classes.<I,
O> Translator<I, O> Returns a new instance of theTranslator
class.ExpansionTranslatorFactory<IbaseT,
ObaseT>.ai.djl.translate.ExpansionTranslatorFactory.ExpandedTranslatorOptions withTranslator
(Translator<IbaseT, ObaseT> translator) Creates a set ofTranslatorOptions
based on the expansions of a given translator.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.TranslatorFactory
isSupported
-
Constructor Details
-
ExpansionTranslatorFactory
public ExpansionTranslatorFactory()
-
-
Method Details
-
getSupportedTypes
Returns supported input/output classes.- Specified by:
getSupportedTypes
in interfaceTranslatorFactory
- Returns:
- a set of supported input/output classes
-
newInstance
public <I,O> Translator<I,O> newInstance(Class<I> input, Class<O> output, Model model, Map<String, ?> arguments) Returns a new instance of theTranslator
class.- Specified by:
newInstance
in interfaceTranslatorFactory
- Type Parameters:
I
- the input data typeO
- the output data type- Parameters:
input
- the input classoutput
- the output classmodel
- theModel
that uses theTranslator
arguments
- the configurations for a newTranslator
instance- Returns:
- a new instance of the
Translator
class
-
withTranslator
public ExpansionTranslatorFactory<IbaseT,ObaseT>.ai.djl.translate.ExpansionTranslatorFactory.ExpandedTranslatorOptions withTranslator(Translator<IbaseT, ObaseT> translator) Creates a set ofTranslatorOptions
based on the expansions of a given translator.- Parameters:
translator
- the translator to expand- Returns:
- the
TranslatorOptions
-
buildBaseTranslator
protected abstract Translator<IbaseT,ObaseT> buildBaseTranslator(Model model, Map<String, ?> arguments) Builds the base translator that can be expanded.- Parameters:
model
- theModel
that uses theTranslator
arguments
- the configurations for a newTranslator
instance- Returns:
- a base translator that can be expanded to form the factory options
-
getBaseInputType
Returns the input type for the base translator.- Returns:
- the input type for the base translator
-
getBaseOutputType
Returns the output type for the base translator.- Returns:
- the output type for the base translator
-
getExpansions
protected Map<ai.djl.util.Pair<Type,Type>, getExpansions()ExpansionTranslatorFactory.TranslatorExpansion<IbaseT, ObaseT>> Returns the possible expansions of this factory.- Returns:
- the possible expansions of this factory
-
getPreprocessorExpansions
Returns the possible expansions of this factory.- Returns:
- the possible expansions of this factory
-
getPostprocessorExpansions
Returns the possible expansions of this factory.- Returns:
- the possible expansions of this factory
-