strangelab/siglip2-base-patch16-naflex-vision-fp16
a compact visual encoder based on Google SigLIP 2
2 min readupdated
This model is a lightweight version of the Google SigLIP 2 NaFlex Base visual encoder, where the developers at Strange Lab removed the text component and converted the weights to the FP16 format (16-bit floating-point precision). The file size is just 185.9 MB, which is 87.6% smaller than the original joint model. The encoder outputs a single 768-dimensional vector for each image while preserving aspect ratios and using up to 256 patches. This solution is ideal for developers who need to quickly index photos or search for similar images without an unnecessary text component.
Key features
- Compact size: Checkpoint size is only 185.9 MB instead of 1.5 GB in the original release.
- Aspect ratio preservation: The built-in image processor automatically adjusts the size of source images.
- Standard library: Full compatibility with the Transformers ecosystem for quick loading via
AutoModel. - Weight accuracy: Tests on the Flickr8k dataset showed results identical to Google's original FP32 version.
What you can do
- Photo indexing: Build a local vector database for fast similarity search.
- Image comparison: Measure cosine similarity between photos for classification or deduplication.
- Pipeline integration: Use the encoder as a lightweight feature extractor in third-party computer projects.
Example
from PIL import Image
import torch
from transformers import AutoImageProcessor, AutoModel
model_id = "strangelab/siglip2-base-patch16-naflex-vision-fp16"
processor = AutoImageProcessor.from_pretrained(model_id)
model = AutoModel.from_pretrained(model_id, dtype=torch.float32).eval()
image = Image.open("photo.jpg").convert("RGB")
with torch.inference_mode():
inputs = processor(images=image, return_tensors="pt")
embedding = torch.nn.functional.normalize(model(**inputs).pooler_output, dim=-1)Read more
DetailsFlickr8k benchmarks (Image-to-text R@1): 87.4% (original Google FP32), 87.4% (FP32 model), 87.1% (FP16 model).
Hardware requirements: minimal, the model runs successfully on CPU and Apple MPS.
License: Apache License 2.0.
Limitations: text queries require compatible embeddings from Google's original text encoder.










Comments