模型:
在imagenet-1k上训练的万模型。它在 Visual Attention Network 论文中被介绍,并于 this repository 首次发布。
免责声明:发布Van模型的团队没有为此模型编写模型卡片,因此这个模型卡片是由Hugging Face团队撰写的。
这篇论文介绍了一种基于卷积操作的新型注意力层,能够捕捉到局部和远程关系。这是通过结合普通和大型核卷积层实现的。后者使用扩张卷积来捕捉远程相关性。
您可以使用原始模型进行图像分类。请查看 model hub 以寻找您感兴趣的任务的微调版本。
以下是如何使用此模型的方法:
>>> from transformers import AutoFeatureExtractor, VanForImageClassification
>>> import torch
>>> from datasets import load_dataset
>>> dataset = load_dataset("huggingface/cats-image")
>>> image = dataset["test"]["image"][0]
>>> feature_extractor = AutoFeatureExtractor.from_pretrained("Visual-Attention-Network/van-base")
>>> model = VanForImageClassification.from_pretrained("Visual-Attention-Network/van-base")
>>> inputs = feature_extractor(image, return_tensors="pt")
>>> with torch.no_grad():
... logits = model(**inputs).logits
>>> # model predicts one of the 1000 ImageNet classes
>>> predicted_label = logits.argmax(-1).item()
>>> print(model.config.id2label[predicted_label])
tabby, tabby cat
更多代码示例,请参阅 documentation 。