Image Feature Extraction
Transformers
JAX
Safetensors
MLX
PyTorch
aimv2_vision_model
vision
custom_code
Eval Results (legacy)
Instructions to use apple/aimv2-large-patch14-224 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use apple/aimv2-large-patch14-224 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-feature-extraction", model="apple/aimv2-large-patch14-224", trust_remote_code=True)# Load model directly from transformers import AutoImageProcessor, AutoModel processor = AutoImageProcessor.from_pretrained("apple/aimv2-large-patch14-224", trust_remote_code=True) model = AutoModel.from_pretrained("apple/aimv2-large-patch14-224", trust_remote_code=True) - MLX
How to use apple/aimv2-large-patch14-224 with MLX:
# Download the model from the Hub pip install huggingface_hub[hf_xet] huggingface-cli download --local-dir aimv2-large-patch14-224 apple/aimv2-large-patch14-224
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- LM Studio
Image and Text features
#3
by praff1234 - opened
Hello , could you please give a simple example of obtaining text features and imager features. Only image feature example has been added.
Doing it with MLX was kind of the point. I'm digging around in the repo, think you can get the tokenizer from from transformers:
processor = AutoProcessor.from_pretrained(
"apple/aimv2-large-patch14-224-lit",
)
then just find that in the library code and start looking around for a way to get the input_ids that should be what you calling in.venv/lib/python3.10/site-packages/aim/v2/mlx/models.py
It's this call:
class AIMv2LiT(nn.Module):
...
def encode_text(
self,
input_ids: mx.array,
mask: Optional[mx.array] = None,
output_features: bool = False,
) -> Union[mx.array, Tuple[mx.array, Tuple[mx.array, ...]]]:
out = self.text_encoder(input_ids, mask=mask, output_features=output_features)
out = self.text_projector(out)
return out
I'm gonna give up here for now, this is a sidetrack for something else. Please ping me if you fix a way to test it out in MLX!