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 -
Field Summary
Fields inherited from class ai.djl.nn.AbstractBlock
children, parametersFields inherited from class ai.djl.nn.AbstractBaseBlock
inputNames, inputShapes, outputDataTypes, version -
Method Summary
Modifier and TypeMethodDescriptionstatic ai.djl.nn.BlockbasicBlock(int filters, float batchNormMomentum, float leakyAlpha) Builds aBlockthat a basic residual block unit used in DarkNet53.static YOLOV3.Builderbuilder()Creates a builder to build aYOLOV3.static ai.djl.nn.BlockconvolutionBlock(int filters, int kernel, float batchNormMomentum, float leakyAlpha) Builds aBlockthat represents a conv-bn-leakyRelu unit for darkNet53.protected ai.djl.ndarray.NDListforwardInternal(ai.djl.training.ParameterStore parameterStore, ai.djl.ndarray.NDList inputs, boolean training, ai.djl.util.PairList<String, Object> params) ai.djl.ndarray.types.Shape[]getOutputShapes(ai.djl.ndarray.types.Shape[] inputShapes) voidinitializeChildBlocks(ai.djl.ndarray.NDManager manager, ai.djl.ndarray.types.DataType dataType, ai.djl.ndarray.types.Shape... inputShapes) static ai.djl.nn.BlockmakeLastLayers(int filtersIn, int filtersOut, float batchNormMomentum, float leakyAlpha) Builds aBlockthat represents the feature head in yolov3.static ai.djl.nn.BlockmakeLayer(int filters, int repeats, float batchNormMomentum, float leakyAlpha) Creates repeated Residual Blocks used in DarkNet53.static ai.djl.nn.BlockmakeOutputLayers(int filtersOut, int outClass, float batchNormMomentum, float leakyAlpha) Builds aBlockthat represents the output layer of yolov3.static ai.djl.nn.BlockBuilds aBlockthat represents an upSampleLayer(the nearest mode) for yolov3.Methods inherited from class ai.djl.nn.AbstractBlock
addChildBlock, addChildBlock, addChildBlockSingleton, addParameter, getChildren, getDirectParametersMethods 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, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ai.djl.nn.Block
forward, freezeParameters, freezeParameters, getOutputShapes
-
Method Details
-
upSampleBlockNearest
public static ai.djl.nn.Block upSampleBlockNearest()Builds aBlockthat represents an upSampleLayer(the nearest mode) for yolov3.- Returns:
- a
Blockthat represent an upSampleLayer for yolov3
-
convolutionBlock
public static ai.djl.nn.Block convolutionBlock(int filters, int kernel, float batchNormMomentum, float leakyAlpha) Builds aBlockthat 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
Blockthat 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 aBlockthat 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
Blockthat represents the feature head in yolov3.
-
makeOutputLayers
public static ai.djl.nn.Block makeOutputLayers(int filtersOut, int outClass, float batchNormMomentum, float leakyAlpha) Builds aBlockthat 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
Blockthat 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<String, Object> params) - Specified by:
forwardInternalin 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:
initializeChildBlocksin classai.djl.nn.AbstractBaseBlock
-
basicBlock
public static ai.djl.nn.Block basicBlock(int filters, float batchNormMomentum, float leakyAlpha) Builds aBlockthat 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
Creates a builder to build aYOLOV3.- Returns:
- a new builder
-