🚀 I-JEPA模型(Huge,在IN1K上微调)
I-JEPA 是一种用于自监督学习的方法。总体而言,I-JEPA 从同一图像其他部分的表示中预测该图像某一部分的表示:
- 不依赖于针对手工数据变换预先指定的不变性,这种不变性往往会对特定的下游任务产生偏差;
- 也无需模型填充像素级细节,因为这往往会导致学习到的表示在语义上缺乏意义。

🚀 快速开始
模型信息
属性 |
详情 |
数据集 |
ILSVRC/imagenet-1k |
库名称 |
transformers |
许可证 |
cc-by-nc-4.0 |
模型原理
与具有像素解码器的生成式方法不同,I-JEPA 有一个在潜在空间进行预测的预测器。
I-JEPA 中的预测器可以被视为一个原始(且受限)的世界模型,它能够从部分可观察的上下文中对静态图像中的空间不确定性进行建模。
这个世界模型具有语义性,因为它预测的是图像中未观察区域的高级信息,而非像素级细节。
我们训练了一个随机解码器,它可以将 I-JEPA 预测的表示映射回像素空间,形成草图。
该模型能够正确捕捉位置不确定性,并以正确的姿态生成高级对象部分(例如,狗的头部、狼的前腿)。

预期用途和局限性
I-JEPA 可用于图像分类或特征提取。此特定检查点旨在用于特征提取。
💻 使用示例
基础用法
以下是如何使用此模型进行图像特征提取的示例:
import requests
from PIL import Image
from torch.nn.functional import cosine_similarity
from transformers import AutoModel, AutoProcessor
url_1 = "http://images.cocodataset.org/val2017/000000039769.jpg"
url_2 = "http://images.cocodataset.org/val2017/000000219578.jpg"
image_1 = Image.open(requests.get(url_1, stream=True).raw)
image_2 = Image.open(requests.get(url_2, stream=True).raw)
model_id = "jmtzt/ijepa_vith14_1k"
processor = AutoProcessor.from_pretrained(model_id)
model = AutoModel.from_pretrained(model_id)
def infer(image):
inputs = processor(image, return_tensors="pt")
outputs = model(**inputs)
return outputs.last_hidden_state.mean(dim=1)
embed_1 = infer(image_1)
embed_2 = infer(image_2)
similarity = cosine_similarity(embed_1, embed_2)
print(similarity)
📚 详细文档
BibTeX引用
如果您在工作中使用了 I-JEPA 或此代码,请引用:
@article{assran2023self,
title={Self-Supervised Learning from Images with a Joint-Embedding Predictive Architecture},
author={Assran, Mahmoud and Duval, Quentin and Misra, Ishan and Bojanowski, Piotr and Vincent, Pascal and Rabbat, Michael and LeCun, Yann and Ballas, Nicolas},
journal={arXiv preprint arXiv:2301.08243},
year={2023}
}