Image Feature Extraction
Transformers
Safetensors
dinov3_vit
medical-imaging
hand-xray
foundation-model
neurips-2026
Instructions to use Yuesai/HandXFM with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Yuesai/HandXFM with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-feature-extraction", model="Yuesai/HandXFM")# pip install -U transformers accelerate # Load model directly from transformers import AutoImageProcessor, AutoModel processor = AutoImageProcessor.from_pretrained("Yuesai/HandXFM") model = AutoModel.from_pretrained("Yuesai/HandXFM", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Upload folder using huggingface_hub
Browse files
README.md
CHANGED
|
@@ -36,12 +36,24 @@ image = Image.open("hand_xray.png").convert("RGB")
|
|
| 36 |
inputs = processor(images=image, return_tensors="pt")
|
| 37 |
|
| 38 |
with torch.no_grad():
|
| 39 |
-
|
| 40 |
|
| 41 |
-
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
```
|
| 44 |
|
|
|
|
|
|
|
| 45 |
**Intended use:** Research on hand radiographs. Not validated for direct clinical diagnosis or treatment decisions. The model weights are distributed subject to the [DINOv3 License](https://github.com/facebookresearch/dinov3/blob/main/LICENSE.md); see the accompanying license file.
|
| 46 |
|
| 47 |
## Citation
|
|
|
|
| 36 |
inputs = processor(images=image, return_tensors="pt")
|
| 37 |
|
| 38 |
with torch.no_grad():
|
| 39 |
+
tokens = model(**inputs).last_hidden_state
|
| 40 |
|
| 41 |
+
# DINOv3 token order: [CLS, register tokens, patch tokens]
|
| 42 |
+
num_register_tokens = getattr(model.config, "num_register_tokens", 0)
|
| 43 |
+
cls_embedding = tokens[:, 0, :] # [B, 768]
|
| 44 |
+
patch_embeddings = tokens[:, 1 + num_register_tokens:, :] # [B, 196, 768] for 224x224
|
| 45 |
+
|
| 46 |
+
# Optional: mean-pool CLS + patch tokens (excluding register tokens)
|
| 47 |
+
features = torch.cat([cls_embedding.unsqueeze(1), patch_embeddings], dim=1)
|
| 48 |
+
pooled_embedding = features.mean(dim=1) # [B, 768]
|
| 49 |
+
|
| 50 |
+
print("CLS:", cls_embedding.shape)
|
| 51 |
+
print("Patches:", patch_embeddings.shape)
|
| 52 |
+
print("Pooled:", pooled_embedding.shape)
|
| 53 |
```
|
| 54 |
|
| 55 |
+
Use `cls_embedding` for global image features, `patch_embeddings` for spatial features, or `pooled_embedding` for a single pooled representation. Register tokens are excluded from patch features.
|
| 56 |
+
|
| 57 |
**Intended use:** Research on hand radiographs. Not validated for direct clinical diagnosis or treatment decisions. The model weights are distributed subject to the [DINOv3 License](https://github.com/facebookresearch/dinov3/blob/main/LICENSE.md); see the accompanying license file.
|
| 58 |
|
| 59 |
## Citation
|