Downloads · 30 days
11
12% of all-time downloads
shenxiaochen/brain-mri-siglip
brain-mri-siglip is a feature extraction model from shenxiaochen. Use it when you need embeddings to search or compare text. It is set up for transformers.
Brain MRI SigLIP is a 3D MRI vision-language representation model trained with a SigLIP-style image-text contrastive objective. This repository publishes the final saved stage2jointfinetune checkpoint from the brainmr…
Downloads · 30 days
11
12% of all-time downloads
All-time downloads
91
Public
Parameters
884M
3.5 GB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors3.5 GB · 100%
From the Hugging Face model README
Brain MRI SigLIP is a 3D MRI vision-language representation model trained with a SigLIP-style image-text contrastive objective. This repository publishes the final saved stage2_joint_finetune checkpoint from the brain_mri_siglip_run_0509 experiment.
This checkpoint is intended as a research visual encoder for brain MRI downstream tasks and as a warm-start encoder for building a medical VLM. It is not a clinical diagnostic device.
google/medsiglip-448BrainMRISiglipModel[1, 128, 192, 192]1152[8, 16, 16]bf16.pt tensors, float16, value range [-1, 1]This model was initialized from the brain_mri_siglip_run_0509/stage1_freeze_text checkpoint and then jointly fine-tuned with both vision and text towers trainable.
Training summary:
950,72067,450metadata_text: 32,27885160800Training-time retrieval evaluation used capped validation subsets and should be treated as monitoring rather than a final benchmark.
This model uses custom Transformers code. Load it with trust_remote_code=True.
import torch
from transformers import AutoModel, AutoProcessor
repo_id = "shenxiaochen/brain-mri-siglip"
device = "cuda" if torch.cuda.is_available() else "cpu"
model = AutoModel.from_pretrained(
repo_id,
trust_remote_code=True,
dtype=torch.bfloat16 if torch.cuda.is_available() else torch.float32,
).to(device).eval()
processor = AutoProcessor.from_pretrained(
repo_id,
trust_remote_code=True,
)
For reproducible inference from NIfTI files, pass paths directly to the saved processor. This repository includes the offline-aligned preprocessing implementation used to match the training tensor distribution.
nifti_path = "/path/to/brain_mri.nii.gz"
inputs = processor(
volumes=nifti_path,
return_tensors="pt",
)
pixel_values = inputs["pixel_values"].to(device)
if torch.cuda.is_available():
pixel_values = pixel_values.to(dtype=torch.bfloat16)
with torch.inference_mode():
image_embeds = model.get_image_features(pixel_values=pixel_values)
print(pixel_values.shape) # [1, 1, 128, 192, 192]
print(image_embeds.shape) # [1, 1152]
The saved path-based preprocessing recipe is:
1e-35mm margin0.5/99.5 percentiles[-1, 1](1.25, 1.0, 1.0)[128, 192, 192]-1.0The exact settings are saved in preprocessor_config.json and processor_config.json.
.pt InputsIf your data is already stored as the same offline preprocessed tensors used during training, you can load it directly:
payload = torch.load("/path/to/sample.pt", map_location="cpu")
pixel_values = payload["pixel_values"] if isinstance(payload, dict) else payload
if pixel_values.ndim == 4:
pixel_values = pixel_values.unsqueeze(0)
pixel_values = pixel_values.to(device=device, dtype=torch.bfloat16)
with torch.inference_mode():
image_embeds = model.get_image_features(pixel_values=pixel_values)
Expected tensor format:
[1, 128, 192, 192] for one volume, or [B, 1, 128, 192, 192] for a batch[-1, 1]-1.0For VLM construction, use the 3D vision tower as a visual backbone and add a projector, Q-Former, Perceiver resampler, or other token compressor before connecting to an LLM.
A practical downstream recipe is:
If you use this checkpoint, please cite this model repository and the upstream MedSigLIP model where appropriate.