|
Download README.md from BenBausch/Xray-Reidentification: direct link, hf CLI and curl.
- Browser
- Download file 2.94 kB
-
https://huggingface.co/BenBausch/Xray-Reidentification/resolve/main/README.md
- Command line
-
hf download hf://BenBausch/Xray-Reidentification/README.md
-
curl -L -o README.md https://huggingface.co/BenBausch/Xray-Reidentification/resolve/main/README.md
2.94 kB
| license: apache-2.0 | |
| library_name: pytorch | |
| pipeline_tag: image-feature-extraction | |
| tags: | |
| - medical-imaging | |
| - chest-x-ray | |
| - patient-re-identification | |
| - b-cos | |
| - dinov2 | |
| - lora | |
| - metric-learning | |
| datasets: | |
| - ChestX-ray14 | |
| # Patient re-identification on chest X-rays | |
| Trained weights for patient re-identification on chest X-rays, from the code in | |
| [BenBausch/Few-Shot-Fingerprinting](https://github.com/BenBausch/Few-Shot-Fingerprinting). | |
| Both models map a 512 x 512 chest X-ray to a 128-d embedding; images of the same patient have a | |
| high cosine similarity. They were trained on ChestX-ray14 with the patient splits of Packhäuser et | |
| al. 2022 (contrastive loss with cross-batch memory, 16 patients x 8 images per batch). | |
| | Folder | Model | Name in `configs/evaluation.json` | Test mAP@R | Verification AUC | | |
| |---|---|---|---|---| | |
| | `bcos-r50-final-eval-model` | B-cos ResNet-50 (interpretable), 300 epochs, best epoch 298 | `bcos-r50-300ep-ep298-512` | 0.9553 | 0.9982 | | |
| | `dinov2l-lora-ep54-512` | DINOv2-L + LoRA (rank 16, query/value), best epoch 54 | `dinov2l-lora-ep54-512` | 0.9383 | 0.9984 | | |
| Retrieval on the whole ChestX-ray14 test split (24,214 queries), verification on the test pairs of | |
| Packhäuser et al. Each folder's README has the full training setup and results. | |
| ## Contents | |
| Each folder holds the checkpoint (`best_model.pth`), the training configs (`configs/`) and a | |
| README. The checkpoints hold only the weights (`model_state_dict`) and `epoch`, `best_epoch`, | |
| `best_metric`; the training state (optimizer, scheduler, loss memory, RNG) is not included, so | |
| they are for inference and fine-tuning, not for resuming the runs. They load with | |
| `torch.load(..., weights_only=True)`. The DINOv2 checkpoint holds only the LoRA weights, the | |
| projection layer and the standardisation statistics; the frozen backbone | |
| (`facebook/dinov2-large`) is loaded from the Hugging Face hub. | |
| The paths in the configs point to the machine the models were trained on. | |
| Check the downloads with `sha256sum -c SHA256SUMS`. | |
| ## Usage | |
| ```bash | |
| git clone https://github.com/BenBausch/Few-Shot-Fingerprinting | |
| cd Few-Shot-Fingerprinting | |
| uv sync | |
| hf download BenBausch/Xray-Reidentification --local-dir final-model-weights | |
| ``` | |
| ```python | |
| import json, torch | |
| from models import get_model # run from src/ | |
| folder = "../final-model-weights/bcos-r50-final-eval-model" | |
| config = json.load(open(f"{folder}/configs/config.json")) | |
| checkpoint = torch.load(f"{folder}/best_model.pth", map_location="cpu", weights_only=True) | |
| config["MODEL"]["CHECKPOINT"] = None # weights come from the checkpoint | |
| model = get_model(config, checkpoint=checkpoint).eval() | |
| ``` | |
| ## License | |
| Apache 2.0. The models were trained on ChestX-ray14, which is subject to its own terms of use. | |
| The B-cos model was initialised from the | |
| [B-cos v2](https://github.com/B-cos/B-cos-v2) ImageNet weights, the DINOv2 model builds on | |
| [DINOv2](https://github.com/facebookresearch/dinov2) (Apache 2.0). | |