Package ai.djl.modality.cv.translator
Class YoloV5Translator
- java.lang.Object
-
- ai.djl.modality.cv.translator.BaseImageTranslator<DetectedObjects>
-
- ai.djl.modality.cv.translator.ObjectDetectionTranslator
-
- ai.djl.modality.cv.translator.YoloV5Translator
-
- All Implemented Interfaces:
PostProcessor<DetectedObjects>
,PreProcessor<Image>
,Translator<Image,DetectedObjects>
- Direct Known Subclasses:
YoloV8Translator
public class YoloV5Translator extends ObjectDetectionTranslator
A translator for YoloV5 models. This was tested with ONNX exported Yolo models. For details check here: https://github.com/ultralytics/yolov5
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
YoloV5Translator.Builder
The builder forYoloV5Translator
.protected static class
YoloV5Translator.IntermediateResult
static class
YoloV5Translator.YoloOutputType
A enum represents the Yolo output type.-
Nested classes/interfaces inherited from class ai.djl.modality.cv.translator.ObjectDetectionTranslator
ObjectDetectionTranslator.ObjectDetectionBuilder<T extends ObjectDetectionTranslator.ObjectDetectionBuilder>
-
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.ObjectDetectionTranslator
applyRatio, classes, imageHeight, imageWidth, threshold
-
Fields inherited from class ai.djl.modality.cv.translator.BaseImageTranslator
pipeline
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
YoloV5Translator(YoloV5Translator.Builder builder)
Constructs an ImageTranslator with the provided builder.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected double
boxIntersection(Rectangle a, Rectangle b)
protected double
boxIou(Rectangle a, Rectangle b)
protected double
boxUnion(Rectangle a, Rectangle b)
static YoloV5Translator.Builder
builder()
Creates a builder to build aYoloV5Translator
.static YoloV5Translator.Builder
builder(java.util.Map<java.lang.String,?> arguments)
Creates a builder to build aYoloV5Translator
with specified arguments.protected DetectedObjects
nms(java.util.List<YoloV5Translator.IntermediateResult> list)
protected double
overlap(double x1, double w1, double x2, double w2)
protected DetectedObjects
processFromBoxOutput(NDList list)
DetectedObjects
processOutput(TranslatorContext ctx, NDList list)
Processes the output NDList to the corresponding output object.-
Methods inherited from class ai.djl.modality.cv.translator.ObjectDetectionTranslator
prepare
-
Methods inherited from class ai.djl.modality.cv.translator.BaseImageTranslator
getBatchifier, processInput
-
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
-
YoloV5Translator
protected YoloV5Translator(YoloV5Translator.Builder builder)
Constructs an ImageTranslator with the provided builder.- Parameters:
builder
- the data to build with
-
-
Method Detail
-
builder
public static YoloV5Translator.Builder builder()
Creates a builder to build aYoloV5Translator
.- Returns:
- a new builder
-
builder
public static YoloV5Translator.Builder builder(java.util.Map<java.lang.String,?> arguments)
Creates a builder to build aYoloV5Translator
with specified arguments.- Parameters:
arguments
- arguments to specify builder options- Returns:
- a new builder
-
nms
protected DetectedObjects nms(java.util.List<YoloV5Translator.IntermediateResult> list)
-
overlap
protected double overlap(double x1, double w1, double x2, double w2)
-
processFromBoxOutput
protected DetectedObjects processFromBoxOutput(NDList list)
-
processOutput
public DetectedObjects 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
-
-