🚀 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
相關論文