英文

ECA-NFNet-L0

ImageNet 上的预训练模型,这是 NFNet (Normalization Free) 模型系列的一种变体。

模型描述

这个模型变体是从原始的 F0 变体中精简而来,以提升在 PyTorch 上 GPU 加速器上的运行时特性(吞吐量、内存使用),它使用的是 Efficient Channel Attention (ECA) 而不是 Squeeze-Excitation。它还使用了 SiLU 激活函数而不是通常的 GELU。

像 NF 家族中的其他模型一样,这个模型不包含任何归一化层(批归一化、组归一化等)。模型使用带有额外缩放值的 Weight Standardized 卷积代替归一化层。

预期用途和限制

您可以使用原始模型对图像进行分类,其中包含 1,000 个 ImageNet 标签,但您也可以更改其头部以在下游任务上进行微调(使用不同标签的另一个分类任务,图像分割或目标检测等)。

如何使用

您可以使用 timm 中的通常工厂方法来使用此模型:

import PIL
import timm
import torch

model = timm.create_model("hf_hub:timm/eca_nfnet_l0")

config = model.default_cfg
img_size = config["test_input_size"][-1] if "test_input_size" in config else config["input_size"][-1]
transform = timm.data.transforms_factory.transforms_imagenet_eval(
    img_size=img_size,
    interpolation=config["interpolation"],
    mean=config["mean"],
    std=config["std"],
    crop_pct=config["crop_pct"],
)

img = PIL.Image.open(path_to_an_image)
img = img.convert("RGB")
input_tensor = transform(cat_img)
input_tensor = input_tensor.unsqueeze(0)
# ^ batch size = 1
with torch.no_grad():
    output = model(input_tensor)
probs = output.squeeze(0).softmax(dim=0)

限制和偏见

数据集中的训练图像通常是明确表示 1,000 个标签之一的照片。该模型可能对绘图或包含多个具有不同标签的对象的图像的推广效果不佳。数据集中的训练图像主要来自美国(45.4%)和英国(7.6%)。因此,通过对这些国家的场景进行细调(参见 this paper )的模型或模型将在这些国家的场景图像上的效果更好。更一般地说, recent research 表明,即使在 ImageNet 上以无监督方式训练模型(即不使用标签),也会体现出训练图像中的种族和性别偏见。

训练数据

这个模型在 ImageNet 上进行了预训练,该数据集由1,000个类别的 14 百万手动注释的图像组成。

训练过程

为了训练的稳定性,强烈建议在训练所有 NFNet 变体时启用梯度剪裁。该模型使用 0.015 的自适应梯度剪裁(AGC)因子进行训练,如 the paper 中所述。与论文类似,使用带有 Nesterov 的 SGD 进行余弦学习率衰减。对于训练,推荐进行适度到大幅度的数据增强( RandAugment )和正则化(dropout、随机深度)。

预处理

图像使用双三次插值进行调整大小为 288x288,并使用常规的 ImageNet 统计值进行归一化。

评估结果

该模型在 ImageNet 评估集上的 top1 准确率为 82.6%,top-5 准确率为 96.5%。

BibTeX 条目和引用信息

NFNet 模型架构:

@article{brock2021high,
  author={Andrew Brock and Soham De and Samuel L. Smith and Karen Simonyan},
  title={High-Performance Large-Scale Image Recognition Without Normalization},
  journal={arXiv preprint arXiv:2102.06171},
  year={2021}
}

L0 模型变体和预训练:

@misc{rw2019timm,
  author = {Ross Wightman},
  title = {PyTorch Image Models},
  year = {2019},
  publisher = {GitHub},
  journal = {GitHub repository},
  doi = {10.5281/zenodo.4414861},
  howpublished = {\url{https://github.com/rwightman/pytorch-image-models}}
}