Package ai.djl.modality.cv.translator
Class SemanticSegmentationTranslator
- java.lang.Object
-
- ai.djl.modality.cv.translator.BaseImageTranslator<CategoryMask>
-
- ai.djl.modality.cv.translator.SemanticSegmentationTranslator
-
- All Implemented Interfaces:
PostProcessor<CategoryMask>
,PreProcessor<Image>
,Translator<Image,CategoryMask>
public class SemanticSegmentationTranslator extends BaseImageTranslator<CategoryMask>
ATranslator
that post-process theImage
intoCategoryMask
with output mask representing the class that each pixel in the original image belong to.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SemanticSegmentationTranslator.Builder
The builder for Semantic Segmentation translator.-
Nested classes/interfaces inherited from class ai.djl.modality.cv.translator.BaseImageTranslator
BaseImageTranslator.BaseBuilder<T extends BaseImageTranslator.BaseBuilder>, BaseImageTranslator.ClassificationBuilder<T extends BaseImageTranslator.BaseBuilder>, BaseImageTranslator.SynsetLoader
-
-
Field Summary
-
Fields inherited from class ai.djl.modality.cv.translator.BaseImageTranslator
pipeline
-
-
Constructor Summary
Constructors Constructor Description SemanticSegmentationTranslator(SemanticSegmentationTranslator.Builder builder)
Creates the Semantic Segmentation translator from the given builder.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SemanticSegmentationTranslator.Builder
builder()
Creates a builder to build aSemanticSegmentationTranslator
.static SemanticSegmentationTranslator.Builder
builder(java.util.Map<java.lang.String,?> arguments)
Creates a builder to build aSemanticSegmentationTranslator
with specified arguments.void
prepare(TranslatorContext ctx)
Prepares the translator with the manager and model to use.NDList
processInput(TranslatorContext ctx, Image image)
Processes the input and converts it to NDList.CategoryMask
processOutput(TranslatorContext ctx, NDList list)
Processes the output NDList to the corresponding output object.-
Methods inherited from class ai.djl.modality.cv.translator.BaseImageTranslator
getBatchifier
-
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.Translator
getExpansions, toBatchTranslator, toBatchTranslator
-
-
-
-
Constructor Detail
-
SemanticSegmentationTranslator
public SemanticSegmentationTranslator(SemanticSegmentationTranslator.Builder builder)
Creates the Semantic Segmentation translator from the given builder.- Parameters:
builder
- the builder for the translator
-
-
Method Detail
-
prepare
public void prepare(TranslatorContext ctx) throws java.io.IOException
Prepares the translator with the manager and model to use.- Parameters:
ctx
- the context for thePredictor
.- Throws:
java.io.IOException
-
processInput
public NDList processInput(TranslatorContext ctx, Image image)
Processes the input and converts it to NDList.- Specified by:
processInput
in interfacePreProcessor<Image>
- Overrides:
processInput
in classBaseImageTranslator<CategoryMask>
- Parameters:
ctx
- the toolkit for creating the input NDArrayimage
- the input object- Returns:
- the
NDList
after pre-processing
-
processOutput
public CategoryMask processOutput(TranslatorContext ctx, NDList list)
Processes the output NDList to the corresponding output object.- Parameters:
ctx
- the toolkit used for post-processinglist
- the output NDList after inference, usually immutable in engines like PyTorch. @see Issue 1774- Returns:
- the output object of expected type
-
builder
public static SemanticSegmentationTranslator.Builder builder()
Creates a builder to build aSemanticSegmentationTranslator
.- Returns:
- a new builder
-
builder
public static SemanticSegmentationTranslator.Builder builder(java.util.Map<java.lang.String,?> arguments)
Creates a builder to build aSemanticSegmentationTranslator
with specified arguments.- Parameters:
arguments
- arguments to specify builder options- Returns:
- a new builder
-
-