Views
No views yet
dinov2-baseCLS tokenpip install rad-dino1>>> from rad_dino import RadDino
2>>> from rad_dino.utils import download_sample_image
3>>> encoder = RadDino()
4>>> image = download_sample_image()
5>>> image
6<PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=2765x2505 at 0x7CCD5C014050>
7>>> cls_embeddings, patch_embeddings = encoder.extract_features(image)
8>>> cls_embeddings.shape, patch_embeddings.shape
9(torch.Size([1, 768]), torch.Size([1, 768, 37, 37]))git clone https://github.com/facebookresearch/dinov2.git1>>> import torch
2>>> from rad_dino.utils import safetensors_to_state_dict
3>>> rad_dino_gh = torch.hub.load("./dinov2", "dinov2_vitb14")
4>>> backbone_state_dict = safetensors_to_state_dict("backbone_compatible.safetensors")
5>>> rad_dino_gh.load_state_dict(backbone_state_dict, strict=True)
6<All keys matched successfully>1>>> from dinov2.layers import DINOHead
2>>> rad_dino_head_gh = DINOHead(
3... in_dim=768,
4... out_dim=65536,
5... hidden_dim=2048,
6... bottleneck_dim=256,
7... nlayers=3,
8... )
9>>> head_state_dict = safetensors_to_state_dict("dino_head.safetensors")
10>>> rad_dino_head_gh.load_state_dict(head_state_dict, strict=True)
11<All keys matched successfully>ssl_default_config.yaml and vitb14_cxr.yaml, and the augmentations module are also available in the repository to help researchers reproduce the training procedure with our hyperparameters.| Dataset | Num. images |
|---|---|
| MIMIC-CXR | 368 960 |
| CheXpert | 223 648 |
| NIH-CXR | 112 120 |
| PadChest | 136 787 |
| BRAX | 41 260 |
| TOTAL | 882 775 |
./training_images.csv.Standard_NC96ads_A100_v4 nodes with four NVIDIA A100 (80 GB) GPUs each.1@article{perez-garcia_exploring_2025,
2 title = {Exploring scalable medical image encoders beyond text supervision},
3 issn = {2522-5839},
4 url = {https://doi.org/10.1038/s42256-024-00965-w},
5 doi = {10.1038/s42256-024-00965-w},
6 journal = {Nature Machine Intelligence},
7 author = {P{\'e}rez-Garc{\'i}a, Fernando and Sharma, Harshita and Bond-Taylor, Sam and Bouzid, Kenza and Salvatelli, Valentina and Ilse, Maximilian and Bannur, Shruthi and Castro, Daniel C. and Schwaighofer, Anton and Lungren, Matthew P. and Wetscherek, Maria Teodora and Codella, Noel and Hyland, Stephanie L. and Alvarez-Valle, Javier and Oktay, Ozan},
8 month = jan,
9 year = {2025},
10}Pérez-García, F., Sharma, H., Bond-Taylor, S., Bouzid, K., Salvatelli, V., Ilse, M., Bannur, S., Castro, D. C., Schwaighofer, A., Lungren, M. P., Wetscherek, M. T., Codella, N., Hyland, S. L., Alvarez-Valle, J., & Oktay, O. (2025). Exploring scalable medical image encoders beyond text supervision. In Nature Machine Intelligence. Springer Science and Business Media LLC. https://doi.org/10.1038/s42256-024-00965-w
fperezgarcia@microsoft.com).