Downloads · 30 days
4
33% of all-time downloads
tsvd/biomedclip-cxr-lora
biomedclip-cxr-lora is a image classification model from tsvd. Use it when you need a label for an image. It is set up for peft. The card lists the license as apache-2.0.
LoRA adapter for a chest X-ray multi-label classifier built on BiomedCLIP's vision tower.
Downloads · 30 days
4
33% of all-time downloads
All-time downloads
12
Public
Repo size
2.2 MB
Likes
0
Public
Click a slice to open those files.
.safetensors2.2 MB · 100%
From the Hugging Face model README
LoRA adapter for a chest X-ray multi-label classifier built on BiomedCLIP's vision tower.
Only the vision tower is used — this is an image-only multi-label classifier, not a CLIP similarity model.
| File | Description |
|---|---|
adapter_model.safetensors | LoRA weights (rank 8, Q&V of the last 6 transformer blocks) + classification head (768→512 proj, LayerNorm, 13 logits) |
adapter_config.json | LoRA hyperparameters (r=8, alpha=16, dropout=0.05) |
calibrated_thresholds.json | Per-class decision thresholds (Youden's J on validation) |
This adapter is part of a hand-reconstructed model graph, not an auto-loadable PEFT module. PeftModel.from_pretrained(...) will not work out of the box: the LoRA lives inside the fused qkv projection of a timm-wrapped ViT (visual.trunk), which has no stock PEFT target. You must rebuild the exact architecture before loading weights:
open_clip.create_model_and_transforms('microsoft/BiomedCLIP-PubMedBERT_256-vit_base_patch16_224').clip_model.visual).blocks[6..11]). timm backend: wrap blocks[idx].attn.qkv with a module that adds low-rank adapters to the Q and V slices of the fused qkv output (K slice unchanged). LoRA math: output = frozen_linear(x) + (alpha/r) * dropout(x) @ A^T @ B^T.nn.Sequential(LayerNorm(512), Dropout(0.1), Linear(512, 13)) over the encoder output (head input here is 512 — the output of encoder.head.proj).load_state_dict the tensors in adapter_model.safetensors onto the reconstructed state dict.(0.4815, 0.4578, 0.4082) / (0.2686, 0.2613, 0.2758) (BiomedCLIP's own preprocessing stats).model.eval(), torch.no_grad().13 raw logits, one per class, in this exact order:
['enlarged cardiomediastinum', 'cardiomegaly', 'atelectasis', 'consolidation',
'lung edema', 'fracture', 'lung lesion', 'pleural effusion', 'pneumonia',
'pneumothorax', 'support device', 'lung opacity', 'pleural other']
Multi-label: apply a per-class sigmoid (no softmax).
For binary predictions, threshold each class's sigmoid probability using calibrated_thresholds.json (per-class, not a flat 0.5). If you only need a score, report raw sigmoid outputs.