--- library_name: open_clip pipeline_tag: zero-shot-image-classification tags: - biomedical - contrastive-learning - image-text-retrieval - zero-shot-classification --- # BioLoom Models

arXiv 2611.33151 GitHub code Project page Loom52M dataset Evaluation suite

BioLoom is a biomedical dual encoder for image–text retrieval and zero-shot classification, trained on 52.4 million image–text pairs from Loom52M. It uses whole figures, panels, captions, and relationships within scientific articles to supervise contrastive learning. The main models share a BioClinical ModernBERT text encoder and a ViT-L/14 vision encoder, with either randomly initialized or DFN-2B-initialized visual weights. ## 📦 Model weights Each model directory contains the weights, architecture configuration, and evaluation files. - **Main models** · [BioLoom (Scratch)](https://huggingface.co/ChartFoundation/BioLoom-models/tree/main/Main/Scratch) · [BioLoom (DFN-2B)](https://huggingface.co/ChartFoundation/BioLoom-models/tree/main/Main/DFN-2B) - **Vision initialization** · [CommonPool](https://huggingface.co/ChartFoundation/BioLoom-models/tree/main/Initialization/CommonPool) · [DINOv2](https://huggingface.co/ChartFoundation/BioLoom-models/tree/main/Initialization/DINOv2) - **Model size** · [ViT-S](https://huggingface.co/ChartFoundation/BioLoom-models/tree/main/Model-size/ViT-S-14) · [ViT-B](https://huggingface.co/ChartFoundation/BioLoom-models/tree/main/Model-size/ViT-B-14) · [ViT-H](https://huggingface.co/ChartFoundation/BioLoom-models/tree/main/Model-size/ViT-H-14) ## 💻 Inference Install the project’s [OpenCLIP implementation](https://github.com/yuweiyang-anu/BioLoom) and its inference dependencies. From its checkout: ```bash pip install -r src/requirements.txt "transformers>=4.48,<5" export PYTHONPATH="$PWD/src:$PYTHONPATH" ``` Choose a model folder in the table. Set `folder` in the example to load its weights and configuration together. The variant name is also the value for `--model` in the evaluation CLI. | Variant | Model folder | |---|---| | `scratch` | `Main/Scratch` | | `dfn2b` | `Main/DFN-2B` | | `commonpool` | `Initialization/CommonPool` | | `dinov2` | `Initialization/DINOv2` | | `vit-s` | `Model-size/ViT-S-14` | | `vit-b` | `Model-size/ViT-B-14` | | `vit-h` | `Model-size/ViT-H-14` | ```python import json from pathlib import Path import open_clip import torch from huggingface_hub import snapshot_download from open_clip.tokenizer import HFTokenizer from PIL import Image folder = "Main/DFN-2B" files = ["open_clip_pytorch_model.bin", "open_clip_config.json"] snapshot = snapshot_download( "ChartFoundation/BioLoom-models", allow_patterns=[f"{folder}/{name}" for name in files], ) directory = Path(snapshot) / folder device = "cuda" if torch.cuda.is_available() else "cpu" model, preprocess = open_clip.create_model_from_pretrained( f"local-dir:{directory}", device=device ) model.eval() text_cfg = json.loads((directory / "open_clip_config.json").read_text())["model_cfg"]["text_cfg"] tokenizer = HFTokenizer(text_cfg["hf_tokenizer_name"], context_length=text_cfg["context_length"]) image = preprocess(Image.open("figure.jpg").convert("RGB")).unsqueeze(0).to(device) tokens = tokenizer(["a microscopy image", "a radiograph"]).to(device) with torch.inference_mode(): scores = model.encode_image(image, normalize=True) @ model.encode_text(tokens, normalize=True).T print(scores.cpu()) ``` ## 🧪 Evaluation For example, evaluate the downloaded DFN-2B model on the full BioLoomBench gallery from the BioLoom checkout. Set `MODEL_DIR` to the directory printed by `print(directory)` in the loading example. ```bash python -m evaluation --model dfn2b --benchmark bioloombench --download \ --checkpoint "$MODEL_DIR/open_clip_pytorch_model.bin" --output results/dfn2b.json ``` To evaluate a checkpoint, use the data and protocols in [BioLoom-EvalSuite](https://huggingface.co/datasets/ChartFoundation/BioLoom-EvalSuite). Load the checkpoint and its matching architecture as shown above, then follow the zero-shot classification, BioMedFlickr, or BioLoomBench guide. Each model’s `results/` folder contains three files: `zero-shot.json` for all 67 classification tasks, `biomedflickr-retrieval.json` for BioMedFlickr, and `bioloom-retrieval.json` for BioLoomBench.