Skip to content

Res2Net

The Res2Net model is based on the "Res2Net: A New Multi-scale Backbone Architecture" paper.

Architecture overview

This paper replaces the bottleneck block of ResNet architectures by a multi-scale version.

Res2Net architecture

The key takeaways from the paper are the following:

  • switch to efficient multi-scale convolutions using a cascade of conv 3x3
  • adapt the block for cardinality & SE blocks

Model builders

The following model builders can be used to instantiate a Res2Net model, with or without pre-trained weights. All the model builders internally rely on the ResNet base class.

res2net50_26w_4s

res2net50_26w_4s(pretrained: bool = False, checkpoint: Checkpoint | None = None, progress: bool = True, **kwargs: Any) -> ResNet

Res2Net-50 26wx4s from "Res2Net: A New Multi-scale Backbone Architecture"

PARAMETER DESCRIPTION
pretrained

If True, returns a model pre-trained on ImageNet

TYPE: bool DEFAULT: False

checkpoint

If specified, the model's parameters will be set to the checkpoint's values

TYPE: Checkpoint | None DEFAULT: None

progress

If True, displays a progress bar of the download to stderr

TYPE: bool DEFAULT: True

kwargs

keyword args of ResNet

TYPE: Any DEFAULT: {}

RETURNS DESCRIPTION
ResNet

classification model

Res2Net50_26w_4s_Checkpoint

Bases: Enum

IMAGENETTE class-attribute instance-attribute
IMAGENETTE = _checkpoint(arch='res2net50_26w_4s', url='https://github.com/frgfm/Holocron/releases/download/v0.2.1/res2net50_26w_4s_224-345170e8.pth', acc1=0.9394, acc5=0.9941, sha256='345170e8ff75d10330af55674090b0d9aa751e14b6f3b4a95bb8ea6cdd65be4b', size=95020747, num_params=23670610, commit='6e32c5b578711a2ef3731a8f8c61760ed9f03e58', train_args='./imagenette2-320/ --arch res2net50_26w_4s --batch-size 64 --mixup-alpha 0.2 --amp --device 0 --epochs 100 --lr 1e-3 --label-smoothing 0.1 --random-erase 0.1 --train-crop-size 176 --val-resize-size 232 --opt adamw --weight-decay 5e-2')
DEFAULT class-attribute instance-attribute
DEFAULT = IMAGENETTE
Source code in holocron/models/classification/res2net.py
def res2net50_26w_4s(
    pretrained: bool = False,
    checkpoint: Checkpoint | None = None,
    progress: bool = True,
    **kwargs: Any,
) -> ResNet:
    """Res2Net-50 26wx4s from
    ["Res2Net: A New Multi-scale Backbone Architecture"](https://arxiv.org/pdf/1904.01169.pdf)

    Args:
        pretrained: If True, returns a model pre-trained on ImageNet
        checkpoint: If specified, the model's parameters will be set to the checkpoint's values
        progress: If True, displays a progress bar of the download to stderr
        kwargs: keyword args of [`ResNet`][holocron.models.classification.resnet.ResNet]

    Returns:
        classification model

    ::: holocron.models.Res2Net50_26w_4s_Checkpoint
        options:
            heading_level: 4
            show_if_no_docstring: true
    """
    checkpoint = _handle_legacy_pretrained(
        pretrained,
        checkpoint,
        Res2Net50_26w_4s_Checkpoint.DEFAULT.value,
    )
    return _res2net(checkpoint, progress, [3, 4, 6, 3], [64, 128, 256, 512], 26, 4, **kwargs)