模型:

snap-research/efficientformer-l1-300

英文

EfficientFormer-L1

目录

  • EfficientFormer-L1
    • 目录
    • 模型详细信息
    • 如何开始使用模型
    • 用途
      • 直接使用
      • 下游使用
      • 误用和超出范围的使用
    • 限制和偏见
    • 训练
      • 训练数据
      • 训练过程
    • 评估结果
    • 环境影响
    • 引文信息

模型详细信息

EfficientFormer-L1是EfficientFormer系列中的一个模型,由 Snap Research 开发。EfficientFormer模型旨在证明经过合理设计的Transformer模型可以在移动设备上实现极低的延迟同时保持高性能。

EfficientFormer-L1的这个检查点是在经过1000个epochs的训练之后得到的。

  • 开发者:Yanyu Li、Geng Yuan、Yang Wen、Eric Hu、Georgios Evangelidis、Sergey Tulyakov、Yanzhi Wang、Jian Ren
  • 语言:英语
  • 许可证:本模型使用apache-2.0许可证
  • 获取更多信息的资源:

如何开始使用模型

使用下面的代码来开始使用模型。

import requests
import torch
from PIL import Image

from transformers import EfficientFormerImageProcessor, EfficientFormerForImageClassificationWithTeacher

# Load a COCO image of two cats to test the model
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)

# Load preprocessor and pretrained model
model_name = "huggingface/efficientformer-l1-300"
processor = EfficientFormerImageProcessor.from_pretrained(model_name)
model = EfficientFormerForImageClassificationWithTeacher.from_pretrained(model_name)

# Preprocess input image
inputs = processor(images=image, return_tensors="pt")

# Inference
with torch.no_grad():
    outputs = model(**inputs)

# Print the top ImageNet1k class prediction 
logits = outputs.logits
scores = torch.nn.functional.softmax(logits, dim=1)
top_pred_class = torch.argmax(scores, dim=1)
print(f"Predicted class: {top_pred_class}")

用途

直接使用

该模型可用于图像分类和语义分割。在移动设备上(该模型在iPhone 12上进行了测试),CoreML检查点可以以低延迟执行这些任务。

限制和偏见

虽然EfficientFormer中的大多数设计都是通用的,例如维度一致的设计和带有CONV-BN融合的4D块,但EfficientFormer的实际速度可能因其他平台而异。例如,如果GeLU在特定硬件和编译器上的支持不好,而HardSwish在特定硬件和编译器上的实现效率很高,则可能需要相应地修改运算符。提出的基于延迟的剪枝方法简单而快速。然而,如果不考虑搜索成本并进行基于枚举的蛮力搜索,则可能会获得更好的结果。

由于该模型是在Imagenet-1K上进行训练的,EfficientFormer模型中将体现 biases embedded in that dataset 。

训练

训练数据

该模型是在ImageNet-1K上进行训练的。

有关更多信息,请参阅 data card 。

训练过程
  • 参数:12.3 M
  • GMACs:1.3
  • 训练周期:1000

在搭载NVIDIA A100和V100 GPU的集群上进行训练。

评估结果

在ImageNet 10K上的Top-1准确率为80.2%。

引文信息

@article{li2022efficientformer,
  title={EfficientFormer: Vision Transformers at MobileNet Speed},
  author={Li, Yanyu and Yuan, Geng and Wen, Yang and Hu, Eric and Evangelidis, Georgios and Tulyakov, Sergey and Wang, Yanzhi and Ren, Jian},
  journal={arXiv preprint arXiv:2206.01191},
  year={2022}
}