🚀 AM - RADIO:将所有领域归为一体
AM - RADIO 是一种创新的模型,它能够将多个领域的信息进行整合,为计算机视觉任务提供更强大的支持,在图像理解等方面具有重要价值。
🚀 快速开始
HuggingFace Hub
你可以从 Python 脚本中拉取模型:
import torch
from PIL import Image
from transformers import AutoModel, CLIPImageProcessor
hf_repo = "nvidia/RADIO-L"
image_processor = CLIPImageProcessor.from_pretrained(hf_repo)
model = AutoModel.from_pretrained(hf_repo, trust_remote_code=True)
model.eval().cuda()
image = Image.open('./assets/radio.png').convert('RGB')
pixel_values = image_processor(images=image, return_tensors='pt', do_resize=True).pixel_values
pixel_values = pixel_values.cuda()
summary, features = model(pixel_values)
💻 使用示例
基础用法
RADIO 将返回一个包含两个张量的元组。summary
类似于 ViT 中的 cls_token
,用于表示整个图像的一般概念。它的形状为 $(B,C)$,其中 $B$ 是批量维度,$C$ 是通道数。spatial_features
表示更局部的内容,适用于密集任务(如语义分割)或集成到 LLM 中。它的形状为 $(B,T,D)$,其中 $T$ 是扁平化的空间令牌,$D$ 是空间特征的通道数。请注意,一般情况下 $C \neq D$。
import torch
from PIL import Image
from transformers import AutoModel, CLIPImageProcessor
hf_repo = "nvidia/RADIO-L"
image_processor = CLIPImageProcessor.from_pretrained(hf_repo)
model = AutoModel.from_pretrained(hf_repo, trust_remote_code=True)
model.eval().cuda()
image = Image.open('./assets/radio.png').convert('RGB')
pixel_values = image_processor(images=image, return_tensors='pt', do_resize=True).pixel_values
pixel_values = pixel_values.cuda()
summary, features = model(pixel_values)
高级用法
将其转换为空间张量格式可以使用模型的下采样大小,并结合输入张量的形状。对于 'radio_v1',补丁大小为 14。
from einops import rearrange
spatial_features = rearrange(spatial_features, 'b (h w) d -> b d h w', h=x.shape[-2] // patch_size, w=x.shape[-1] // patch_size)
得到的张量将具有 $(B,D,H,W)$ 的形状,这在计算机视觉模型中很常见。
📚 详细文档
RADIOv2.5 说明
请参阅 RADIOv2.5 技术报告。
📄 许可证
RADIO 的代码和权重根据 NSCLv1 许可证 发布。
📚 引用信息
如果你发现这个仓库很有用,请考虑给它加星并引用:
@InProceedings{Ranzinger_2024_CVPR,
author = {Ranzinger, Mike and Heinrich, Greg and Kautz, Jan and Molchanov, Pavlo},
title = {AM-RADIO: Agglomerative Vision Foundation Model Reduce All Domains Into One},
booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
month = {June},
year = {2024},
pages = {12490-12500}
}
@misc{ranzinger2024phisdistributionbalancinglabelfree,
title={PHI-S: Distribution Balancing for Label-Free Multi-Teacher Distillation},
author={Mike Ranzinger and Jon Barker and Greg Heinrich and Pavlo Molchanov and Bryan Catanzaro and Andrew Tao},
year={2024},
eprint={2410.01680},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/2410.01680},
}
作者信息
- Mike Ranzinger
- Greg Heinrich
- Jan Kautz
- Pavlo Molchanov
研究机构
NVIDIA Research
相关论文