get_net_builder
anomaly_match.utils.get_net_builder
¶
Neural network model builder and registry.
TestCNN(num_classes=2, in_channels=3)
¶
Bases: Module
Minimal CNN for fast testing. Not for production use.
Source code in anomaly_match/utils/get_net_builder.py
forward(x)
¶
Run the forward pass.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Tensor
|
Input tensor. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Classification logits. |
Source code in anomaly_match/utils/get_net_builder.py
get_net_builder(net_name, pretrained=False, in_channels=3)
¶
Create a neural network builder function for the specified architecture.
This function returns a builder function that creates a neural network with the specified architecture when called with num_classes and in_channels parameters. Uses timm (pytorch-image-models) as the backend for all EfficientNet variants.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
net_name
|
str
|
Name of the network architecture, supported values: - efficientnet-lite0 through efficientnet-lite4 - efficientnet-b0 through efficientnet-b7 - test-cnn (for testing only) |
required |
pretrained
|
bool
|
If True, loads pretrained weights. Default is False. |
False
|
in_channels
|
int
|
Number of input channels. Default is 3. |
3
|
Returns:
| Type | Description |
|---|---|
Callable
|
A function that builds the network when called with (num_classes, in_channels) |
Source code in anomaly_match/utils/get_net_builder.py
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 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | |