Views
No views yet
1from transformers import AutoModel
2import torch
3
4# Load the vision encoder
5vision_encoder = AutoModel.from_pretrained("your-repository/pixtral-12b-vision-encoder")1from PIL import Image
2import torch
3
4# Load an image
5image = Image.open("example_image.jpg")
6
7# Preprocess the image (ensure to use the corresponding processor)
8inputs = vision_processor(images=image, return_tensors="pt")
9
10# Extract visual features
11with torch.no_grad():
12 visual_embeddings = vision_encoder(**inputs).last_hidden_state
13
14# Now you can use visual_embeddings for downstream tasks