🚀 vit_intern300m_patch14_448.ogvl_dist模型卡片
这是一个InternViT图像特征模型。由论文作者使用多种图像 - 文本数据,从InternViT - 6B进行蒸馏预训练得到。模型权重已从OpenGVLab/InternViT - 300M - 448px的原始格式转换为timm
的vit格式。注意:此vit在特征/头部之前没有最终归一化层。
🚀 快速开始
本模型可用于图像分类、特征图提取和图像嵌入等任务,具体使用方法见下方“💻 使用示例”部分。
✨ 主要特性
- 基于InternViT架构,能有效提取图像特征。
- 使用多种图像 - 文本数据进行蒸馏预训练,具有良好的泛化能力。
📦 安装指南
文档未提及安装步骤,故跳过此章节。
💻 使用示例
基础用法
图像分类
from urllib.request import urlopen
from PIL import Image
import timm
img = Image.open(urlopen(
'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png'
))
model = timm.create_model('vit_intern300m_patch14_448.ogvl_dist', pretrained=True)
model = model.eval()
data_config = timm.data.resolve_model_data_config(model)
transforms = timm.data.create_transform(**data_config, is_training=False)
output = model(transforms(img).unsqueeze(0))
top5_probabilities, top5_class_indices = torch.topk(output.softmax(dim=1) * 100, k=5)
高级用法
特征图提取
from urllib.request import urlopen
from PIL import Image
import timm
img = Image.open(urlopen(
'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png'
))
model = timm.create_model(
'vit_intern300m_patch14_448.ogvl_dist',
pretrained=True,
features_only=True,
)
model = model.eval()
data_config = timm.data.resolve_model_data_config(model)
transforms = timm.data.create_transform(**data_config, is_training=False)
output = model(transforms(img).unsqueeze(0))
for o in output:
print(o.shape)
图像嵌入
from urllib.request import urlopen
from PIL import Image
import timm
img = Image.open(urlopen(
'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png'
))
model = timm.create_model(
'vit_intern300m_patch14_448.ogvl_dist',
pretrained=True,
num_classes=0,
)
model = model.eval()
data_config = timm.data.resolve_model_data_config(model)
transforms = timm.data.create_transform(**data_config, is_training=False)
output = model(transforms(img).unsqueeze(0))
output = model.forward_features(transforms(img).unsqueeze(0))
output = model.forward_head(output, pre_logits=True)
📚 详细文档
模型详情
属性 |
详情 |
模型类型 |
图像分类 / 特征主干网络 |
模型统计信息 |
参数(M):304.0 GMACs:362.0 激活值(M):656.4 图像尺寸:448 x 448 |
相关论文 |
InternVL2: Better than the Best: https://internvl.github.io/blog/2024-07-02-InternVL-2.0/ InternVL: Scaling up Vision Foundation Models and Aligning for Generic Visual-Linguistic Tasks: https://arxiv.org/abs/2312.14238 |
原始代码库 |
https://github.com/OpenGVLab/InternVL |
训练数据集 |
LAION - en LAION - zh COYO GRIT COCO TextCaps Objects365 OpenImages All - Seeing Wukong - OCR LaionCOCO - OCR other - OCR |
引用信息
@article{chen2023internvl,
title={InternVL: Scaling up Vision Foundation Models and Aligning for Generic Visual-Linguistic Tasks},
author={Chen, Zhe and Wu, Jiannan and Wang, Wenhai and Su, Weijie and Chen, Guo and Xing, Sen and Zhong, Muyan and Zhang, Qinglong and Zhu, Xizhou and Lu, Lewei and Li, Bin and Luo, Ping and Lu, Tong and Qiao, Yu and Dai, Jifeng},
journal={arXiv preprint arXiv:2312.14238},
year={2023}
}
🔧 技术细节
文档未提供具体技术实现细节,故跳过此章节。
📄 许可证
本模型使用MIT许可证。