Views
No views yet

1from transformers import AutoImageProcessor, ViTModel
2import torch
3from PIL import Image
4
5# Adjust the size, crop_size, etc. fields to your liking
6processor = AutoImageProcessor.from_pretrained('facebook/webssl-mae300m-full2b-224')
7model = ViTModel.from_pretrained('facebook/webssl-mae300m-full2b-224').cuda().eval()
8
9# Process an image
10image = Image.open('path/to/image.jpg')
11inputs = processor(images=image, return_tensors="pt").to('cuda')
12with torch.no_grad():
13 outputs = model(**inputs)
14
15# Extract features from the encoder
16encoder_hidden_states = outputs.last_hidden_state1@article{fan2025scaling,
2 title={Scaling Language-Free Visual Representation Learning},
3 author={David Fan and Shengbang Tong and Jiachen Zhu and Koustuv Sinha and Zhuang Liu and Xinlei Chen and Michael Rabbat and Nicolas Ballas and Yann LeCun and Amir Bar and Saining Xie},
4 year={2025},
5 eprint={2504.01017},
6 archivePrefix={arXiv},
7 primaryClass={cs.CV}
8}