Package ai.djl.translate
Interface TranslatorFactory
-
- All Known Implementing Classes:
BaseImageTranslatorFactory,BigGANTranslatorFactory,DefaultTranslatorFactory,DeferredTranslatorFactory,ExpansionTranslatorFactory,ImageClassificationTranslatorFactory,ImageFeatureExtractorFactory,InstanceSegmentationTranslatorFactory,NoopServingTranslatorFactory,ObjectDetectionTranslatorFactory,SemanticSegmentationTranslatorFactory,ServingTranslatorFactory,SimplePoseTranslatorFactory,SingleShotDetectionTranslatorFactory,SpeechRecognitionTranslatorFactory,StyleTransferTranslatorFactory,YoloTranslatorFactory,YoloV5TranslatorFactory,YoloV8TranslatorFactory
public interface TranslatorFactoryA utility class createsTranslatorinstances.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.util.Set<ai.djl.util.Pair<java.lang.reflect.Type,java.lang.reflect.Type>>getSupportedTypes()Returns supported input/output classes.default booleanisSupported(java.lang.Class<?> input, java.lang.Class<?> output)Returns if the input/output is supported by theTranslatorFactory.<I,O>
Translator<I,O>newInstance(java.lang.Class<I> input, java.lang.Class<O> output, Model model, java.util.Map<java.lang.String,?> arguments)Returns a new instance of theTranslatorclass.
-
-
-
Method Detail
-
getSupportedTypes
java.util.Set<ai.djl.util.Pair<java.lang.reflect.Type,java.lang.reflect.Type>> getSupportedTypes()
Returns supported input/output classes.- Returns:
- a set of supported input/output classes
-
isSupported
default boolean isSupported(java.lang.Class<?> input, java.lang.Class<?> output)Returns if the input/output is supported by theTranslatorFactory.- Parameters:
input- the input classoutput- the output class- Returns:
trueif the input/output type is supported
-
newInstance
<I,O> Translator<I,O> newInstance(java.lang.Class<I> input, java.lang.Class<O> output, Model model, java.util.Map<java.lang.String,?> arguments) throws TranslateException
Returns a new instance of theTranslatorclass.- 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
-
-