
focalnet (image classification)
Image classification544 ops27.7M params
13 models, image classification. Fewest parameters first.
FocalNets, focal modulation networks, are vision backbones in which self-attention is completely replaced by a focal modulation mechanism for modeling how tokens interact. Focal modulation has three parts: hierarchical contextualization through a stack of depth-wise convolutions that encode context from short to long range, and gated aggregation that gathers context for each query token based on its content. The aggregated context is then injected into the query by an element-wise modulation or affine transformation.
Depth-wise convolution was chosen for the contextualization because, compared to pooling, it is learnable and structure-aware, and compared to regular convolution it is channel-wise and much cheaper. To capture whole-image context, which may be high-resolution, a global average pooling is applied on the last level's feature map. A FocalNet is specified by the number of focal levels L and the kernel size at each level; kernel sizes grow by 2 from one level to the next. To match the complexity of Swin and Focal Transformers, each of the four layouts comes in a small receptive field (SRF) version with 2 focal levels and a large receptive field (LRF) version with 3. Patch embedding uses non-overlapping convolutions: 4x4 with stride 4 at the start and 2x2 with stride 2 between stages.
Tiny and base FocalNets reach 82.3% and 83.9% top-1 on ImageNet-1K; pretrained on ImageNet-22K at 224 resolution they reach 86.5% and 87.3% when fine-tuned at 224 and 384. With Mask R-CNN, FocalNet base trained on a 1x schedule beats its Swin counterpart by 2.1 points and already surpasses Swin trained 3x (49.0 vs 48.5). Using huge FocalNet and DINO, the authors report 64.3 and 64.4 mAP on COCO minival and test-dev. The timm port is fully convolutional with an NCHW tensor layout throughout, which its author found had minimal performance impact but more flexibility. It also drops input size constraints and supports feature extraction via features_only=True.
AI-written summary; not reviewed by a person. Corrections welcome.
Paper: Focal Modulation Networks

Image classification544 ops27.7M params

Image classification553 ops28.4M params

Image classification613 ops28.6M params

Image classification1,081 ops49.9M params

Image classification1,201 ops50.3M params

Image classification1,081 ops88.1M params

Image classification1,201 ops88.7M params

Image classification1,249 ops239.1M params

Image classification1,369 ops239.3M params

Image classification1,249 ops408.8M params

Image classification1,369 ops409M params

Image classification1,417 ops686.5M params

Image classification1,297 ops745.3M params