Model¶
Model Builder¶
yolo.model.builder
¶
logger = logging.getLogger('yolo')
module-attribute
¶
ModelConfig
dataclass
¶
YOLOLayer
dataclass
¶
YOLO
¶
Bases: Module
A preliminary YOLO (You Only Look Once) model class still under development.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_cfg
|
ModelConfig
|
Configuration for the YOLO model. Expected to define the layers, parameters, and any other relevant configuration details. |
required |
Source code in yolo/model/builder.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |
save_load_weights(weights)
¶
Update the model's weights with the provided weights.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
weights
|
Union[Path, OrderedDict]
|
A OrderedDict containing the new weights. |
required |
Source code in yolo/model/builder.py
prepare_weight(download_link=None, weight_path=Path('v9-c.pt'))
¶
Source code in yolo/data/preparation.py
get_layer_map()
¶
Dynamically generates a dictionary mapping class names to classes, filtering to include only those that are subclasses of nn.Module, ensuring they are relevant neural network layers.
Source code in yolo/utils/module_utils.py
create_model(model_cfg, weight_path=True, class_num=80)
¶
Constructs and returns a YOLO model from a model config.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_cfg
|
ModelConfig
|
The model configuration (architecture definition). |
required |
weight_path
|
Union[bool, Path]
|
Path to pretrained weights. |
True
|
class_num
|
int
|
Number of output classes. |
80
|
Returns:
| Name | Type | Description |
|---|---|---|
YOLO |
YOLO
|
An instance of the model defined by the given configuration. |
Source code in yolo/model/builder.py
Basic Blocks¶
yolo.model.blocks.basic
¶
Conv
¶
Bases: Module
A basic convolutional block that includes convolution, batch normalization, and activation.
Source code in yolo/model/blocks/basic.py
Pool
¶
Bases: Module
A generic pooling block supporting 'max' and 'avg' pooling methods.
Source code in yolo/model/blocks/basic.py
Concat
¶
UpSample
¶
auto_pad(kernel_size, dilation=1, **kwargs)
¶
Auto Padding for the convolution blocks
Source code in yolo/utils/module_utils.py
create_activation_function(activation)
¶
Retrieves an activation function from the PyTorch nn module based on its name, case-insensitively.
Source code in yolo/utils/module_utils.py
Backbone Blocks¶
yolo.model.blocks.backbone
¶
logger = logging.getLogger('yolo')
module-attribute
¶
Conv
¶
Bases: Module
A basic convolutional block that includes convolution, batch normalization, and activation.
Source code in yolo/model/blocks/basic.py
Pool
¶
Bases: Module
A generic pooling block supporting 'max' and 'avg' pooling methods.
Source code in yolo/model/blocks/basic.py
RepConv
¶
Bases: Module
A convolutional block that combines two convolution layers (kernel and point-wise).
Source code in yolo/model/blocks/backbone.py
Bottleneck
¶
Bases: Module
A bottleneck block with optional residual connections.
Source code in yolo/model/blocks/backbone.py
RepNCSP
¶
Bases: Module
RepNCSP block with convolutions, split, and bottleneck processing.
Source code in yolo/model/blocks/backbone.py
ELAN
¶
Bases: Module
ELAN structure.
Source code in yolo/model/blocks/backbone.py
RepNCSPELAN
¶
Bases: Module
RepNCSPELAN block combining RepNCSP blocks with ELAN structure.
Source code in yolo/model/blocks/backbone.py
AConv
¶
Bases: Module
Downsampling module combining average and max pooling with convolution for feature reduction.
Source code in yolo/model/blocks/backbone.py
ADown
¶
Bases: Module
Downsampling module combining average and max pooling with convolution for feature reduction.
Source code in yolo/model/blocks/backbone.py
create_activation_function(activation)
¶
Retrieves an activation function from the PyTorch nn module based on its name, case-insensitively.
Source code in yolo/utils/module_utils.py
Neck Blocks¶
yolo.model.blocks.neck
¶
Conv
¶
Bases: Module
A basic convolutional block that includes convolution, batch normalization, and activation.
Source code in yolo/model/blocks/basic.py
Pool
¶
Bases: Module
A generic pooling block supporting 'max' and 'avg' pooling methods.
Source code in yolo/model/blocks/basic.py
CBLinear
¶
Bases: Module
Convolutional block that outputs multiple feature maps split along the channel dimension.
Source code in yolo/model/blocks/neck.py
SPPCSPConv
¶
Bases: Module
Source code in yolo/model/blocks/neck.py
SPPELAN
¶
Bases: Module
SPPELAN module comprising multiple pooling and convolution layers.
Source code in yolo/model/blocks/neck.py
CBFuse
¶
Bases: Module
Source code in yolo/model/blocks/neck.py
auto_pad(kernel_size, dilation=1, **kwargs)
¶
Auto Padding for the convolution blocks
Source code in yolo/utils/module_utils.py
Implicit Blocks¶
yolo.model.blocks.implicit
¶
RepNCSPELAN
¶
Bases: Module
RepNCSPELAN block combining RepNCSP blocks with ELAN structure.
Source code in yolo/model/blocks/backbone.py
Conv
¶
Bases: Module
A basic convolutional block that includes convolution, batch normalization, and activation.
Source code in yolo/model/blocks/basic.py
Anchor2Vec
¶
Bases: Module
Source code in yolo/model/blocks/implicit.py
ImplicitA
¶
Bases: Module
Implement YOLOR - implicit knowledge(Add), paper: https://arxiv.org/abs/2105.04206
Source code in yolo/model/blocks/implicit.py
ImplicitM
¶
Bases: Module
Implement YOLOR - implicit knowledge(multiply), paper: https://arxiv.org/abs/2105.04206
Source code in yolo/model/blocks/implicit.py
DConv
¶
Bases: Module
Source code in yolo/model/blocks/implicit.py
RepNCSPELAND
¶
Detection Head¶
yolo.tasks.detection.head
¶
Conv
¶
Bases: Module
A basic convolutional block that includes convolution, batch normalization, and activation.
Source code in yolo/model/blocks/basic.py
Anchor2Vec
¶
Bases: Module
Source code in yolo/model/blocks/implicit.py
ImplicitA
¶
Bases: Module
Implement YOLOR - implicit knowledge(Add), paper: https://arxiv.org/abs/2105.04206
Source code in yolo/model/blocks/implicit.py
ImplicitM
¶
Bases: Module
Implement YOLOR - implicit knowledge(multiply), paper: https://arxiv.org/abs/2105.04206
Source code in yolo/model/blocks/implicit.py
Detection
¶
Bases: Module
A single YOLO Detection head for detection models
Source code in yolo/tasks/detection/head.py
IDetection
¶
Bases: Module
Source code in yolo/tasks/detection/head.py
MultiheadDetection
¶
Bases: Module
Multihead Detection module for Dual detect or Triple detect