🚀 感知編碼器(Perception Encoder)
感知編碼器(Perception Encoder)是一種通過簡單的視覺 - 語言學習訓練的先進編碼器,用於圖像和視頻理解。它能在多種視覺任務中展現出卓越性能,為下游任務提供強大的通用特徵。
🚀 快速開始
感知編碼器(PE)是一系列大規模視覺編碼器模型,在眾多視覺任務中表現出色。通過使用強大的對比預訓練方法並在合成對齊視頻上進行微調,PE不僅在分類和檢索任務上超越了所有現有模型,還能在內部生成強大的通用特徵,以支持下游任務。
✨ 主要特性
- 先進性能:在零樣本圖像分類和檢索以及零樣本視頻分類和檢索等任務中取得了極其出色的結果。
- 多規模選擇:提供了不同規模的模型配置,包括B/16、L/14和G/14,以滿足不同的應用需求。
- 通用特徵:內部生成的強大通用特徵可有效遷移到下游任務。
📦 安裝指南
我們在 https://github.com/facebookresearch/perception_models 提供了模型加載代碼。
git clone https://github.com/facebookresearch/perception_models.git
cd perception_models
conda create --name perception_models python=3.12
conda activate perception_models
# 安裝PyTorch
pip install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 xformers --index-url https://download.pytorch.org/whl/cu124
# 我們使用torchcodec將視頻解碼為PyTorch張量
conda install ffmpeg -c conda-forge
pip install torchcodec==0.1 --index-url=https://download.pytorch.org/whl/cu124
pip install -e .
這將安裝可編輯版本的倉庫,允許您在不每次重新安裝包的情況下對代碼進行更改。
💻 使用示例
基礎用法
import torch
from PIL import Image
import core.vision_encoder.pe as pe
import core.vision_encoder.transforms as transforms
print("CLIP configs:", pe.CLIP.available_configs())
model = pe.CLIP.from_config("PE-Core-B16-224", pretrained=True)
model = model.cuda()
preprocess = transforms.get_image_transform(model.image_size)
tokenizer = transforms.get_text_tokenizer(model.context_length)
image = preprocess(Image.open("docs/assets/cat.png")).unsqueeze(0).cuda()
text = tokenizer(["a diagram", "a dog", "a cat"]).cuda()
with torch.no_grad(), torch.autocast("cuda"):
image_features, text_features, logit_scale = model(image, text)
text_probs = (logit_scale * image_features @ text_features.T).softmax(dim=-1)
print("Label probs:", text_probs)
您可以在GitHub倉庫中找到更多詳細信息。
📚 詳細文檔
模型詳情
📃 技術報告
📂 Github
感知編碼器(PE)是一種通過簡單的視覺 - 語言學習訓練的先進編碼器,用於圖像和視頻理解。它在論文 "Perception Encoder: The best visual embeddings are not at the output of the network" 中被提出。
模型開發者:Meta
模型概述:感知編碼器(PE)是一系列大規模視覺編碼器模型,在多種視覺任務中具有先進的性能。通過使用強大的對比預訓練方法並在合成對齊視頻上進行微調,PE不僅在分類和檢索任務上超越了所有現有模型,還能在內部生成強大的通用特徵,以支持下游任務。PE通過對齊調整解鎖了大規模對比預訓練向利用這些通用特徵的下游任務遷移的能力。

模型配置
PE核心目前有3種規模。PE核心G是主要的檢查點,L和B模型是從它蒸餾而來的。
規模 |
塔 |
參數 |
寬度 |
深度 |
MLP |
頭數 |
CLIP維度 |
分辨率 / 上下文長度 |
B/16 |
視覺 |
0.09B |
768 |
12 |
3072 |
12 |
1024 |
224px |
|
文本 |
0.31B |
1024 |
24 |
4096 |
16 |
1024 |
32 個標記 |
L/14 |
視覺 |
0.32B |
1024 |
24 |
4096 |
16 |
1024 |
336px |
|
文本 |
0.31B |
1024 |
24 |
4096 |
16 |
1024 |
32 個標記 |
G/14 |
視覺 |
1.88B |
1536 |
50 |
8960 |
16 |
1280 |
448px |
|
文本 |
0.47B |
1280 |
24 |
5120 |
20 |
1280 |
72 個標記 |
所有PE核心模型在視覺塔頂部使用一個具有8個頭的注意力池化塊。L和B模型另外還有一個用於全局聚合的類標記。更多詳細信息請參閱論文。
模型性能
PE核心在零樣本圖像分類和檢索以及零樣本視頻分類和檢索方面都取得了極其出色的結果。以下是其在這些領域的部分性能表現。
模型 |
檢查點 |
IN-1k |
IN-v2 |
IN-A |
ObjectNet |
COCO-T2I |
Kinetics-400 |
VTT-T2I |
B/16 224px |
PE-Core-B16-224 |
78.4 |
71.7 |
62.4 |
71.9 |
50.9 |
65.6 |
47.6 |
L/14 336px |
PE-Core-L14-336 |
83.5 |
77.9 |
89.0 |
84.7 |
57.1 |
73.4 |
50.3 |
G/14 448px |
PE-Core-G14-448 |
85.4 |
80.2 |
92.6 |
88.2 |
58.1 |
76.9 |
51.2 |
PE核心在諸如ObjectNet和ImageNet - A等“困難”基準測試中表現尤為出色。
📄 許可證
本項目採用Apache - 2.0許可證。
📖 引用
如果您發現我們的代碼對您的研究有用,請考慮引用:
@article{bolya2025PerceptionEncoder,
title={Perception Encoder: The best visual embeddings are not at the output of the network},
author={Daniel Bolya and Po-Yao Huang and Peize Sun and Jang Hyun Cho and Andrea Madotto and Chen Wei and Tengyu Ma and Jiale Zhi and Jathushan Rajasegaran and Hanoona Rasheed and Junke Wang and Marco Monteiro and Hu Xu and Shiyu Dong and Nikhila Ravi and Daniel Li and Piotr Doll{\'a}r and Christoph Feichtenhofer},
journal={arXiv},
year={2025}
}
@article{cho2025PerceptionLM,
title={PerceptionLM: Open-Access Data and Models for Detailed Visual Understanding},
author={Jang Hyun Cho and Andrea Madotto and Effrosyni Mavroudi and Triantafyllos Afouras and Tushar Nagarajan and Muhammad Maaz and Yale Song and Tengyu Ma and Shuming Hu and Hanoona Rasheed and Peize Sun and Po-Yao Huang and Daniel Bolya and Suyog Jain and Miguel Martin and Huiyu Wang and Nikhila Ravi and Shashank Jain and Temmy Stark and Shane Moon and Babak Damavandi and Vivian Lee and Andrew Westbury and Salman Khan and Philipp Kr\"{a}henb\"{u}hl and Piotr Doll{\'a}r and Lorenzo Torresani and Kristen Grauman and Christoph Feichtenhofer},
journal={arXiv},
year={2025}
}