Class YOLOV3
- java.lang.Object
-
- ai.djl.nn.AbstractBaseBlock
-
- ai.djl.nn.AbstractBlock
-
- ai.djl.basicmodelzoo.cv.object_detection.yolo.YOLOV3
-
- All Implemented Interfaces:
ai.djl.nn.Block
public final class YOLOV3 extends ai.djl.nn.AbstractBlock
YOLOV3
contains a generic implementation of yolov3 (Original author bubbliiiing).Yolov3 is a fast and accurate model for ObjectDetection tasks.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
YOLOV3.Builder
The Builder to construct aYOLOV3
object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ai.djl.nn.Block
basicBlock(int filters, float batchNormMomentum, float leakyAlpha)
Builds aBlock
that a basic residual block unit used in DarkNet53.static YOLOV3.Builder
builder()
Creates a builder to build aYOLOV3
.static ai.djl.nn.Block
convolutionBlock(int filters, int kernel, float batchNormMomentum, float leakyAlpha)
Builds aBlock
that represents a conv-bn-leakyRelu unit for darkNet53.protected ai.djl.ndarray.NDList
forwardInternal(ai.djl.training.ParameterStore parameterStore, ai.djl.ndarray.NDList inputs, boolean training, ai.djl.util.PairList<java.lang.String,java.lang.Object> params)
ai.djl.ndarray.types.Shape[]
getOutputShapes(ai.djl.ndarray.types.Shape[] inputShapes)
void
initializeChildBlocks(ai.djl.ndarray.NDManager manager, ai.djl.ndarray.types.DataType dataType, ai.djl.ndarray.types.Shape... inputShapes)
static ai.djl.nn.Block
makeLastLayers(int filtersIn, int filtersOut, float batchNormMomentum, float leakyAlpha)
Builds aBlock
that represents the feature head in yolov3.static ai.djl.nn.Block
makeLayer(int filters, int repeats, float batchNormMomentum, float leakyAlpha)
Creates repeated Residual Blocks used in DarkNet53.static ai.djl.nn.Block
makeOutputLayers(int filtersOut, int outClass, float batchNormMomentum, float leakyAlpha)
Builds aBlock
that represents the output layer of yolov3.static ai.djl.nn.Block
upSampleBlockNearest()
Builds aBlock
that represents an upSampleLayer(the nearest mode) for yolov3.-
Methods inherited from class ai.djl.nn.AbstractBlock
addChildBlock, addChildBlock, addChildBlockSingleton, addParameter, getChildren, getDirectParameters
-
Methods inherited from class ai.djl.nn.AbstractBaseBlock
beforeInitialize, cast, clear, describeInput, forward, forward, forwardInternal, getInputShapes, getOutputDataTypes, getParameters, initialize, isInitialized, loadMetadata, loadParameters, prepare, readInputShapes, saveInputShapes, saveMetadata, saveParameters, setInitializer, setInitializer, setInitializer, toString
-
-
-
-
Method Detail
-
upSampleBlockNearest
public static ai.djl.nn.Block upSampleBlockNearest()
Builds aBlock
that represents an upSampleLayer(the nearest mode) for yolov3.- Returns:
- a
Block
that represent an upSampleLayer for yolov3
-
convolutionBlock
public static ai.djl.nn.Block convolutionBlock(int filters, int kernel, float batchNormMomentum, float leakyAlpha)
Builds aBlock
that represents a conv-bn-leakyRelu unit for darkNet53.- Parameters:
filters
- the number of filters for convkernel
- the kernel size for convbatchNormMomentum
- the momentum for batchNorm layerleakyAlpha
- the alpha for leakyRelu activation- Returns:
- a
Block
that represents a conv-bn-leakyRelu unit for darkNet53
-
makeLastLayers
public static ai.djl.nn.Block makeLastLayers(int filtersIn, int filtersOut, float batchNormMomentum, float leakyAlpha)
Builds aBlock
that represents the feature head in yolov3.- Parameters:
filtersIn
- the number of input filtersfiltersOut
- the number of output filtersbatchNormMomentum
- the momentum of batchNorm layerleakyAlpha
- the alpha value for leakyRelu activation- Returns:
- a
Block
that represents the feature head in yolov3.
-
makeOutputLayers
public static ai.djl.nn.Block makeOutputLayers(int filtersOut, int outClass, float batchNormMomentum, float leakyAlpha)
Builds aBlock
that represents the output layer of yolov3.- Parameters:
filtersOut
- the number of output filtersoutClass
- the number of output classesbatchNormMomentum
- the momentum for batchNorm layerleakyAlpha
- the alpha for leakyRelu activation- Returns:
- a
Block
that represents the output layer of yolov3.
-
forwardInternal
protected ai.djl.ndarray.NDList forwardInternal(ai.djl.training.ParameterStore parameterStore, ai.djl.ndarray.NDList inputs, boolean training, ai.djl.util.PairList<java.lang.String,java.lang.Object> params)
- Specified by:
forwardInternal
in classai.djl.nn.AbstractBaseBlock
-
getOutputShapes
public ai.djl.ndarray.types.Shape[] getOutputShapes(ai.djl.ndarray.types.Shape[] inputShapes)
-
initializeChildBlocks
public void initializeChildBlocks(ai.djl.ndarray.NDManager manager, ai.djl.ndarray.types.DataType dataType, ai.djl.ndarray.types.Shape... inputShapes)
- Overrides:
initializeChildBlocks
in classai.djl.nn.AbstractBaseBlock
-
basicBlock
public static ai.djl.nn.Block basicBlock(int filters, float batchNormMomentum, float leakyAlpha)
Builds aBlock
that a basic residual block unit used in DarkNet53.- Parameters:
filters
- the output filter of the Convolutional LayerbatchNormMomentum
- the momentum used for computing batchNormleakyAlpha
- the alpha used in LeakyRelu Function- Returns:
- a basic residual block unit used in DarkNet53
-
makeLayer
public static ai.djl.nn.Block makeLayer(int filters, int repeats, float batchNormMomentum, float leakyAlpha)
Creates repeated Residual Blocks used in DarkNet53.- Parameters:
filters
- the output filters of the final Convolutional Layerrepeats
- the repeat times of a residual unitbatchNormMomentum
- the momentum used for computing batchNormleakyAlpha
- the alpha used in LeakyRelu Function- Returns:
- several repeats of a residual block
-
builder
public static YOLOV3.Builder builder()
Creates a builder to build aYOLOV3
.- Returns:
- a new builder
-
-