Overview
Thebackbones module provides access to a wide variety of pre-trained neural network architectures for feature extraction in PatchCore. These backbones are loaded with ImageNet pre-trained weights.
Functions
load
str
required
Name of the backbone architecture to load. See Available Backbones for the complete list.
Returns
torch.nn.Module
Pre-trained PyTorch model loaded with ImageNet weights.
Example
Available Backbones
The following pre-trained backbones are available:ResNet Family
str
ResNet-50 architecture from torchvision
str
ResNet-101 architecture from torchvision
str
ResNet-200 architecture from timm
str
ResNeXt-101 (32x8d) architecture from torchvision
str
ResNeSt-50 (4s2x40d) architecture from timm
Wide ResNet Family
str
Wide ResNet-50-2 architecture from torchvision. Recommended for PatchCore.
str
Wide ResNet-101-2 architecture from torchvision
ResNetV2 (BiT) Family
str
ResNetV2-50x3 trained with Big Transfer (BiT) on ImageNet-1k
str
ResNetV2-50x3 trained with BiT on ImageNet-21k
str
ResNetV2-101x3 trained with BiT on ImageNet-1k
str
ResNetV2-101x3 trained with BiT on ImageNet-21k
str
ResNetV2-101 standard architecture
str
ResNetV2-152x4 trained with BiT on ImageNet-1k
str
ResNetV2-152x4 trained with BiT on ImageNet-21k
str
ResNetV2-152x2 teacher model with 384x384 input resolution
VGG Family
str
VGG-11 architecture from torchvision
str
VGG-19 architecture from torchvision
str
VGG-19 with batch normalization from torchvision
AlexNet
str
AlexNet architecture from torchvision
DenseNet Family
str
DenseNet-121 architecture from timm
str
DenseNet-201 architecture from timm
EfficientNet Family
str
EfficientNet-B1 (TensorFlow weights) from timm
str
EfficientNet-B3 (TensorFlow weights) from timm
str
EfficientNet-B3a architecture from timm
str
EfficientNet-B5 (TensorFlow weights) from timm
str
EfficientNet-B7 (TensorFlow weights) from timm
str
EfficientNetV2-M (TensorFlow weights) from timm
str
EfficientNetV2-L (TensorFlow weights) from timm
MNASNet Family
str
MNASNet 1.0 architecture from timm
str
MNASNet-A1 architecture from timm
str
MNASNet-B1 architecture from timm
Vision Transformer (ViT) Family
str
Vision Transformer Small with 16x16 patches (224x224 input)
str
Vision Transformer Base with 16x16 patches (224x224 input)
str
Vision Transformer Large with 16x16 patches (224x224 input)
str
Vision Transformer Large with ResNet-50 hybrid backbone
DeiT Family
str
Data-efficient Image Transformer (DeiT) Base with 16x16 patches
str
DeiT Base with distillation token (16x16 patches)
Swin Transformer Family
str
Swin Transformer Base with 4x4 patches and 7x7 window size
str
Swin Transformer Large with 4x4 patches and 7x7 window size
Inception
str
Inception-V4 architecture from timm
BN-Inception
str
Batch Normalized Inception trained on ImageNet (requires pretrainedmodels package)
Usage with PatchCore
Recommended Backbone: The original PatchCore paper uses
wideresnet50 with features extracted from layer2 and layer3, which provides excellent performance for most industrial anomaly detection tasks.Backbone Registry
The complete mapping of backbone names to their implementations is stored in the_BACKBONES dictionary:
Dependencies
- torchvision: For ResNet, VGG, AlexNet, and Wide ResNet models
- timm: For Vision Transformers, EfficientNets, and many other architectures
- pretrainedmodels (optional): For BN-Inception
All backbones are loaded with pre-trained weights. The
pretrained=True parameter ensures that ImageNet weights are used, which is crucial for transfer learning in anomaly detection.